similar to: R grep & gsub issue - sign seems to be causing an issue...

Displaying 20 results from an estimated 20000 matches similar to: "R grep & gsub issue - sign seems to be causing an issue..."

2009 Sep 25
2
grep or other complex string matching approach to capture necessary information...
Say I have the following data: house_number<-floor(runif(100, 200, 600)) water_evaluation<-c("No water damage", "Water damage", "Water On", "Water off", "water pipes damaged", "leaking water") water_evaluation_selection<-floor(runif(100, 1,6)) house_info<-data.frame(water_evaluation[water_evaluation_selection],
2003 Aug 12
3
grep and gsub on backslash and quotes
The following code works, to gsub single quotes to double quotes: line <- gsub("'", '"', line) (that's a single quote within doubles then a double within singles if your viewer's font is not good). But The R Language Manual tells me that Quotes and other special characters within strings are specified using escape sequences: \' single quote \"
2003 May 22
4
grep, gsub, sub have problems with NA values (PR#3078)
In a string context, grep, gsub, sub are improperly treating NA (missing) as the string "NA", and returning unexpected results > grep("A", c(NA,"NA")) [1] 1 2 # expected: # [1] 2 > gsub("A", "X", c(NA,"NA")) [1] "NX" "NX" # expected # [1] NA "NX" > sub("A", "X",
2008 Aug 22
1
grep, gsub and metacharacters
Hello, I have an expression that I want to substitute for something else. myvector<-c("ajkhfkiuwe","Variable(kg/min)") if I use the following code to extract "variable(kg/min)" and substitute it for "va" gsub(myvector[grep("var", myvector, ignore=T)], "va", myvector) grep identifies the element of the vector that matches my
2003 Oct 13
4
help with gsub and grep functions
Hi all, Let Names a vector of chatacters. For example, > Names [1] "g 604 be-0 -p1 (602 matches)" "g 606 Phli-0 -p2 (517 matches)" [3] "g 608 alu-0 (659 matches)" I try to use gsub or grep functions for two problems : 1. First, I would like to delete all the characters between parentheses. [1] "g 604 be-0 -p1" "g 606 be-0 -p2" [3] "g
2001 Aug 02
1
gsub() and parenthesis symbols
Dear R-users -- I'm using R 1.3.0 on a PC running SuSE Linux 7.1. I'm confused by the following behavior from the gsub() function. Am I doing something wrong? ## A string of characters > string<-c("q","w","e","(",")","q","w","e") ## Use gsub to replace `q' with `A' >
2002 Jul 23
2
sub() and gsub() (PR#1826)
Full_Name: Jerome Asselin Version: 1.5.1 OS: linux redhat 7.2 Submission from: (NULL) (142.103.173.179) gsub() return different answers depending on how the input variables were created. Here is an example of code that replicates the problem. The vectors y and yy appear to be the same, but gsub() doesn't return the same answer. It should remove all the blanks when I use the vector y, but it
2012 Jan 24
1
gsub semicolon with double quotation mark
Hi, I would like to substitute a semicolon with two double quotation marks and a comma inbetween. It suppose to look like that: I have: FBpp0070086;FBpp0099643;FBpp0112915 I would like to have: "FBpp0070086","FBpp0099643","FBpp0112915" I tried with various numbers of backslashes, but noe have worked. for example: gsub(";", "\\\",\"",
2011 Jul 17
3
gsub() with unicode and escape character
Dear helpers, I'm trying to replace a character with a unicode code inside a data frame using gsub(), but unsuccessfully. > data.frame(animals=c("dog","wolf","cat"))->my.data > gsub("o","\u0254",my.data$animals)->my.data$animals > my.data$animals [1] "d??g" "w??lf" "cat" It's not that a data
2004 Aug 27
3
gsub, backslash and xtable
R Version 1.9.1 (2004-06-21) Mac OS X.3.5 Dual 2GHz PowerPC G5 GUI = "AQUA" I have a data.frame comprising percentiles with the column headings containing % characters, e.g. > (pp <- colnames(temp2)) [1] "5%" "10%" "25%" "50%" "75%" "90%" "95%" I use xtable to convert the data.frame to Latex but I want to
2018 Feb 17
2
readLines interaction with gsub different in R-dev
| Confirmed for R-devel (current) on Ubuntu 17.10. But ... isn't the regexp | you use wrong, ie isn't R-devel giving the correct answer? No, I don't think R-devel is correct (or at least consistent with the documentation). My interpretation of gsub("(\\w)", "\\U\\1", entry, perl = TRUE) is "Take every word character and replace it with itself, converted to
2012 Sep 30
3
How to escape a forward slash with gsub, also does interpolation work with gsub?
I am trying this: I want to replace all the text in between java comments: /* start */ replace this text here /* end */ I''m trying: text.gsub(//* start */(.*)/* end *//im, replace_with) But i''m getting errors relating to expecting keyword_end. How should I be escaping /* and */ ? Also, does string interpolation work in gsub regex? Say I had variables like: start_tag =
2011 May 05
1
Using GSUB to obtain a printing "\"
Hello. I'd like to be able to print variable strings which contain "\" as-is, without interpreting (for example) "abcde\nuvxyz" as having an embedded newline (or whatever other escaped instruction). To do this, I've tried gsub, and here's some of my output (I've tried all kinds of variations to the arguments): >
2004 Jul 17
2
gsub(*, perl=TRUE) bug incl. seg.fault (PR#7108)
Experimenting a bit further, I've "found" the following 1) the problem seems only gsub(), not sub() > sub(" ", "", "b c + d | a * b", perl=TRUE) [1] "bc + d | a * b" > gsub(" ", "", "b c + d | a * b", perl=TRUE) NULL 2) only if perl = TRUE, not otherwise 3) Also modifying the replacement string
2011 Nov 23
1
gsub, utf-8 replacements and the C-locale
Hi all, I'd like to discuss a infelicity/possible bug with gsub. Take the following function: f <- function(x) { gsub("\u{A0}", " ", gsub(" ", "\u{A0}", x)) } As you might expect, in utf-8 locales it is idempotent: Sys.setlocale("LC_ALL", "UTF-8") f("x y") # [1] "x y" But in the C locale it is not:
2012 Feb 23
1
multiple gsub
Hi Guys, I am relatively new to R and was wondering if I could next my gsub command in identifying one object I have data which looks like this: <name>Taiwan_250km</name> I want it to look like this: Taiwan_250km So essentially I just want to gsub '<name>' and </name> with nothing! So far I have got this: PolyNam <-
2013 Sep 09
2
Invalid UTF-8 with gsub(perl=TRUE) and iconv(sub="")
Hi! I experience an error with an invalid UTF-8 character passed to gsub(..., perl=TRUE); the interesting point is that with perl=FALSE (the default) no error happens. (The character itself was read from an invalid HTML file.) Illustration of the error: gsub("a", "", "\U3e3965", perl=FALSE) # [1] "\U3e3965" gsub("a", "",
2012 Mar 07
1
gsub: replacing double backslashes with single backslash
Hello everybody, this might be a trivial question, but I have been unable to find this using Google. I am trying to replace double backslashes with single backslashes using gsub. There seems to be some unexpected behaviour with regards to the replacement string "\\". The following example uses the string C:\\ which should be converted to C:\ . > gsub("\\\\",
2004 Sep 23
2
gsub
Hi A while back I used gsub to do the following temp<-"000US00231" gsub("something here", "", temp) "00231" I think it involved the `meta characters' somehow. I do not know how to do this anymore. I know strsplit will also work but I remember gsub was much faster. In essence the question is how to delete all characters before a particular
2009 Nov 16
2
on gsub (simple, but not to me!) sintax
Dear R users, my problem today deals with my ignorance on regular expressions. a matter I recently discovered. Consider the following foo <- c("V_7_101110_V", "V_7_101110_V", "V_9_101110_V", "V_9_101110_V", "V_9_s101110_V", "V_9_101110_V", "V_9_101110_V", "V_11_101110_V", "V_11_101110_V",