similar to: exact string match?

Displaying 20 results from an estimated 7000 matches similar to: "exact string match?"

2009 Nov 03
2
Exact String Compare in R?
Dear R users: Here's a barebones example of what I can't make work. As you can see, regexpr() does not perform an exact string match, which only occurs in row 1 of these data frames. Instead, as it's supposed to do, it finds "b" in "bb" and "c" in "cc". Does anybody know what function I can use such that only the first rows would be matched (ie,
2010 Jun 01
1
regexpr help (match.length=0)
R-help, Sorry if this is more of a regex question than an R question. However, help would be appreciated on my use of the regexpr function. In the first example below, I ask for all characters (a-z) in 'abc123'; regexpr returns a 3-character match beginning at the first character. > regexpr("[[:alpha:]]*", "abc123") [1] 1 attr(,"match.length") [1] 3
2018 Apr 24
0
How to visualise what code is processed within a for loop
The loop never assigns anything to d0, only t. The first line makes t a character string "d0$V1" (or "d0$V2" etc.). The second line assigns either 0 or 1 to t. Looking at this, I don't think you've got into the R psychology (bad news if you want to use R, good news in many other ways). I assume d0 is a list, so could you put the V's into a vector, and then just use
2009 Sep 01
1
Syntax for crossed random effects in nlme
Hello R users, I've read the posts on this topic, and had a look at the R documentation for nlme, but I can't seem to make this work. I'd like to be able to fit a mixed effects model with crossed random effects, but also be able to specify the covariance matrix structure for the residuals. Here's the syntax using the lmer function in lme4 (which doesn't currently allow
2010 May 05
1
extracting a matched string using regexpr
Given a text like I want to be able to extract a matched regular expression from a piece of text. this apparently works, but is pretty ugly # some html test<-"</tr><tr><th>88958</th><th>Abcdsef</th><th>67.8S</th><th>68.9\nW</th><th>26m</th>" # a pattern to extract 5 digits > pattern<-"[0-9]{5}" #
2018 Apr 24
4
How to visualise what code is processed within a for loop
Hi, I am trying to debug the following code: for (i in 1:10){ t <- paste("d0$V",i,sep="") t <- ifelse(regexpr(d1[i,1],d0$X0)>0,1,0) } and I would like to see what code is actually processing R, how can I do that? More to the point, I am trying to update my variables d0$V1 to d0$V10 according to the presence or absence of some text (contained in the file d1)
2017 Apr 04
2
Bug report: POSIX regular expression doesn't match for somewhat higher values of upper bound
Dear Sirs, while > regexpr('(.{1,2})\\1', 'foo') [1] 2 attr(,"match.length") [1] 2 attr(,"useBytes") [1] TRUE yields the correct match, an incremented upper bound in > regexpr('(.{1,3})\\1', 'foo') [1] -1 attr(,"match.length") [1] -1 attr(,"useBytes") [1] TRUE incorrectly yields no match. R versions tested: 2.11.1
2011 Sep 29
2
String manipulation with regexpr, got to be a better way
Help-Rs,   I'm doing some string manipulation in a file where I converted a string date in mm/dd/yyyy format and returned the date yyyy.   I've used regexpr (hat tip to Gabor G for a very nice earlier post on this function) in steps (I've un-nested the code and provided it and an example of what I did below.  My question is: is there a more efficient way to do this.  Specifically is
2004 Mar 24
1
string problems ( grep and regepxr)
Recently working with strings and data I have found a small problem. Windows XP R 1.8.1 Reading data from a "txt file" with readLine. finding a specific line with "grep" command, all OK. but here comes the problem... After finding the correct line(s) i need to find a substring inside each string. In this case "tabs" I think it represented by "\t" in the
2008 Apr 15
1
why does regexpr not work with '.'
Dear R Helpers, I am running R 2.6.2 on a Windows XP machine. I am trying to use regexpr to locate full stops in strings, but, without success. Here an example:- f="a,b.c at d:" #define an arbitrary test string regexpr(',',f) #find the occurrences of ',' in f - should be one at location 2 # and this is what regexpr finds #[1] 2
2007 Aug 02
4
Finding multiple characters in the same string
Hi I have this problem where I need to find if there is any numbers in a string, this is no problem if theres only one number per string. I would then simply use the regexpr() funtion togheter with the substring function to extract the number. But regexpr only picks one number per string either from the beginning or the end, but not multiple. Can this be done? And how for example My string <-
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
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
2010 Apr 23
2
Problem with parsing a dataset - help earnestly sought
Dear fellow R-help members, I hope to seek your advice on how to parse/manage a dataset with hundreds of columns. Two examples of these columns, 'cancer.problems', and 'neuro.problems' are depicted below. Essentially, I need to parse this into a useful dataset, and unfortunately, I am not familiar with perl or any such language. data <- data.frame(id=c(1:10))
2012 Aug 21
7
Regular Expressions in grep
Dear r-help members, I have a number in the form of a string, say: a<-"-01020.909200" I'd like to extract "1020." as well as ".9092" Front<-grep(pattern="[1-9]+[0-9]*\\.", value=TRUE, x=a, fixed=FALSE) End<-grep(pattern="\\.[0-9]*[1-9]+", value=TRUE, x=a, fixed=FALSE) However, both strings give "-01020.909200", exactly
2013 Mar 20
2
Pattern match
Hello again, in the help page of grep() function, it is written that pattern: character string containing a regular expression (or character string for fixed = TRUE) to be matched in the given character vector. Coerced by as.character to a character string if possible. If a character vector of length 2 or more is supplied, the first element is used with a warning. Missing values are allowed
2007 Nov 02
1
R timeDate does not allow seconds?
Hello, Sorry if anyone gets this message twice, as my mailserver may not be working. Thanks for your response. Your idea makes a lot of sense to me, but I've been unable to get seconds to work. I ended up with this format finally: "2007-10-31_16:20:22" Problem is I am unable to get it recognized as a date using timeDate(): R>
2013 Jan 07
3
pattern matching
Hi, I have a simple question. Suppose I have a string "x$Expensive". I want to find the position of the $ in this string; i.e., I want a function that returns 2. I tried grep, regexpr, etc with no luck, unless I'm just using them incorrectly. Any suggestions? Thanks, Walt ________________________ Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro,
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
2012 Jan 24
2
Writing a function to return column position XXXX
Hello everyone, I am writing my own function to return the column index of all variables (these are currently character vectors) in a data frame that contain a dollar sign($). A small piece of the data look like this: can_sta can_zip ind_ite_con ind_uni_con AL 36106 $251,895.80 $22,874.43 AL 35802 $141,373.60 $7,100.00 AL 35201 $273,208.50 $18,193.66 AR 72404 $186,918.00 $25,391.00 AR