Hello,
Inline.
Às 22:44 de 29/04/20, Ana Marija escreveu:
Hi Rui,
thanks for getting back to me
so I tried your method and I got:
sum(b$PHENO==2, na.rm=T)
[1] 828
sum(b$PHENO==1, na.rm=T)
[1] 859
Can you please tell me if
b$PHENO <- (b$FLASER == 2 | b$PLASER == 2) + 1L
just assigns PHENO
Thank you so much, numbers add up now!
On Wed, Apr 29, 2020 at 5:09 PM wrote:
>
> While I've sent you a maths way to do it,
>
> I'd probably take this approach;
>
> # set b$pheno to 1 as default
>
> b$pheno <- 1
>
> # set the flaser
>
> b$pheno[b$flaser == 2] <- 2
>
> #set the plaser
>
> b$pheno[
Hi Rui,
thanks for getting back to me
so I tried your method and I got:
> sum(b$PHENO==2, na.rm=T)
[1] 828
> sum(b$PHENO==1, na.rm=T)
[1] 859
Can you please tell me if
b$PHENO <- (b$FLASER == 2 | b$PLASER == 2) + 1L
just assigns PHENO=2 if b$FLASER == 2 | b$PLASER == 2 and everything else is 1?
Or if you prefer not to load an entire suite of packages to do such a
simple task you could use
b$PHENO <- ifelse(...)
or in this specific case it seems sufficient to do
b$PHENO <- pmax(b$FLASER, b$PLASER)
/Ege
On Wed, 2020-04-29 at 15:30 -0400, Patrick (Malone Quantitative) wrote:
> If you do
Hello,
Here is another way. The condition returns FALSE/TRUE or 0/1. Add 1 to
get the expected result.
It has the advantage of being faster.
b$PHENO <- (b$FLASER == 2 | b$PLASER == 2) + 1L
Hope this helps,
Rui Barradas
Às 20:42 de 29/04/20, Ana Marija escreveu:
Thanks, I did this:
b$PHENO
Thanks, I did this:
b$PHENO<- ifelse(b$FLASER ==2 | b$PLASER ==2, 2, 1)
On Wed, Apr 29, 2020 at 2:36 PM Ivan Krylov wrote:
>
> On Wed, 29 Apr 2020 14:19:18 -0500
> Ana Marija wrote:
>
> > My conditions for creating a new column PHENO would be this:
> >
> > if FLASER or PLASER =2 then PHENO=2
> >
On Wed, 29 Apr 2020 14:19:18 -0500
Ana Marija wrote:
> My conditions for creating a new column PHENO would be this:
>
> if FLASER or PLASER =2 then PHENO=2
> otherwise PHENO=1
On Wed, 29 Apr 2020 15:30:45 -0400
"Patrick (Malone Quantitative)" wrote:
> If you don't mind using tidyverse, you ca
If you don't mind using tidyverse, you can do this easily with if_else.
b$PHENO<-if_else(...
On Wed, Apr 29, 2020 at 3:21 PM Ana Marija
wrote:
> Hello,
>
> I have a data frame like this:
>
> > head(b)
>FID IID FLASER PLASER
> 1: fam1000 G1000 1 1
> 2: fam1001 G1001
Hello,
I have a data frame like this:
> head(b)
FID IID FLASER PLASER
1: fam1000 G1000 1 1
2: fam1001 G1001 1 1
3: fam1003 G1003 1 2
4: fam1005 G1005 1 1
5: fam1009 G1009 2 1
6: fam1052 G1052 1 1
...
My conditions for cr
9 matches
Mail list logo