Displaying 20 results from an estimated 20000 matches similar to: "gsub wildcard"
2011 Aug 19
1
gsub for numeric characters in string
Dear all,
I have what is a bit of a confusing question, so I hope that I can explain
clearly. Thank you for your help in advance.
I would like to do a replacement procedure on several strings, but the way
that I am currently going about it is not working.
I have defined "len", which is a series comprising the lengths of different
items, all preceded by a colon.
> len
[1]
2013 Jan 16
2
How to cut the time format short
Hello all,
I have a time format looks like
31JAN2002:00:00:00.000
How could I cut it to
31JAN2002
?
I tried with format() but not work.
Thanks,
Rebecca
----------------------------------------------------------------------
This message, and any attachments, is for the intended r...{{dropped:5}}
2007 Oct 01
4
Disentagling formulas
I am writing a program in which I would like to take in a formula, change the response (Y) variable into something else, and then pass the formula, with the new Y variable to another function. That is, I am starting with
formula <- Y~X1+X2+X3
and I'd like to do something like
Y <- formula$Y
newY <- f(Y)
lm(newY~X1+X2+X3)
So far, it seems that my
2011 Jul 27
2
plotting the ending point in a for loop
Hello,
I would appreciate if someone could help me with this query. I would like to
plot a line chart of all of the points in a "for" loop. I would also like
to plot the final point with a symbol (to show where the random walk ends).
Here is the code I am using:
Brownian.fn <- function(mu, sigma, T, N){
dt <- T/N
t <- c(rep(NA, N))
B1 <- c(rep(NA, N))
B2 <- c(rep(NA,
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
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
2013 Jan 22
6
plot two time series with different length and different starting point in one figure.
Hello,
I do have two different time series A and B, they are different in length and starting point. A starts in Jan, 2012 and ends in Dec, 2012 and B starts in March, 2012 and ends in Nov, 2012.
How can I plot those two series A and B in the same plot? I.E., from Jan. 2012 - Feb, 2012, it would have one data point from A and from Mar, 2012-Nov, 2012, it would have two data points from A and B,
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