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] 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