similar to: Subset using grepl

Displaying 20 results from an estimated 10000 matches similar to: "Subset using grepl"

2016 Apr 30
3
how to use AND in grepl
Hi all, I have one factor variable in my df and I want to extract the names from it which contain both "t2" and "pd": 'data.frame': 36919 obs. of 162 variables $TE :int 38,41,11,52,48,75,..... $TR :int 100,210,548,546,..... $Command :factor W/2229 levels
2016 Apr 22
0
subset by multiple letters condition
You can use the grepl() function to give you logicals for each criterion, then combine them as needed. For example: # example version of Command Command <- paste0("_localize_", c("PD","t2","t1_seq", "abc", "xyz", "PD_t1")) hasPD <- grepl("PD", Command, fixed=TRUE) hast1 <- grepl("t1", Command,
2016 Apr 23
1
subset by multiple letters condition
Thanks Jean, Does anyone know how to set these [hast1] and [hast2] as the colors of a plot? On Friday, April 22, 2016 7:39 AM, "Adams, Jean" <jvadams at usgs.gov> wrote: You can use the grepl() function to give you logicals for each criterion, then combine them as needed. For example: # example version of Command Command <- paste0("_localize_",
2010 May 23
2
Subsetting with a list of vectors
Hi, I have a dataset that looks like the one below. data plot plantno. species H 31 ABC D 2 DEF Y 54 GFE E 12 ERF Y 98 FVD H 4 JKU J 7 JFG A 55 EGD . . . . . . .
2016 Apr 24
1
assign color to subsets
'grepl' returns a logical vector; you have to use this to get your subset. You can use: df_tq <- subset(df, grepl("t1", Command)) df_t2 <- subset(df, grepl("t2", Command)) # if you want to also get a subset that has both, use df_both <- subset(df, grepl("t1", Command) & grepl("t2", Command)) Jim Holtman Data Munger Guru What is
2016 Apr 24
0
assign color to subsets
now after this: df_both <- subset(df, grepl("t1", Command) & grepl("t2", Command)) I use factor to apply the subset to df but then the Command level becomes 0 df_both$Command=factor(df_both$Command) str(df_both) $ Protocol : Factor w/ 0 levels: Do you know what is the reason? Thanks for replying On Sunday, April 24, 2016 12:18 PM, jim
2010 May 28
1
Match 2 vectors
Hi, I have 2 dataframes of unequal length, and I would like to match a factor to them so that both dataframes will have the same number of rows. example: # create the 2 dataframes with unequal length data1 <- data.frame(letters, 1:26)[-c(5,10,19:21),] data2 <- data.frame(letters, 1:26)[-c(6,9,15:18),] data2a <- match(data1[,1], data2[,1]) data2b <- data2[data2a,] When I match
2016 Apr 23
4
assign color to subsets
Hi I have the following df and I created two subsets but I don't know how to use these subsets as the colors of my plot. data.frame': 36919 obs. of 162 variables $TE :int 38,41,11,52,48,75,..... $TR :int 100,210,548,546,..... $Command :factor W/2229 levels
2016 Apr 22
2
subset by multiple letters condition
Hi all, I have a data frame df and I want to do subset based on several conditions of letters of the names in Command.1)if the names contain PD 2)if the names contain t1 3)if the names contain t2 4)if the names contain t1 and PD 5)if the names contain t2 and PD 6)otherwise the names would be unknown. I don't know how to use grep for all these conditions. 'data.frame': 36919
2023 May 30
3
why does [A-Z] include 'T' in an Estonian locale?
Inspired by this old Stack Overflow question https://stackoverflow.com/questions/19765610/when-does-locale-affect-rs-regular-expressions I was wondering why this is TRUE: Sys.setlocale("LC_ALL", "et_EE") grepl("[A-Z]", "T") TRE's documentation at <https://laurikari.net/tre/documentation/regex-syntax/> says that a range "is shorthand for
2019 Aug 09
3
Underscores in package names
I do not follow you Gabriel. Package name must not use digit numbers. Tarbal will use them, taken from the DESCRIPTION file, version field. That's why I consider the weird case name you presented as irrelevant, and not to be considered. Le ven. 9 ao?t 2019 ? 20:41, Gabriel Becker <gabembecker at gmail.com> a ?crit : > > > On Fri, Aug 9, 2019 at 11:05 AM neonira Arinoem
2023 Feb 12
2
Removing variables from data frame with a wile card
x["V2"] is more efficient than using drop=FALSE, and perfectly normal syntax (data frames are lists of columns). I would ignore the naysayers, or put a comment in if you want to accelerate their uptake. As I understand it, one of the main reasons tibbles exist is because of drop=TRUE. List-slice (single-dimension) indexing works equally well with both standard and tibble types of data
2011 Sep 30
2
Overlapping plot in lattice
Hi all, I was wondering if there's an equivalent to par(new=T) of the plot function in lattice. I'm plotting an xyplot, and I would like to highlight one point by plotting that one point again using a different symbol. For example, where 6 is highlighted: plot(1:10, xlim=c(0,10), ylim=c(0,10)) par(new=T) plot(6,6, xlim=c(0,10), ylim=c(0,10), pch=16) Is there a way to do this in lattice?
2011 Dec 04
2
Extract last 3 characters from numeric vector
Hi all, I have a numeric vector with 1 decimal place, and I'd like to extract the last 3 characters, including the decimal point. The vector ranges from 0 to 20. x <- round(runif(100)*20, digits=1) Some of numbers have 3 characters, and some have 4. I've read up on the substr() function but that extracts characters based on exact positions. How can I extract just the last 3
2023 Jun 01
1
why does [A-Z] include 'T' in an Estonian locale?
On 5/30/23 17:45, Ben Bolker wrote: > Inspired by this old Stack Overflow question > > https://stackoverflow.com/questions/19765610/when-does-locale-affect-rs-regular-expressions > > > I was wondering why this is TRUE: > > Sys.setlocale("LC_ALL", "et_EE") > grepl("[A-Z]", "T") > > TRE's documentation at >
2009 Oct 25
1
rotate levelplot
Hi all, I have a matrix with 5 rows and 10 columns, which represent the grids on a rectangular map. I used the code below to plot, but it gives me the map with the 10 columns as y-axis, and the 5 rows as the x-axis, and the (0,0) point is at the usual bottom left hand corner. My map starts with the (0,0) at the top left hand corner. How can I rotate the map 90 degrees clockwise so the (0,0)
2010 Oct 08
2
Memory management in R
Dear All, I am experiencing some problems with a script of mine. It crashes with this message Error in grepl(fut_string, past_string) : invalid regular expression
2016 Apr 10
0
what is the faster way to search for a pattern in a few million entries data frame ?
On 04/10/2016 03:27 PM, Fabien Tarrade wrote: > Hi Duncan, >> Didn't you post the same question yesterday? Perhaps nobody answered >> because your question is unanswerable. > sorry, I got a email that my message was waiting for approval and when I > look at the forum I didn't see my message and this is why I sent it > again and this time I did check that the
2010 May 15
1
Barchart reorder
Hi fellow R users, I have a dataset that looks something like this. species class abundance K 1 592 K 2 288 G 1 254 G 2 239 C 2 173 D 2 123 E 3 89 F 2 87 B 2 86 H 2 82 I 1 79 J 2 76 B 1 73 D 3 72 A 2 62 L 2 58 I want to plot a stacked barchart. species is the x-axis, abundance is y-axis, and class will appear as the stacks in different colours. I need the species to be displayed in descending
2011 Dec 05
1
Subsetting a data frame
Hi R users, I really need help with subsetting data frames: I have a large database of medical records and I want to be able to match patterns from a list of search terms . I've used this simplified data frame in a previous example: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, 2, 1.3, 3), test2 = c(56L, 27L, 58L,