similar to: Finding a gsub like function in S+ 2000

Displaying 20 results from an estimated 20000 matches similar to: "Finding a gsub like function in S+ 2000"

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",
2006 Apr 24
3
gsub + backslashes
Dear developeRs, I thought that backslashes can be escaped in the usual way (and I think I did this before) but I can't see why R> gsub("\\", "x", "\alpha") Error in gsub(pattern, replacement, x, ignore.case, extended, fixed, useBytes) : invalid regular expression '\' gives an error. Or am I just blind? Best, Torsten R> version
2008 Sep 23
4
gsub difficulty
Greetings R-ians: I know what doesn?t work but I don?t know why, nor how to remedy things. I have a character string containing "." which I want to replace with " " gsub(".", " ", file.label) replaces the every character with a blank. However gsub(".xls", " ", file.label) replaces ".xls" with a blank as expected. It appears
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
2010 Jul 19
3
"ACCTGMX" to "1223400" in R?
Hi, I am a newbie in R and was working on some DNA data represented as strings of A,C,T and G (also wild-character like M and X). I use the Bioconductor package in R. Currently I need to convert a string of the form "ACCTGMX" to "1223400" i.e. A is replaced by 1, C with 2, T with 3, G with 4 and any other character with a 0. I checked with 'replace' and also with a
2004 Jul 29
3
Editing Strings in R
I was wondering if there is a way of editting strings in R. I have a set of strings and each set is a row of numbers and paranthesis. For example the first row is: (0 2)(3 4)(7 9)(5 9)(1 5) and I have a thousand or so such rows. I was wondering how I could get the corresponding string obtained by adding 1 to all the numbers in the string above. Dursun [[alternative HTML version deleted]]
2017 Oct 11
6
changing "," to "." in data.frame
Dear friends - I have a data.frame with "," instead of "." and found the discussion http://r.789695.n4.nabble.com/How-to-replace-all-commas-with-semicolon-in-a-string-tt4721187.html#a4721192 so copying the code of Ulrik(I hope:-)) I tried (making some data) AX <-
2006 Nov 09
1
invert argument in grep
Hello, What about an `invert` argument in grep, to return elements that are *not* matching a regular expression : R> grep("pink", colors(), invert = TRUE, value = TRUE) would essentially return the same as : R> colors() [ - grep("pink", colors()) ] I'm attaching the files that I modified (against today's tarball) for that purpose. Cheers, Romain --
2011 Aug 30
2
url prep function (backslash issue)
Greeting R Community, I am a windows user so this problem may be specific to windows. I often want to source files from within R such as: C:\Users\Rinker\Desktop\Research & Law\Data\School Data 09-10. To source this file I need to go through the path and replace all the backslashes (\) with forward slashes (/). I usually do this in MS Word using the replace option, however, I'd like
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' >
2009 Sep 29
1
Help with sub functions
I have chances to work with both linux based and win based R codes. And as you all know in linux, the file directories use "/" and win uses "\\". Is there a function like sub or gsub that could substitute those slashes automatically? Thanks! Edward Chen Email: tkedch@msn.com Cell Phone: 510-371-4717 [[alternative HTML version deleted]]
2005 Nov 27
4
gsub syntax
Hello I know that R's string functions are not as extensive as those of Unix but I need to do some text handling totally within an R environment because the target is a Windows system which will not have the corresponding shell utilities, sed, awk etc. Can anyone explain the following gsub phenomenon to me: >
2005 Mar 02
1
Error on Windows installing package to non-default library
Hi all, I'm seeing an error on Windows when I try to install a package to a package library path that starts with a digit. I can reproduce the error as follows using R-devel from Feb 24 on Windows advanced server: badLib = "c:\\badExample\\2\\foo" dir.create(badLib, recursive=TRUE) z = .libPaths() z = .libPaths(c(badLib, z)) z [1] "c:\\badExample\\2\\foo"
2004 Oct 28
1
gsub() on Matrix
Hi, Suppose I've got a matrix, and the first few elements look like "x1 + x3 + x4 + x5 + x1:x3 + x1:x4" "x1 + x2 + x3 + x5 + x1:x2 + x1:x5" "x1 + x3 + x4 + x5 + x1:x3 + x1:x5" and so on (have got terms from x1 ~ x14). If I want to replace all the x1 with i7, all x2 with i14, all x3 with i13, for example. Is there an easy way? I tried to put what I want
2007 Jan 27
1
gsub regexp question
Dear R Users, I am trying to users gsub to remove multiple cases of square brackets and their different contents in a character string. A sample of such a string is shown below. However, I am having great difficulty understanding regexp syntax. Any help is greatly appreciated. Ally "tree STATE_286000 [&lnP=-12708.453945423369] = [&R]
2009 Oct 13
4
replacing period with a space
Dear R-ers! I have x as a variable in a data frame x. x<-data.frame(x=c("aa.bb","cc.dd.ee")) x$x<-as.character(x$x) x I am sorry for such a simple question - but how can I replace all periods in x$x with spaces? sub('.', ' ', x$x) - removes all letters to the left of each period... Thanks a lot for your advice! -- Dimitri Liakhovitski Ninah.com
2009 Jan 19
1
sub and gsub treat \\ incorrectly (PR#13454)
Sub and gsub treat \\ replacement pattern incorrectly I expect sub("a","\\", "a", perl=T) to produce [1] "\" instead it generates [1] "" On the other hand, if I run sub("a","\\\\", "a", perl=T) it correctly outputs [1] "\\" The same issue applies to gsub. --please do not edit the information
2017 Oct 11
0
changing "," to "." in data.frame
And as follow up, fff<-function(x) gsub(",", ".", x) BX <- apply(apply(AX, 2, fff), 2, as.numeric) this seems to be easier. Cheers Petr S pozdravem | Best Regards RNDr. Petr PIKAL Vedouc? V?zkumu a v?voje | Research Manager PRECHEZA a.s. n?b?. Dr. Edvarda Bene?e 1170/24 | 750 02 P?erov | Czech Republic Tel: +420 581 252 256 | GSM: +420 724 008 364 petr.pikal at
2003 Oct 20
3
R - S compatibility table
Hello all - I've just recently been exploring R for the first time. After noticing a few things that have changed from S to R, I started looking for an R-S compatibility table but didn't find it. Is such a table out there ? Where ? Thanks much, Purvis Bedenbaugh purvis at mbi.ufl.edu Examples: 'stdev' is now 'sd' - is it exactly the same computation ? couldn't find
1997 May 29
2
R-beta: WISH: For dyn.load()ing, I'd like is.loaded(.) , symbol.C, symbol.For
In S(plus), I can write functions using code fragments like if(!is.loaded(symbol.C("my_C_fun"))) dyn.load("......../my_C_fun.o") r <- .C("my_C_fun", x = x, n = n, ... ) which I would like to have in R, too. The S-plus help page on this subject says : S+>> Code Availability S+>> S+>> DESCRIPTION: S+>> is.loaded