Converting set of rows into column in R

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

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

Blockquote

Blockquote



Answers 1


You can use reshape function as shown below

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

Related Questions


Updated December 20, 2018 23:26 PM

Updated September 09, 2019 12:26 PM

Updated January 13, 2018 09:26 AM

Updated June 27, 2018 01:26 AM

Updated October 09, 2018 10:26 AM