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 would be great? Code is below to replicate.

This was fixed using the code below:

"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 would be great? Code is below to replicate.

Code:

```
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=N0,N1,N2))
cdf
```

Code:

```
ggdata <- data.frame(N0,N1,N2)
ggdata<- melt(ggdata)
ggdata <- ddply(ggdata, .(variable), transform, ecd=ecdf(value)(value))
cdf <- ggplot(ggdata, aes(x=value)) + stat_ecdf(aes(colour=variable))
cdf
```

Last edited: