Re: [R] Obtaining p values from t-test run with a by function

2020-06-12 Thread Rui Barradas
Hello, Or in one go with *apply, function '[[': sapply(result, '[[', 'p.value') # EPAP #2.564503e-04 4.173480e-06 Hope this helps, Rui Barradas Às 23:20 de 12/06/20, Sarah Goslee escreveu: Where you have result[1]$p.value result[2]$p.value You need result[[1]]$p.value

Re: [R] if else statement adjustemtn

2020-06-12 Thread Ana Marija
Great idea! Here it is: > b[is.na(b$FLASER) | is.na(b$PLASER),] FID IID FLASER PLASER pheno 1: fam1837 G1837 1 NA 2 2: fam2410 G2410 NA NA 2 3: fam2838 G2838 NA 2 2 4: fam3367 G3367 1 NA 2 5: fam3410 G3410 1 NA 2 6: fam

Re: [R] if else statement adjustemtn

2020-06-12 Thread Jim Lemon
Since you have only a few troublesome NA values, if you look at them, or even better, post them: b[is.na(b$FLASER) | is.na(b$PLASER),] perhaps we can work out the appropriate logic to get rid of only the ones you don't want. Jim On Sat, Jun 13, 2020 at 12:50 PM Ana Marija wrote: > > Hi Rasmus,

Re: [R] if else statement adjustemtn

2020-06-12 Thread Ana Marija
Hi Rasmus, thank you for getting back to be, the command your provided seems to add all 11 NAs to 2s > b$pheno <- + ifelse(b$PLASER==2 | + b$FLASER==2 | + is.na(b$PLASER) | + is.na(b$PLASER) & b$FLASER %in% 1:2 | + is.na

Re: [R] if else statement adjustemtn

2020-06-12 Thread Rasmus Liland
On 2020-06-13 11:30 +1000, Jim Lemon wrote: > On Fri, Jun 12, 2020 at 8:06 PM Jim Lemon wrote: > > On Sat, Jun 13, 2020 at 10:46 AM Ana Marija wrote: > > > > > > I am trying to make a new column > > > "pheno" so that I reduce the number > > > of NAs > > > > it looks like those two NA values in >

Re: [R] if else statement adjustemtn

2020-06-12 Thread Jim Lemon
Obviously my guess was wrong. I thought you wanted to impute the value of "pheno" from FLASER if PLASER was missing. From just your summary table, it's hard to guess the distribution of NA values. My guess that the two undesirable NAs were cases where PLASER was missing and FLASER was 2. My tactic

Re: [R] if else statement adjustemtn

2020-06-12 Thread Ana Marija
Hi Jim, I tried it: > b$pheno<-ifelse(b$PLASER==2 | b$FLASER==2 |is.na(b$PLASER) & b$FLASER == > 2,2,1) > table(b$pheno,exclude = NULL) 12 859 828 11 > b$pheno<-ifelse(b$PLASER==2 | b$FLASER==2 |is.na(b$FLASER) & b$PLASER == > 2,2,1) > table(b$pheno,exclude = NULL) 12 859

Re: [R] if else statement adjustemtn

2020-06-12 Thread Jim Lemon
Hi Ana, >From your desired result, it looks like those two NA values in PLASER are the ones you want to drop. If so, try this: b$pheno<-ifelse(b$PLASER==2 | b$FLASER==2 | is.na(b$PLASER) & b$FLASER == 2,2,1) and if I have it the wrong way round, swap FLASER and PLASER in the bit I have added. J

[R] if else statement adjustemtn

2020-06-12 Thread Ana Marija
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 1 1 6: fam1052 G1052 1 1 ... > table(b$PLASER,b$FLASER, e

Re: [R] Creating one df from 85 df present in a list

2020-06-12 Thread Rasmus Liland
On 2020-06-13 01:54 +0200, Rasmus Liland wrote: > Dear Alejandro, Sorry, I programmed and wrote that email at the same time, changed the “toma_de_muestras” perhaps other things, then continued programming, thus this might make more sense ... Firstly, it would be easier to help you if you pro

Re: [R] Creating one df from 85 df present in a list

2020-06-12 Thread Rasmus Liland
On 2020-06-10 13:14 -0700, Bert Gunter wrote: > On Wed, Jun 10, 2020 at 11:48 AM Alejandro Ureta wrote: > > > > hi, I am trying to fuse (cbind, merge... > > NOT rbind) several dataframes with > > different numbers of rows, all df > > included in a list, and using the code > > extract shown bel

Re: [R] Obtaining p values from t-test run with a by function

2020-06-12 Thread Sarah Goslee
Where you have result[1]$p.value result[2]$p.value You need result[[1]]$p.value result[[2]]$p.value to get the first component of the list. Sarah On Fri, Jun 12, 2020 at 5:35 PM Sorkin, John wrote: > > Colleagues, > I am trying to retrieve the p values produced by a Student's t-test run usin

Re: [R] Obtaining p values from t-test run with a by function

2020-06-12 Thread Stephen Ellison
Define a wrapper function for the t test that only returns the p-value? by(mydata$WtBaseline,mydata$Group, function(...) t.test(...)$p.value) S Ellison From: R-help [r-help-boun...@r-project.org] on behalf of Sorkin, John [jsor...@som.umaryland.edu] Sent:

[R] Obtaining p values from t-test run with a by function

2020-06-12 Thread Sorkin, John
Colleagues, I am trying to retrieve the p values produced by a Student's t-test run using a by function, but can not do so. I can easily get the p value when I run s Student's t-test without a by function. What is the secret to obtaining results returned from a function run within a by function.

Re: [R] Help with a (g)lmer code

2020-06-12 Thread Bert Gunter
Questions on mixed models methodology, which this is, should be posted on the r-sig-mixed-models list, not here. That's where both the interest and expertise are. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley

[R] Update of addScales package with vignette on CRAN

2020-06-12 Thread Bert Gunter
I have added a couple of what I would like to think are worthwhile features to my addScales package. More important, also a short vignette. While this is part of the lattice graphics ecosystem, have a look at the vignette as it may have ideas that can be adapted/improved on in other graphics paradi

Re: [R] Help with a (g)lmer code

2020-06-12 Thread Saudi Sadiq
Hi Jim, So many thanks for your reply. I actually made a mistake in presenting the problem; I should have clarified that the 1-10 linear scale questions went as: 10 most humorous/closest to Egyptian culture and 1 the least. Also, I should have attached some examples so the participant issue could

Re: [R] function to return plots

2020-06-12 Thread Naresh Gurbuxani
Thanks for your quick response.  It works as I wanted.  From: Rui Barradas Sent: Friday, June 12, 2020 7:08 AM To: Naresh Gurbuxani ; r-help@r-project.org Subject: Re: [R] function to return plots   Hello, plot.list is a list, try '[[' to access its members. ('[' returns sub-lists.) plot(

Re: [R] function to return plots

2020-06-12 Thread Rui Barradas
Hello, plot.list is a list, try '[[' to access its members. ('[' returns sub-lists.) plot(plot.list[[1]], position = c(0, 0, 1, 0.5), more = TRUE) #Works plot(plot.list[[2]], position = c(0, 0.5, 1, 1), more = FALSE) #Works Hope this helps, Rui Barradas Às 10:52 de 12/06/20, Naresh Gurbuxan

Re: [R] function to return plots

2020-06-12 Thread Jim Lemon
Hi Naresh, The somewhat obscure syntax of lattice. print(plot.list[[1]]) print(plot.list[[2]]) Jim On Fri, Jun 12, 2020 at 7:53 PM Naresh Gurbuxani wrote: > > > I want to write a function that will return lattice plots. This simple > function output a list of two plots. These plots can be > i

[R] function to return plots

2020-06-12 Thread Naresh Gurbuxani
I want to write a function that will return lattice plots. This simple function output a list of two plots. These plots can be individually shown on the console. But I am unable to put them on two panels of a single plot. What changes do I need to make to this function? Thanks, Naresh libra