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
Asked
Active
Viewed 33 times
-1
-
1this is the `dcast` function, see `?dcast` and let us know what is unclear there :) – MichaelChirico Oct 20 '19 at 05:13
1 Answers
1
You can use reshape
function as shown below
reshape(data,idvar = c("sample", "species"), timevar = "trait", v.names = "value", dir = "wide")

Onyambu
- 67,392
- 3
- 24
- 53