I think I am overlooking a call or concept in R to help me easily and quickly
restructure my data.frame:
Sometimes the data I receive looks like:
VariableName, Run1, Run2, Run3, Location
temp, 15.0, 16.0, 17.0, There
And other times it looks like:
VariableName, Run, Location
temp, 17.0, There
I would like to use the header information in order to be able to restructure
the first data set to have a similar look as the second, i.e.
VariableName, Run, Location,
temp, 15.0, There # Really Run1
temp, 16.0, There # Really Run2
temp, 17.0, There # Really Run3
Right now I am manually recombining:
tmp_1<-data.frame(data$VariableName, data$ Run1, data$Location)
tmp_2<-data.frame(data$VariableName, data$ Run2, data$Location)
tmp_3<-data.frame(data$VariableName, data$ Run3, data$Location)
combine_1<-rbind(tmp_1, tmp_2)
combine_1<-rbind(combine_1, tmp_3)
Is there an easier way that is more flexible? I would like to make it flexible
enough to handle the case where I have two or four runs.
Thank you for any feedback.
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
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.