I have the following data.frame:
group <- sample(c("egyptian", "american", "irish", "australian"), 50, TRUE)
E <- c(rnorm(50, 5, 6))
F <- c(rnorm(50, 7.8, 4.5))
G <- c(rnorm(50, 65, 16.7))
test <- data.frame(group=group, E=E, F=F, G=G)
My goal is to generate data.frameone that includes groupas a heading and lists its corresponding values in Ebelow.
something like this data.frame:
egyptian <- c(rnorm(50,5,6))
american<- c(rnorm(50,5,6))
irish<- c(rnorm(50,5,6))
australian<- c(rnorm(50,5,6))
test <- data.frame(egyptian=egyptian, american=american,
irish=irish, australian=australian)
I tried to multiply 2 columns and then use dcast,, but that failed. Is dcast2 columns possible from long to wide?
source
share