[R] melt function chooses wrong id variable with large datasets
Joachim Audenaert
Joachim.Audenaert at pcsierteelt.be
Thu Apr 16 11:36:38 CEST 2015
Hello all,
I'm using a large dataset consisting of 2 groups of data, 2 columns in
excel with a header (group name) and 15 000 rows of data. I would like
like to compare this data, so I transform my dataset with the melt
function to get 1 column of data and 1 column of ID variables, then I can
apply different statistical tests. With small datasets this works great,
the melt function automatically chooses the name in row 1 as ID variable
and melts the data, thus giving me a matrix with all ID variables in
column one and the data accordingly in column 2.
With this big dataset however it chooses the whole first column as ID
variables in stead of the first row. Is there a reason why this happens
and how can I make sure the first row is chosen as ID variabele and the
lower rows as data?
If I specify that I want the first row to be the id variable I also get
error.
melt(dataset,id.vars=dataset[1,], na.rm=TRUE)
Error: id variables not found in data: norm, jaar
Are there alternative ways to create a good reshaped dataset?
Met vriendelijke groeten - With kind regards,
Joachim Audenaert
onderzoeker gewasbescherming - crop protection researcher
PCS | proefcentrum voor sierteelt - ornamental plant research
Schaessestraat 18, 9070 Destelbergen, België
T: +32 (0)9 353 94 71 | F: +32 (0)9 353 94 95
E: joachim.audenaert at pcsierteelt.be | W: www.pcsierteelt.be
Heb je je individuele begeleiding bemesting (CVBB) al aangevraagd? | Het
PCS op LinkedIn
Disclaimer | Please consider the environment before printing. Think green,
keep it on the screen!
[[alternative HTML version deleted]]
More information about the R-help
mailing list