[R] Arguments imply differing number of rows: 1, 0
John Murtagh
john9427 at gmail.com
Mon Mar 27 20:47:20 CEST 2017
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)
cdf <- ggplot(ggdata, aes(x=value)) +
stat_ecdf(aes(colour="blue","red","green"))
cdf
[[alternative HTML version deleted]]
More information about the R-help
mailing list