rnorouzian rnorouzian - 3 years ago 153
R Question

Why a value for an R object appears twice in a cbind output in R?

I was wondering how I could prevent the numeric value of object

eta
in my R code below from being repeated (as it does now) in the second row of my
cbind()
output and instead of that an
NA
be inserted in the second row?

Here is my current
cbind
output:


Df Sum Sq Mean Sq F value Pr(>F) eta
k 2 8.688793 4.3443964 5.47955 0.02038724 0.4773314
Residuals 12 9.514058 0.7928382 NA NA 0.4773314(This one is repetitive! I want `NA` here)


Here is my R code:

k = gl(3, 5, 15)
y = as.vector(unlist(mapply(FUN = rnorm, n = rep(5, 3), mean = c(4, 5, 6))))
a = anova(aov(y ~ k))
eta = a[, 2][1] / (a[, 2][1] + a[, 2][2])
cbind(a, eta)

Answer Source

Pretty sure eta value is being recycled. Try cbind(a, c(eta, NA))

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download