] create multiple categorical variables in a data frame using a
loop
[Attention: This email came from an external source. Do not open attachments or
click on links from unknown senders or unexpected emails.]
> On Apr 19, 2018, at 1:22 PM, David Winsemius wrote:
>
>
>> On Apr
> On Apr 19, 2018, at 1:22 PM, David Winsemius wrote:
>
>
>> On Apr 19, 2018, at 11:20 AM, Ding, Yuan Chun wrote:
>>
>> Hi All,
>>
>> I want to create a categorical variable, cat.pfoa, in the file of pfas.pheno
>> (a data frame) based on log2pfoa values. I can do it using the following
>>
> On Apr 19, 2018, at 11:20 AM, Ding, Yuan Chun wrote:
>
> Hi All,
>
> I want to create a categorical variable, cat.pfoa, in the file of pfas.pheno
> (a data frame) based on log2pfoa values. I can do it using the following code.
>
> pfas.pheno <-within(pfas.pheno, {cat.pfoa<-NA
> cat.pfoa[pf
variables in a data frame using a
loop
[Attention: This email came from an external source. Do not open attachments or
click on links from unknown senders or unexpected emails.]
Hello,
When programming it is better to use dat[["variable"]] than dat$variable.
So your code could be
Hello,
When programming it is better to use dat[["variable"]] than dat$variable.
So your code could be
pfas.pheno[[cat.var]] <- NA
pfas.pheno[[cat.var]][pfas.pheno[,i] <= quantile(pfas.pheno[,i],0.25,
na.rm =T)] <- 0
etc.
Untested.
Hope this helps,
Rui Barradas
On 4/19/2018 7:20 PM, Ding
Hi All,
I want to create a categorical variable, cat.pfoa, in the file of pfas.pheno (a
data frame) based on log2pfoa values. I can do it using the following code.
pfas.pheno <-within(pfas.pheno, {cat.pfoa<-NA
cat.pfoa[pfas.pheno$log2pfoa <=quantile(pfas.pheno$log2pfoa,0.25, na.rm
=T)]<-0
c
6 matches
Mail list logo