Displaying 20 results from an estimated 10000 matches similar to: "help with gsub and date pattern"
2009 Jul 10
3
strange strsplit gsub problem 0 is this a bug or a string length limitation?
I was working with the rmetrics portfolioBacktesting function and dug into
the code to try to find why my formula with 113 items, i.e. A1 thru A113,
was being truncated and I only get 85 items, not 113.
Is it due to a string length limitation in R or is it a bug in the strsplit
or gsub functions, or in my string?
I'd very much appreciate any suggestions
============Input script:
2009 May 26
2
Problem with fractional seconds
Dear List,
I am having problems converting a file with fractional seconds to class POSIXct. I have set my options to include digits.secs and my format to just time, but my output is the current date with my time lacking the fractions of a second. For example:
options(digits.secs=3)
t<-c("06:00:00.100","06:00:01.231")
myt<-as.POSIXct(t,format="%H:%M:%S")
2009 May 22
5
Need a faster function to replace missing data
Dear List,
I need some help in coming up with a function that will take two data sets, determine if a value is missing in one, find a value in the second that was taken at about the same time, and substitute the second value in for where the first should have been. My problem is from a fish tracking study. We put acoustic tags in fish and track them for several days. Location data is supposed
2009 May 26
4
Creating multiple graphs based on one variable
Dear List,
I would like to create several graphs of similar data. I have x and y values for several different individuals (in this case fish). I would like to plot the x and y values for each fish separately. I can do it using a for loop, but I think I should be using "apply". Please let me know what I am doing wrong, or if there is a "better" way to do this. What I have
2011 Apr 20
1
Pattern match
Hi ALL,
I have very simple question regarding pattern matching. Could anyone tell me
how to I can use R to retrieve string pattern from text file. for example
my file contain following information
SpeciesCommon=(Human);SpeciesScientific=(Homo
sapiens);ReactiveCentres=(N,C,C,C,+
H,O,C,C,C,C,O,H);BondInvolved=(C-H);EzCatDBID=(S00343);BondFormed=(O-H,O-H);Bond+
2008 Jun 12
2
numbers as part of long character
Hi,
I'm looking for some way to pick up the numbers which are contained and buried in a long character.
For example,
outtree.new="(((B:1204.25,E:1204.25):7581.11,F:8785.36):8353.85,C:17139.21);"
num.char =
2012 May 30
1
gsub/strsplit with multiple patterns/splits
Hi,
I have a vector like this:
DF <- c("Aetna, Inc.", "Alexander's Inc.", "Allegheny Energy, Inc")
For each element in the vector I would like to remove the "incorporated"
info, so that my vector looks like this:
DF <- c("Aetna", "Alexander's", "Allegheny Energy")
That means that I have to strip:
strip <-
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
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",
2011 Aug 12
3
gsub("\\", "\\\\", "C:\Program Files\R")
Hi,
I think it is not possible in R but I rather ask before giving up:
What I have: I have copied "C:\Program Files\R" into my clipboard.
What I want: setwd(transform("C:\Program Files\R")) where the function
transform should change the "C:\Program Files\R" from my clipboard to
"C:\\Program Files\\R" so that R can handle it. Is this possible?
I've
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 <-
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",
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
2010 May 03
2
Estimating theta for negative binomial model
Dear List,
I am trying to do model averaging for a negative binomial model using the package AICcmodavg. I need to use glm() since the package does not accept glm.nb() models. I can get glm() to work if I first run glm.nb and take theta from that model, but is there a simpler way to estimate theta for the glm model? The two models are:
mod.nb<-glm.nb(mantas~site,data=mydata)
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'
>
2010 Sep 10
1
faster unlist,strsplit,gsub,for
Hi,
I perform the operations unlist,strsplit,gsub and the for loop on a lot of
strings and its heavily slowing down the overall system. Is there some way
for me to speeden up these operations..maybe like alternate versions that
exist which use multiprocessors etc.
--
Rajesh.J
[[alternative HTML version deleted]]
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,
2008 Oct 15
4
strsplit and regex
Hi All,
Is there a means to extract the "10" from "23:10:34" in one pass using
strsplit (or something else)?
tst <- "23:10:34"
For example my attempt
strsplit(as.character(tst),"^[0-9]*:")
gives
[[1]]
[1] "" "" "34"
Obviously it is matching the first two instances of [0-9]. Note that
there may be only one digit
2005 Jan 21
2
gsub pattern?
Hi,
search in web for regular expressions i get the information that
the line below replace all AUTO string's like AUTOBAHN
,AUTORENNEN with 1 but nothing happend.
Using the [] in the pattern it works like i'm expected, but i didn't
want single character replacment. Where is my mistake?
bcode <- gsub("/^AUTO.*/","1",MyStringVector,ignore.case=T,extended=T)
2007 Mar 19
3
character to numeric conversion
Hi.
Is there a straightforward way to convert a character string
containing comma-delimited
numbers to a numeric vector?
In my application, I use
system(executable.string, intern=TRUE)
which returns a string like
"[0.E-38, 2.096751179214927596171268230,
3.678944959657480671183123052, 4.976528845643001020345216157,
6.072390165503099343887569007, 7.007958550337542210168866070,