2017年4月28日 星期五

melt() 使用時 measure variable 的型態要一致

使用 melt() 來 reshape 資料時, measure variable 的型態要一致,否則會出現警告。

例如有以下的資料:


資料中,subject 欄位為 factor。若使用 subject 為 id.var 進行 melt,則會出現以下警告訊息:


因為,第一個欄位為 Factor 型態,melt() 把後面其他的欄位也視為 Factor,造成轉換時的錯誤。


Reference:
[1] thiagogm, 2013. Reshape and aggregate data with the R package reshape2, www.r-bloggers.com.

沒有留言: