0

I'm working with a large dataset and I used the melt function and the values in the table remained the same but when I applied the dcast function the values changed from species name, As Ns Ss and numbers to all 0s or 1s.

I've tried googling this specifically and have found nothing and have looked up the dcast function but am having a hard time understanding what in it would be causing the values to switch to 0s and 1s. This is my first time ever writing my own code and I'm not a trained programmer so I have spent hours trying to figure this out on my own and I can't think of anything else to try.

PhenotypeData_melt <- melt(PhenotypeData_wheat, id=c("Trial", "Trait"))

PhenotypeData_Spread <- dcast(PhenotypeData_melt, Trial ~ Trait + variable, value.var="value")

I haven't received any error messages. Although I do receive "Aggregation function missing: defaulting to length". I would like to fix this code so that the value stays as it is and isn't converted to 0s and 1s.

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
  • Hi. Please read this answer (https://stackoverflow.com/a/5963610/882102) about providing good minimal working examples, so we can better help you. – MrGumble Aug 07 '19 at 06:25
  • The message about length means that you have multiple values for each cell so it is aggregating them. Maybe check your data for duplicates (jointly in Trial, Trait, variable) – Frank Aug 17 '19 at 18:37

0 Answers0