Converting set of rows into column in R

by Gull   Last Updated October 20, 2019 05:26 AM - source

I have a data set containing information regarding morphological traits of individuals of several species. Columns are about the individual id, species' name, trait types and trait values. I need to arrange the data in a manner where each traits should be as columns and species and individual id should be in rows. I have hundreds of individuals and several species



Answers 1

You can use reshape function as shown below

reshape(data,idvar = c("sample", "species"), timevar = "trait", v.names = "value", dir = "wide")
October 20, 2019 05:18 AM

Related Questions

How to transform panel data into specific wide format?

Updated December 20, 2018 23:26 PM

retaining names of levels of variables while melting

Updated January 13, 2018 09:26 AM

Long to Wide Multiple variables in R

Updated October 09, 2018 10:26 AM