Message-ID: <7123A5E3-DAC9-4CBA-A256-7739A8F11D29@comcast.net>
Date: 2012-09-26T21:27:37Z
From: David Winsemius
Subject: replace string values with numbers
In-Reply-To: <SNT135-W8C85744B8741AD6049F8ECB9C0@phx.gbl>
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