similar to: sub and gsub treat \\ incorrectly (PR#13454)

Displaying 20 results from an estimated 2000 matches similar to: "sub and gsub treat \\ incorrectly (PR#13454)"

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
2009 Jan 21
1
Bug in sub and gsub (PR#13460)
Full_Name: Leon C. Banza Version: 2.8.1 OS: Windows Vista Submission from: (NULL) (195.69.243.253) I believe there is a serious bug in the code for sub and gsub. I do as following: gsub("\\", "-", "some\\backslashed\\string") This ought return "some-backslashed-string", but prints warnings instead: Error in sub("\\", "",
2008 Nov 20
1
sub / gsub - extracting between identical symbols
Hi, I am trying to extract some numbers from a text string. The problem is that the delimiting symbols are identical so that I do not know how to tell "sub" between which of them to extract. The string looks like this 12/01/03/08 The extracted variables should look like: x1=12 x2=01 x3=03 x4=08 If anybody could help or point me to useful help, I would be greatful. Cheers, Daniel
2007 Sep 05
1
gsub question, not a regex question...including part of the original in the sub...
Hi all, I''ve got a simple bulletin board type of code in part of my application, and I want to implement phpbb-like tags for users to add to posts. I strip HTML out of the posts, of course. I can handle things like [b] => <b> with a simple gsub, but there''s one that is throwing me for a loop. I want users to be able to quote other users, and have the quoted text show
2004 Sep 29
2
defining a template for functions via do.call and substit ute.
Here's one not-so-straightforward way: > f <- function(a, b) a + b > flist <- as.list(f) > names(flist)[1:2] <- c("x", "y") > flist[[3]] <- do.call("substitute", list(body(f), list(a=as.name("x"), b=as.name("y")))) > g <- as.function(flist) > g function (x, y) x + y HTH, Andy > From: john.gavin at ubs.com
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
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", "",
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 Oct 07
3
vectorized sub, gsub, grep, etc.
R pattern-matching and replacement functions are vectorized: they can operate on vectors of targets. However, they can only use one pattern and replacement. Here is code to apply a different pattern and replacement for every target. My question: can it be done better? sub2 <- function(pattern, replacement, x) { len <- length(x) if (length(pattern) == 1) pattern <-
1998 Jun 26
2
R-beta: Problem with functions using sub and gsub
Previously I had problems with data(foo) and Gass and I had problems with help(). His diagnostic was "POSIX regular expressions not available" and mine was "invalid regular expression". Martin Maechler has no problems with Solaris 2.5 and suggested a regular expression library was needed, e.g., regex-x.xx. Solaris 2.4 has regex.o in /usr/ccs/libgen.a and regex.h in
2012 Dec 17
2
Formatting a path for unix with gsub
I have a path: path = "/nfs/users/nfs_n/ns9/ Phenotype Analysis/Results/Run_AmplRatio_neg BinaryAll trained without akapn+tnik.csv" I wish to replace the spaces with "\ " so that it can be read by a system call to unix. Using gsub I try: > gsub(" ","\\ ",path) [1] "/nfs/users/nfs_n/ns9/Phenotype Analysis/Results/Run_AmplRatio_neg BinaryAll
2010 Jan 29
2
evaluating expressions with sub expressions
Hallo I'm having trouble figuring out how to evaluate an expression when one of the variables in the expression is defined separately as a sub expression. Here's a simplified example mat <- expression(0, f1*s1*g1) # vector of formulae g1 <- expression(1/Tm) # expansion of the definition of g1 vals <- data.frame(f1=1, s1=.5, Tm=2) # one set of possible values for
2007 Jul 26
3
substituting dots in the names of the columns (sub, gsub, regexpr)
Dear R users, I have the following two problems, related to the function sub, grep, regexpr and similia. The header of the file(s) I have to import is like this. c("y (m)", "BD (g/cm3)", "PR (Mpa)", "Ks (m/s)", "SP g./g.", "P (m3/m3)", "theta1 (g/g)", "theta2 (g/g)", "AWC (g/g)") To get rid of spaces and
2013 Feb 15
2
Printing of anonymous functions in calls is sub-optimal
e.g. substitute(f(x), list(f = function(x) x + 1)) # function (x) # x + 1(x) An extra pair of parentheses would really help: (function(x) x + 1)(x) (Better indenting etc would be nice, but not necessary for correct understand of the code) Hadley -- Chief Scientist, RStudio http://had.co.nz/
2017 Aug 27
6
regex - optional part isn't considered in replacement with gsub
Hello, I need some help with regex. I have this to sentences. I need to extract both "49MU6300" and "LE32S5970" and put them in a new colum "SKU". A) SMART TV UHD 49'' CURVO 49MU6300 B) SMART TV HD 32'' LE32S5970 DataFrame for testing: ecommerce <- data.frame(a = c(1,2), producto = c("SMART TV UHD 49'' CURVO 49MU6300",
2007 Feb 24
3
gsub: replacing a.*a if no occurence of b in .*
I am trying to read a number of XML files using xmlTreeParse(). Unfortunately, some of them are malformed in a way that makes R crash. The problem is that closing tags are sometimes repeated like this: <tag>value1</tag><tag>value2</tag>some garbage</tag></tag><tag>value3</tag> I want to preprocess the contents of the XML file using gsub() before
2009 Apr 13
3
toupper does not work in sub + regex
Hi, I don't know what I am doing wrong to the toupper does not seem working in sub + regex. The following returns 's' not the upper class 'S' as I expect: sub("q_([a-z])[a-zA-Z]*",toupper('\\1'),"q_sviRaw") Can someone tell me where I did wrong? Thanks, Richard [[alternative HTML version deleted]]
2010 Nov 05
1
Regular Expressions
Hi, I'm trying to figure out how to use capturing parenthesis in regular expressions in R. (Doing this in Perl, Java, etc. is fairly trivial, but I can't seem to find the functionality in R.) For example, given the string: "10 Nov 13.00 (PFE1020K13)" I want to capture the first to digits and then the month abreviation. In perl, this would be /^(\d\d)\s(\w\w\w)\s/ Then
2014 Apr 19
4
[LLVMdev] [NVPTX] Eliminate common sub-expressions in a group of similar GEPs
Hi, We wrote an optimization that eliminates common sub-expressions in a group of similar GEPs for the NVPTX backend. It speeds up some of our benchmarks by up to 20%, which convinces us to try to upstream it. Here's a brief description of why we wrote this optimization, what we did, and how we did it. Loops in CUDA programs are often extensively unrolled by programmers and compilers,
2014 Sep 30
1
R's internal tar ignores files in sub-directories
E.g. I am seeing: dir <- file.path(tempdir(), "test-tar") dir.create(dir) setwd(dir) dir.create("foo", showWarnings = FALSE) file.create("foo/bar.R") tar("test.tar", files = "foo/bar.R") dir.create("untarred") untar("test.tar", exdir = "untarred")