Re: [R] matching doesn't work

2020-04-10 Thread Ana Marija
I am not sure what I am suppose to run from your codes. Can you just send me lines of codes which I should run? (without part where you are loading your data frames) (assuming my files are as I showed them) Or the whole idea was to remove sep=" " from everywhere? On Fri, Apr 10, 2020 at 7:01 PM R

Re: [R] matching doesn't work

2020-04-10 Thread Rasmus Liland
On 2020-04-10 18:46 -0500, Ana Marija wrote: > so if I understand correctly you would just remove sep=" " from my codes? > > Thank you so much for working on this. > Is there is any chance you can change my original code (pasted bellow) > with changes you think should work? > > library(SNPRelate)

Re: [R] matching doesn't work

2020-04-10 Thread Ana Marija
so if I understand correctly you would just remove sep=" " from my codes? Thank you so much for working on this. Is there is any chance you can change my original code (pasted bellow) with changes you think should work? library(SNPRelate) # get PLINK output plink.genome <- read.table("plink.geno

Re: [R] matching doesn't work

2020-04-10 Thread Rasmus Liland
On 2020-04-10 17:05 -0500, Ana Marija wrote: > it didn't work unfortunately with your > example: > > > plink.genome[idx,] > character(0) Hi! Perhaps csv formatting are better suited for these emails ... the two ibdlist lines I added still matches in this example, added lookup for kinship ..

Re: [R] matching doesn't work

2020-04-10 Thread Ana Marija
it didn't work unfortunately with your example: > plink.genome[idx,] character(0) here is my whole: plink.genome <- read.table("plink.genome", header=TRUE) FID1 IID1 FID2 IID2 RTEZ Z0 Z1 Z2 PI_HAT PHE DST PPC RATIOIBS0IBS1IBS2 HOMHOM HETHET

Re: [R] matching doesn't work

2020-04-10 Thread Rasmus Liland
On 2020-04-10 15:38 -0500, Ana Marija wrote: | Hi, | | I have this code: Dear Ana, none of the ID tuples in the head outputs you provided matches, so I added two lines in ibdlist that matches up; perhaps if you provided more lines that would have matched in a pastebin somewhere ... optio

Re: [R] question about system.file()

2020-04-10 Thread Rasmus Liland
On Fri, Apr 10, 2020 at 2:54 PM Duncan Murdoch wrote: > On 10/04/2020 3:46 p.m., Ana Marija wrote: > > I have in current directory from > > where I would run this function a > > file named output4.bed > > Just use "output4.bed" as the > filename. The system.file() function > is for working out

[R] matching doesn't work

2020-04-10 Thread Ana Marija
Hi, I have this code: library(SNPRelate) # get PLINK output plink.genome <- read.table("plink.genome", header=TRUE) > head(plink.genome) FID1 IID1FID2 IID2 RT EZ Z0 Z1 Z2 PI_HAT PHE DST 1 fam1054 G1054 fam1054 G700 OT 0 0.0045 0.9938 0.0017 0.4986 -1 0.839150 2 fa

Re: [R] question about system.file()

2020-04-10 Thread Ana Marija
Got it, thanks! On Fri, Apr 10, 2020 at 2:54 PM Duncan Murdoch wrote: > > On 10/04/2020 3:46 p.m., Ana Marija wrote: > > Hello, > > > > I would like to try this example in this link: > > https://www.rdocumentation.org/packages/SNPRelate/versions/1.6.4/topics/snpgdsBED2GDS > > > > for example this

Re: [R] question about system.file()

2020-04-10 Thread Duncan Murdoch
On 10/04/2020 3:46 p.m., Ana Marija wrote: Hello, I would like to try this example in this link: https://www.rdocumentation.org/packages/SNPRelate/versions/1.6.4/topics/snpgdsBED2GDS for example this line: bed.fn <- system.file("extdata", "plinkhapmap.bed.gz", package="SNPRelate") I have in c

Re: [R] question about system.file()

2020-04-10 Thread Ana Marija
I tried to do this but I got this error: > bed.fn <- system.file("output4.bed", package="SNPRelate") > dim(bed.fn) NULL > fam.fn <- system.file("output4.fam", package="SNPRelate") > bim.fn <- system.file("output4.bim", package="SNPRelate") > snpgdsBED2GDS(bed.fn, fam.fn, bim.fn, "HapMap.gds") Star

[R] question about system.file()

2020-04-10 Thread Ana Marija
Hello, I would like to try this example in this link: https://www.rdocumentation.org/packages/SNPRelate/versions/1.6.4/topics/snpgdsBED2GDS for example this line: bed.fn <- system.file("extdata", "plinkhapmap.bed.gz", package="SNPRelate") I have in current directory from where I would run this

Re: [R] how to get all strings in a data frame that start with a particular string

2020-04-10 Thread Ana Marija
Thank you so much! On Fri, Apr 10, 2020 at 12:00 PM Rasmus Liland wrote: > > On 2020-04-10 11:15 -0500, Ana Marija wrote: > > I have a data frame (tot) with about > > 2000 columns. How can I extract from > > it all strings that start with E14? > > > > I tried this: > > e14 <- sapply(tot, function

Re: [R] create a r list from dataframe using the first column as list names

2020-04-10 Thread Bert Gunter
"I thought: why make this overly complicated,..." Indeed, though "complicated" is in the eyes of the beholder. One wonders whether any of this is necessary, though: see ?apply , as in apply(a, 1, whatever...) to do things rowwise. Cheers, Bert Bert Gunter "The trouble with having an open mind i

Re: [R] how to get all strings in a data frame that start with a particular string

2020-04-10 Thread Rasmus Liland
On 2020-04-10 11:15 -0500, Ana Marija wrote: > I have a data frame (tot) with about > 2000 columns. How can I extract from > it all strings that start with E14? > > I tried this: > e14 <- sapply(tot, function(x) grepl("^E14", x)) > > but this returns me just TRUE and > FALSE vector, how do I g

Re: [R] how to get all strings in a data frame that start with a particular string

2020-04-10 Thread Michael Dewey
Dear Ana Would it not be possible to use grep instead of grepl and get the values using the value = TRUE parameter? Michael On 10/04/2020 17:15, Ana Marija wrote: Hello, Hello, I have a data frame (tot) with about 2000 columns. How can I extract from it all strings that start with E14? I

[R] how to get all strings in a data frame that start with a particular string

2020-04-10 Thread Ana Marija
Hello, Hello, I have a data frame (tot) with about 2000 columns. How can I extract from it all strings that start with E14? I tried this: e14 <- sapply(tot, function(x) grepl("^E14", x)) but this returns me just TRUE and FALSE vector, how do I get actual strings that start with E14? Thanks Ana

Re: [R] create a r list from dataframe using the first column as list names

2020-04-10 Thread Rasmus Liland
On 2020-04-09 18:00 +, aiguo li wrote: | That is awesome! Thanks. Dear AiGuo, I thought: why make this overly complicated, when this is also possible: a <- matrix(LETTERS[1:16], nrow=4) X <- split(x=a[,-1], f=a[,1]) lapply(X=X, FUN=as.factor) Best, Rasmus _