[R] Arguments imply differing number of rows: 1, 0
Gerrit Eichner
Gerrit.Eichner at math.uni-giessen.de
Tue Mar 28 11:32:42 CEST 2017
Hi, John,
see inline.
Am 27.03.2017 um 20:47 schrieb John Murtagh:
> Hi All,
>
> I am trying to generate a cdf plot by using ggplot and have looked at some
> examples online. However when I try to replicate it I get the following
> error:
>
> "arguments imply differing number of rows: 1, 0"
>
> I made a search and it seems from what I gather the nrows!=ncol and that
> doesn't work for a data.frame. I am confused a bit as my MCtab dataframe is
> similar.
>
> If someone can explain what is going wrong or what i am
> misunderstanding/doing wrong would be great? Code is below to replicate.
> Thanks
>
> library (triangle)
> library(ggplot2)
>
> n = 1000
> W1 = rtriangle(n,330,400)
> W2 = rtriangle(n,300,420)
> SO = rtriangle(n,0.2,0.3)
>
> MCtab <- data.frame(W1,W2,SO)
>
> set.seed(1)
> for (n in 1:n) {
> N0 <- (W1 + W2 + SO )}
>
> set.seed(1)
> for (n in 1:n) {
> N1 <- ((0.99*W1 + 0.99*W2 + 0.99*SO ))}
>
> set.seed(1)
> for (n in 1:n) {
> N2 <- ((0.98*W1 + 0.98*W2 + 0.98*SO))}
>
> ggdata <- data.frame(N0,N1,N2)
>
>
> ggdata <- ddply(ggdata, .(N0,N1,N2), transform, ecd=ecdf)
I'm not familiar with ggplot, but I do not think that splitting your
ggdata by your numerical variables N1, N2 and N3 makes any sense ...
PS: I also think that your loops to create N1, N2 and N3 are pretty
nonsensical.
>
> cdf <- ggplot(ggdata, aes(x=value)) +
> stat_ecdf(aes(colour="blue","red","green"))
> cdf
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Hth -- Gerrit
---------------------------------------------------------------------
Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/eichner
More information about the R-help
mailing list