Displaying 20 results from an estimated 10000 matches similar to: "grep and gsub on backslash and quotes"
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
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 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
2011 Apr 29
1
regular expression in gsub() for strings with leading backslash
Hello,
Can anyone help on gsub() in R? I have a string like something below, and
wanted to delete all the strings with leading backslash, including "\xa0On",
"\023, "\xab", and many others. How should I write a regular expression
pattern in gsub()? I don't care how many characters following backslash.
txt <- "Is This Thing\xa0On? http://bit.ly/jAbKem
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
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
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
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
2011 Nov 04
3
replace double backslash with singel backslash
I want to replace \\ with \ in:
str <-
"C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg"
and tried:
gsub("\\\\", "\\", str)
but this removes the \\ without replacing them by \
Any help much appreciated,
Kay
-----
------------------------
Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck
------------------------
2009 Apr 03
2
Removing backslashes from data
I am trying to check for backslashes in data, then remove them when I
find them, but am having a difficult time figuring out the best way to
do it. I know the backslash is the escape character in R, and I
should be able to use 'gsub' to accomplish this, but I all I seem to
be getting are errors. For example:
If entry is:
"Hello\World"
I want:
"HelloWorld"
2006 Feb 01
3
inserting one backslash
Hello, I am not very familiar with regular expressions and escaping. I
need to replace the %-signs in a character vector with elements as
"income 0%-33%# to be replaced by "income 0\%-33\%" (for later use in
LaTeX). Using
gsub("%","\\%","income 0%-33%")
does not give the desired result. However, gsub("%","\\\\%","income
2004 Nov 29
4
escaping backslash in a string
How can I get a single backslash in a character string?
My goal is to escape dots in a string that will be used as a regular
expression. I thought I could do it this way:
gsub(".", "\\.", x)
Unfortunately, "\\" does not represent a literal backslash as I
expected, but rather a pair of backslashes:
> "\\."
[1] "\\."
> "\\"
[1]
2005 Jun 09
3
dir() and RegEx and gsub()
Dear R-Users,
I have two questions:
a)
in a directory there are 3 files:
[1] "Data.~csv" "Kopie von Data.~csv" "VorlageTradefile.csv"
The command "dir( fold, pattern = "\.csv" )" gives back *all* the 3 files
With dir( fold, pattern = "\\.csv" ) I get back only VorlageTradefile.csv.
I don't understand this behaviour,
2024 Apr 11
3
Regexp pattern but fixed replacement?
I noticed this issue in stringr::str_replace, but it also affects sub()
in base R.
If the pattern in a call to one of these needs to be a regular
expression, then backslashes in the replacement text are treated specially.
For example,
gsub("a|b", "\\", "abcdef")
gives "def", not "\\\\def" as I wanted. To get the latter, I need to
escape
2009 Feb 06
3
Sweave and backslashes
Hello Everyone,
I am an avid Sweave user and I am trying to pretty print floating point
numbers for latex output. For example in my document, I would like:
4.2\cdot 10^-{8}
Instead of:
4.2e-08
The Hmisc package has a nice function for doing this- but Hmisc has a ton of
dependencies and has proved very unportable to the various machines I work
on. So, I set out to write my own function that
2008 Sep 23
3
How to convert backslash to slash?
How to use sub, gsub, etc. to replace "\" in a string to "/"?
For example,convert "C:\foo\bar" to "C:/foo/bar".
Thanks,
Shengqiao Li
2003 Nov 18
4
address for bug reports? (PR#5171)
bug.report() tells me to email to r-bugs@r-project.org, whereas
the Web site http://www.r-project.org/ points me to
r-bugs@biostat.ku.dk.
Which should I believe?
Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: Simon.Fear@synequanon.com
web: http://www.synequanon.com
Number of attachments included with this message: 0
This
2003 Aug 12
8
capturing output from Win 98 shell
How can I best achieve the following (works in Splus):
filenames <- dos("dir *.sasb7dat /b")
What I am asking, more generically, is: how can I capture the output of
a
DOS command in R?
I have tried using
system("COMMAND.COM /c dir /b", intern=T, show.output.on.console=T)
where
intern: a logical, indicates whether to make the output of the
command an R
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
2003 Nov 18
3
plot, plot, methods, crash (PR#5173)
(If this only happens in Win 98, I'm sure I could live with it. Just
may be helpful to report it, I hope.)
Start up R GUI, then
> plot(1:4,1:4) # then close manually by clicking X
> plot(1:4,1:4) # ditto
> methods(plot)
sometimes produces normal output and even the following prompt,
but then crashes immediately, or more often, crashes immediately with
no output.
I can do any