replace string values with numbers
On Sep 26, 2012, at 12:52 PM, JiangZhengyu wrote:
Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3. Gene[Gene=="GG"]<-3 It always give me: Warning in `[<-.factor`(`*tmp*`, thisvar, value = 3) : invalid factor level, NAs generated Does any know if there is anything wrong with my code?
You are trying to replace a factor value with a level that it doesn't have. Hence that particular very informative error message.
David Winsemius, MD Alameda, CA, USA