>
> > Thank you. Further, very nice solution.
> >
> > Best,
> >
> > Iago
> >
> > On 01/03/2024 12:49, Iris Simmons wrote:
> > > Hi Iago,
> > >
> > >
> > > This is not a bug. It is expected. Patterns may not overlap. H
at 3:59 AM Iago Giné Vázquez wrote:
>
> Hi Iris,
>
> Thank you. Further, very nice solution.
>
> Best,
>
> Iago
>
> On 01/03/2024 12:49, Iris Simmons wrote:
> > Hi Iago,
> >
> >
> > This is not a bug. It is expected. Patterns may not overlap. H
Hi Iris,
Thank you. Further, very nice solution.
Best,
Iago
On 01/03/2024 12:49, Iris Simmons wrote:
> Hi Iago,
>
>
> This is not a bug. It is expected. Patterns may not overlap. However, there
> is a way to get the result you want using perl:
>
> ```R
> gsub("
Hi Iago,
This is not a bug. It is expected. Patterns may not overlap. However, there
is a way to get the result you want using perl:
```R
gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
```
The specific change I made is called a positiv
Hi all,
I tested next command:
gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")
with the following output:
[1] "a_eri_ou_e"
So, there are two consecutive vowels where an underscore is not added.
May it be a bug? Is it expected (bug or not)? Is there any chance to get
what I want (a
;
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Oct 7, 2016 at 12:58 PM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:
> Hello again,
>
> I have few many string elements, and some of those elements contain a
> special phrase as '"[NA]NA%", whi
Hello again,
I have few many string elements, and some of those elements contain a
special phrase as '"[NA]NA%", which I planned to replace by some
Blank. So I tried with below code in R
> gsub("[NA]NA%", "", "[NA]NA%abcde")
[1] "[NA]NA%abcde
Thanks Jim!
Joe
On Wed, Sep 14, 2016 at 11:06 AM, jim holtman wrote:
> try this:
>
> > gsub("", "/", test)
> [1] "8/24/2016" "8/24/2016" "6/16/2016" "6/16/2016"
>
>
>
>
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not
try this:
> gsub("", "/", test)
[1] "8/24/2016" "8/24/2016" "6/16/2016" "6/16/2016"
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Wed, Sep 14, 2016 at 12:25 PM, Joe Ceradini
wrote:
> Hi all,
>
>
ent of Anthropology
> Texas A&M University
> College Station, TX 77840-4352
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Joe
> Ceradini
> Sent: Wednesday, September 14, 2016 11:25 AM
> To: Zilefac
> Subject: [R
016"
"2","8/24/2016"
"3","6/16/2016"
"4","6/16/2016"
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-
From: R-help [
Hello,
I failing to understand the problem, isn't the following what you want?
(test2 <- gsub("\\", "/", test, fixed = TRUE))
[1] "8/24/2016" "8/24/2016" "6/16/2016" "6/16/2016"
Hope this helps,
Rui Barradas
Citando Joe Ceradini :
Hi all,
There are many R help posts out there dealing with
Hi all,
There are many R help posts out there dealing with slashes in gsub. I
understand slashes are "escape characters" and thus need to be treated
differently, and display differently in R. However, I'm still stuck on
find-replace problem, and would appreciate any tips. Thanks!
GOAL: replace al
On Thu, Feb 12, 2015 at 7:12 PM, arnaud gaboury
wrote:
> On Thu, Feb 12, 2015 at 3:40 PM, arnaud gaboury
> wrote:
>> I have two df (and dt):
>>
>> df1
>> structure(list(name = c("poisonivy", "poisonivy", "poisonivy",
>> "poisonivy", "poisonivy", "poisonivy", "poisonivy", "poisonivy",
>> "cruzecon
On Thu, Feb 12, 2015 at 3:40 PM, arnaud gaboury
wrote:
> I have two df (and dt):
>
> df1
> structure(list(name = c("poisonivy", "poisonivy", "poisonivy",
> "poisonivy", "poisonivy", "poisonivy", "poisonivy", "poisonivy",
> "cruzecontrol", "agreenmamba", "agreenmamba", "vairis", "vairis",
> "vairis
I have two df (and dt):
df1
structure(list(name = c("poisonivy", "poisonivy", "poisonivy",
"poisonivy", "poisonivy", "poisonivy", "poisonivy", "poisonivy",
"cruzecontrol", "agreenmamba", "agreenmamba", "vairis", "vairis",
"vairis", "vairis", "vairis", "vairis", "xaeth"), text = c("ok",
"need items
I believe the backslash is not considered an escape character by the extended
RE library used by R (perl=FALSE), so it is being treated as a literal. This
means that the last ] is outside the character class and is the atom that the *
applies to.
gsub("^([[:alnum:]\\[\\]]*).*", "\\1", "a]]]rra
I just found a curious behaviour of regexp and I'd like to share with y'all.
gsub("^([[:alnum:]\\[\\]]*).*", "\\1", "array[n] <- 10", perl=T) #
works as expected ("array[n]")
gsub("^([[:alnum:]\\[\\]]*).*", "\\1", "array[n] <- 10", perl=F) #
doesn't work ("a")
I didn't find anything in the docum
Hi,
If I understand you well, the problem is that DataGoogle2 is a 1-column
data.frame and this is expected based on your code!
I think you want something like this to change the 1st column of the
data.frame:
DataGoogle2 <- DataGoogle1
DataGoogle2$Campaña <- gsub("facebook-Ads1", "FBAds", Da
Hi all,
please, i'm trying to understand how using "Gsub" for some search and
replace of text, makes my data frame lost it's format.
This is my code:
DataGoogle1 <- read.csv(file = "DataGoogle2.csv", header = T,
stringsAsFactors = F)
head(DataGoogle1)
Result 1:
CampañaV
Hello,
Try reading your data with option stringsAsFactors = FALSE. It seems
that your strings are being read as factors, which are coded as integers.
DataGoogle1 <- read.csv(file = "DataGoogle2.csv", header = T,
stringsAsFactors = FALSE)
Hope this helps,
Rui Barradas
Em 18-08-2014 10:13,
gsub will work on a column of a data.frame, not an entire data.frame.
> gsub(pattern = "facebook-Ads1", "FBAds", DataGoogle1$Campaña)
[1] "FBAds" "faceBOOK-Ads1" "fcebook-ads12" "Email1"
"mail1"
[6] "referral1"
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Aug 18, 2014 at 2:13 AM,
Hi all, i have this data.frame with 3 columns: "campaña", "visitas",
"compras".
This is the actual data.frame:
Campaña Visitas Compras
1 facebook-Ads1 524 2
2 faceBOOK-Ads1 487 24
3 fcebook-ads12258 4
4
Hi,
Try:
string1<- "Red, Romeo, Calf"
string2<- "Red, Rome, Ralf"
string3<- "China, Japan, USA"
gsub("R[[:alpha:]]{1,}","MM",string3)
#[1] "China, Japan, USA"
gsub("R[[:alpha:]]{1,}","MM",string2)
#[1] "MM, MM, MM"
gsub("R[[:alpha:]]{1,}","MM",string1)
#[1] "MM, MM, Calf"
Other way would be:
On Wed, May 8, 2013 at 5:08 AM, Thaler,Thorn,LAUSANNE,Applied
Mathematics wrote:
> Dear all,
>
> I want to use gsub to change a vector of strings. Basically, I want to
> replace any dot by a space, remove the possibly appended ".f" and I want to
> capitalize each word. I did that by chaining mul
Dear all,
I want to use gsub to change a vector of strings. Basically, I want to replace
any dot by a space, remove the possibly appended ".f" and I want to capitalize
each word. I did that by chaining multiple gsubs together, but I was wondering
(for the sake of learning - maybe the current ve
Hi
One more comment
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of David Winsemius
> Sent: Thursday, August 23, 2012 2:22 AM
> To: Paula Cafeld
> Cc: r-help@r-project.org
> Subject: Re: [R] gsub -&
On Aug 22, 2012, at 10:24 AM, Paula Cafeld wrote:
Hi all,
please excuse- I'm a complete newbie to R, so it's possible my
question was asked a thousand times before, but I don't get it :-(
I imported a CSV file via:
x=read.csv("test.csv",header=TRUE,sep="\t")
In a column there are values w
r-help@r-project.org"
Cc:
Sent: Wednesday, August 22, 2012 1:24 PM
Subject: [R] gsub -> replace substring in column
Hi all,
please excuse- I'm a complete newbie to R, so it's possible my question was
asked a thousand times before, but I don't get it :-(
I imported a CSV
This is untested, but I suspect you should try
x[[9]]
instead of
x[9]
If you want to replace the original values with the modified values, then
you will need something like,
x[[9]] <- gsub(".",",",x[[9]],fixed=T)
The difference between single brackets [] and double brackets [[]] is
importa
Hello,
Your earch pattern is wrong, it should be
gsub("\\.", ", ", x[9])
I find x[9] a bit strange, by the way. Specially if the column vector
name is V16. Anyway, try the instruction above and if it doesn't work,
post a data example with
dput( head(x, 16) ) # paste the output of this in
Hi all,
please excuse- I'm a complete newbie to R, so it's possible my question was
asked a thousand times before, but I don't get it :-(
I imported a CSV file via:
x=read.csv("test.csv",header=TRUE,sep="\t")
In a column there are values with the dot-character (".") I want to replace
with a co
Hi,
Try this:
sub("(I)\\((.*?)\\)","\\2",t1)
[1] "(Ithis) test"
A.K.
- Original Message -
From: nalluri pratap
To: r-help@r-project.org
Cc:
Sent: Thursday, June 14, 2012 7:03 AM
Subject: [R] gsub
Hi,
I have a string t1="(Ithis) I(test)"
Hello,
Try
t1 <- "(Ithis) I(test)"
t2 <- "(Ithis) test"
t3 <- sub("I\\((.+)\\)", "\\1", t1)
t2 == t3 #[1] TRUE
If there are more than one occurences, use 'gsub'.
Hope this helps,
Rui Barradas
Em 14-06-2012 12:03, nalluri pratap escreveu:
Hi,
I have a string t1="(Ithis) I(test)". I need
> sub("I\\((.*?)\\)", "\\1", t1) # nongreedy
[1] "(Ithis) test"
On Thu, Jun 14, 2012 at 7:03 AM, nalluri pratap wrote:
>
> Hi,
>
> I have a string t1="(Ithis) I(test)". I need to get t2="(Ithis) test".
>
> Can someone look into this. ?I have tried using gsub("I[^)]","",t1) , but
> didn't get th
On Jun 14, 2012, at 13:03 , nalluri pratap wrote:
>
> Hi,
>
> I have a string t1="(Ithis) I(test)". I need to get t2="(Ithis) test".
>
> Can someone look into this. ?
Well, you can, it is your problem
You need to look into the hairier parts of regular expression syntax. Looks
like th
Hi,
I have a string t1="(Ithis) I(test)". I need to get t2="(Ithis) test".
Can someone look into this. ?I have tried using gsub("I[^)]","",t1) , but
didn't get the required result.
Thanks,
Pratap
[[alternative HTML version deleted]]
__
R-
Thank you very much. This definitely helps me out.
Math
Jeff Newmiller wrote
>
> There are many resources for learning regular expressions (e.g.
> http://gnosis.cx/publish/programming/regular_expressions.html). Once you
> understand the basics you will probably be able to refer to the ?regex
>
0 and 1 means zero or 1 match.
Want to remove the word "Energy"?
gsub("( Energy){0,1},{0,1} Inc[.]{0,1}", "", DF)
On Thu, May 31, 2012 at 11:45 AM, mdvaan wrote:
> Thanks! That works like a charm, but I am not sure if I fully understand the
> syntax. I looked at the gsub page but still couldn't
There are many resources for learning regular expressions (e.g.
http://gnosis.cx/publish/programming/regular_expressions.html). Once you
understand the basics you will probably be able to refer to the ?regex help
page for specific tools. After you have waded through a tutorial, the following
ex
Thanks! That works like a charm, but I am not sure if I fully understand the
syntax. I looked at the gsub page but still couldn't figure it out. What
does the pattern part (",{0,1} Inc[.]{0,1}") do? What do the 0 and 1 within
the curly brackets refer to? Also, what if, for example, I would want to
Try this where you qualify how many characters you might match:
> gsub(",{0,1} Inc[.]{0,1}", "", DF)
[1] "Aetna""Alexander's" "Allegheny Energy"
On Wed, May 30, 2012 at 6:05 PM, mdvaan wrote:
> Hi,
>
> I have a vector like this:
>
> DF <- c("Aetna, Inc.", "Alexander's Inc.", "A
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 str
rg [mailto:r-help-boun...@r-project.org]
>> On Behalf Of Ista Zahn
>> Sent: Wednesday, March 07, 2012 6:55 PM
>> To: Greg Snow
>> Cc: r-help@r-project.org; Markus Elze
>> Subject: Re: [R] gsub: replacing double backslashes with single backslash
>>
>> On Wed
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Ista Zahn
> Sent: Wednesday, March 07, 2012 6:55 PM
> To: Greg Snow
> Cc: r-help@r-project.org; Markus Elze
> Subject: Re: [R] gsub: replacing double ba
You are chasing your tail. You have already achieved your goal, but you don't
seem to understand that.
The three characters
C:\
are represented in R as
"C:\\"
so when you see the latter, the former is what is actually already in memory.
"C:\"
is not legal R code (it is an unterminated strin
On Wed, Mar 7, 2012 at 12:57 PM, Greg Snow <538...@gmail.com> wrote:
>
> The issue here is the difference between what is contained in a string
> and what R displays to you.
>
> The string produced with the code:
>
> > tmp <- "C:\\"
>
> only has 3 characters (as David pointed out), the third of whi
The issue here is the difference between what is contained in a string
and what R displays to you.
The string produced with the code:
> tmp <- "C:\\"
only has 3 characters (as David pointed out), the third of which is a
single backslash, since the 1st \ escapes the 2nd and the R string
parsing r
On Mar 7, 2012, at 6:54 AM, Markus Elze wrote:
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.
Actually you don't have double backslashes in the argument you
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
cool that works! thanks a lot :)
--
View this message in context:
http://r.789695.n4.nabble.com/gsub-to-manipulate-characters-tp4416939p4416961.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://s
On 24-02-2012, at 12:48, syrvn wrote:
> Hello,
>
> from a vector of strings I want to delete everything after the _
>
>> v <- c("AAA_BB", "FF_MM")
>> gsub("_*", "", v)
> [1] "AAABB" "FFMM"
>
>
> but should be
> [1] "AAA" "FF"
>
>
> Why does * not work? Even perl=TRUE does not give me the
Hello,
from a vector of strings I want to delete everything after the _
> v <- c("AAA_BB", "FF_MM")
> gsub("_*", "", v)
[1] "AAABB" "FFMM"
but should be
[1] "AAA" "FF"
Why does * not work? Even perl=TRUE does not give me the right result
Man thanks!
--
View this message in context:
http
Oh, perfect. I was running
gsub(".sample.tif", "", avec).
your change
gsub("\\.sample\\.tif$", "", avec)
did it.
Thanks Sarah
*Ben Caldwell*
On Thu, Feb 2, 2012 at 1:48 PM, Sarah Goslee wrote:
> In the example you gave, all that has to be done is
> replace ".sample.tif" at the end of the
In the example you gave, all that has to be done is
replace ".sample.tif" at the end of the string with "", which
is easy.
> avec <- c("SPI1.S1.str1.P3.sample.tif", "SPI1.S1.STR2.P1.sample.tif")
> gsub("\\.sample\\.tif$", "", avec)
[1] "SPI1.S1.str1.P3" "SPI1.S1.STR2.P1"
If your real data are mo
I have some elements in a vector with extraneous information (e.g. file
name and sample IDs) that I'd like to strip from every element.
For example, I would like "SPI1.S1.str1.P3.sample.tif"
"SPI1.S1.STR2.P1.sample.tif" to read "SPI1.S1.str1.P3" "SPI1.S1.STR2.P1".
Will someone help me with the
Hi Ista,
sorry I didn't explain it better.
What I wan to do is to change each of these line into a character vector,
so that I can work with it in biomaRt.
What I am principally trying to do is extract the FBgn IDs for each of
these FBpp IDs. For that I need each line to be a character vector in
Hi Assa,
I think you should back up and tell us what you're trying to
accomplish. You can replace characters in the column just as you do in
a vector. But I think that is not what you're trying to do. Are you
trying to split the column into three different columns? If so you can
look at the colspl
Hi Ista,
This is hat I thought I am doing
I forgot to mention, but I am working with a table which look like that:
>head(data)
id protein_ids
45FBpp0070037
46FBpp0070039;FBpp0070040
47FBpp0070041;FBpp0070042;FBpp0070043
48FBpp0070044;FBpp0110571
...
For one line your solution
Hi Assa,
On Tue, Jan 24, 2012 at 6:30 AM, Assa Yeroslaviz wrote:
> 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","FBp
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 wo
Hi,
I am working with the following list of files:
[1] "study_chr1.one.phased.impute2.chunk1"
[2] "study_chr1.one.phased.impute2.chunk1_info"
[3] "study_chr1.one.phased.impute2.chunk1_info_by_sample"
[4] "study_chr1.one.phased.impute2.chunk1_summary"
[5] "study_ch
Hi,
On Mon, Nov 14, 2011 at 7:59 PM, Debs Majumdar wrote:
> Hi,
>
> I am working with the following list of files:
>
> [1] "study_chr1.one.phased.impute2.chunk1"
> [2] "study_chr1.one.phased.impute2.chunk1_info"
> [3] "study_chr1.one.phased.impute2.chunk1_info_by_sample"
> [4] "study_chr1.one.ph
On Fri, Aug 19, 2011 at 11:11 AM, Rebecca Gray wrote:
> 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
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
Hi Peter,
Well the problem is that I need to also move the ":" to the front of the
bracketed expression, although I like the simplicity of your statement. I
cannot replace all of the "[" with ":[" because I am actually just using a
small example from a large file, and there are many more "[" that
On Mon, Aug 15, 2011 at 10:34 AM, Rebecca Gray wrote:
> Hello all,
>
> I have what I think is a simple question but I've been unable to solve it. I
> have the following string:
>
> A[&states=1]:[&rate=2]425, B[&states=3]:[&rate=5]500
>
> I would like to combine the two expressions in the [], so th
Hello all,
I have what I think is a simple question but I've been unable to solve it. I
have the following string:
A[&states=1]:[&rate=2]425, B[&states=3]:[&rate=5]500
I would like to combine the two expressions in the [], so that only one set
of [] is present after each letter, so that I have t
Sorry for not including those details. Here is a more detailed description:
> 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"
> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw3
t;\\numeric=<<12>>" "alpha=<>\\numeric=<<34>>"
> cat(.Last.value, sep="\n") # see what is really in the strings
alpha=<>\numeric=<<12>>
alpha=<>\numeric=<<34>>
I don't know about your unicode/encodi
;" "alpha=<>\\numeric=<<34>>"
> > cat(.Last.value, sep="\n") # see what is really in the strings
> alpha=<>\numeric=<<12>>
> alpha=<>\numeric=<<34>>
>
> I don't know about your unicode/encodin
You forgot the 'at a minimum' information required by the posting
guide.
Most likely this is a limitation of the locale you used (and failed to
tell us about) on the OS you used (...).
On Sat, 16 Jul 2011, Sverre Stausland wrote:
Dear helpers,
I'm trying to replace a character with a unico
Don't know the answer to you first question, but for the \\ see below.
On Sat, Jul 16, 2011 at 7:19 PM, Sverre Stausland
wrote:
> Unrelated to that problem, but related to gsub() is that I can't find
> a way for gsub() to interpret the backslash as a character. In regular
> expression, \\ should
what is really in the strings
alpha=<>\numeric=<<12>>
alpha=<>\numeric=<<34>>
I don't know about your unicode/encoding problem.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-proj
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 fr
Hi Charles,
It's not clear to me what you mean by "doesn't work".
> test <- "Interesting 1\nPoint\n"
> cat(test)
Interesting 1
Point
> test1 <- gsub("ing 1\nP","ing 3\nP", test)
> cat(test1)
Interesting 3
Point
>
Cheers
Andrew
On Tue, May 17, 2011 at 10:45:31AM +0200, Thibault Charles wrote:
The backslashes in the patt argument need to be doubled since "\" is a
special regex character. Or it may work to set fixed =TRUE.
Either:
original <- "INFILTRATION INF_BASE \\n AIRCHANGE=1"
replace <- "INFILTRATION INF_BASE \n AIRCHANGE=3"
new_texte <- gsub(patt=original,replace,text)
Or:
ibb
Envoyé : mardi 17 mai 2011 11:15
À : r-help@r-project.org
Objet : Re: [R] gsub() issue...
Hello Thibault Charles,
> I have the following text :
> text <- INFILTRATION INF_BASE
>
> AIRCHANGE=1
becomes:
text <- "INFILTRATION INF_BASE\nAIRCHANGE=1"
> original
Hello Thibault Charles,
> I have the following text :
> text <- INFILTRATION INF_BASE
>
> AIRCHANGE=1
becomes:
text <- "INFILTRATION INF_BASE\nAIRCHANGE=1"
> original <- "INFILTRATION INF_BASE \n AIRCHANGE=1"
There are spaces around "\n". That's why text != original
Try
original <- "INFI
Hello R helpers,
I get a problem using gsub() function.
I have the following text :
text <- INFILTRATION INF_BASE
AIRCHANGE=1
Then my code is :
original <- "INFILTRATION INF_BASE \n AIRCHANGE=1"
replace <- "INFILTRATION INF_BASE \n AIRCHANGE=3"
new_texte <- gsub
On Aug 6, 2010, at 10:14 AM, Alfredo Alessandrini wrote:
>
> Hi,
>
> I'm using gsub, but I've a problem.
>
>> print(i)
> [1] "piante_venere.csv"
>> gsub("\\.csv$", "", i)
> [1] "piante_venere"
>> gsub("^piante_", "", i)
> [1] "venere.csv"
>
>
> Can I combine the two expressions?
>
> Like th
Hi,
I'm using gsub, but I've a problem.
> print(i)
[1] "piante_venere.csv"
> gsub("\\.csv$", "", i)
[1] "piante_venere"
> gsub("^piante_", "", i)
[1] "venere.csv"
Can I combine the two expressions?
Like this:
> gsub(.)
[1] "venere"
Thanks,
Alfredo
--
View this message in context:
ht
i <- "piante_venere.csv"
gsub("^.*_(.*)\\.csv$", "\\1", i)
-
A R learner.
--
View this message in context:
http://r.789695.n4.nabble.com/gsub-tp2316443p2316550.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org
t.org]
On Behalf Of Uwe Ligges
Sent: Tuesday, June 29, 2010 4:11 AM
To: Jason Rupert
Cc: r-help@r-project.org
Subject: Re: [R] gsub issue in R 2.11.1, but not present in 2.9.2
On 29.06.2010 12:47, Jason Rupert wrote:
Previously in R 2.9.2 I used the following to convert from an improperly
formatte
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Bert Gunter
> Sent: Tuesday, June 29, 2010 11:08 AM
> To: 'Jason Rupert'; 'Duncan Murdoch'
> Cc: r-help@r-project.org
> Subject: Re: [R
ice to double backslashes
should be heeded as much as possible. Unfortunately, I don't think it's
always possible:
> newlineString <- "first line\nsecond line\n"
> print(newlineString)
[1] "first line\nsecond line\n"
> cat(newlineString)
first line
second
ecause there is already sufficient confusion that the
typo may totally bewilder people.
-- Bert
Bert Gunter
Genentech Nonclinical Statistics
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Uwe Ligges
> Sent: Tue
On 29.06.2010 12:47, Jason Rupert wrote:
Previously in R 2.9.2 I used the following to convert from an improperly
formatted NA string into one that is a bit more consistent.
gsub("N\A", "NA", "N\A", fixed=TRUE)
This worked in R 2.9.2, but now in R 2.11.1 it doesn't seem to work an throws
t
On 29/06/2010 6:47 AM, Jason Rupert wrote:
Previously in R 2.9.2 I used the following to convert from an improperly formatted NA string into one that is a bit more consistent.
gsub("N\A", "NA", "N\A", fixed=TRUE)
This worked in R 2.9.2, but now in R 2.11.1 it doesn't seem to work an throws
Previously in R 2.9.2 I used the following to convert from an improperly
formatted NA string into one that is a bit more consistent.
gsub("N\A", "NA", "N\A", fixed=TRUE)
This worked in R 2.9.2, but now in R 2.11.1 it doesn't seem to work an throws
the following error.
Error: '\A' is an unr
On Fri, Jun 25, 2010 at 11:11 AM, Gabor Grothendieck
wrote:
> On Fri, Jun 25, 2010 at 10:48 AM, Sebastian Kruk
> wrote:
>> If I have a text with 7 words per line and I would like to put first
>> and second word joined in a vector and the rest of words one per
>> column in a matrix how can I do it
help("strsplit") is your friend, for example:
t <- c("2008/12/31 12:23:31 numero 343.233.233 Rodeo Vaca Ruido",
"2010/02/01 02:35:31 palabra 111.111.222 abejorro Rodeo Vaca")
m <- do.call(rbind, strsplit(t, "[[:space:]]+")) # Matrix of all the data
v <- paste(m[, 1], m[, 2]) # The vect
On Fri, Jun 25, 2010 at 10:48 AM, Sebastian Kruk
wrote:
> If I have a text with 7 words per line and I would like to put first
> and second word joined in a vector and the rest of words one per
> column in a matrix how can I do it?
>
> First 2 lines of my text file:
> "2008/12/31 12:23:31 numero 3
If I have a text with 7 words per line and I would like to put first
and second word joined in a vector and the rest of words one per
column in a matrix how can I do it?
First 2 lines of my text file:
"2008/12/31 12:23:31 numero 343.233.233 Rodeo Vaca Ruido"
"2010/02/01 02:35:31 palabra 111.111.22
ast on my client) posting.
--
David.
From: jim holtman [mailto:jholt...@gmail.com]
Sent: Wednesday, April 28, 2010 1:31 PM
To: arnaud Gaboury
Cc: r-help@r-project.org
Subject: Re: [R] gsub,regex and replacing
Next time you include a data frame that has spaces in the fields,
please
consider
, -1082, 11084, 1983.5,
-2464, -118), quantity = c(0, -3, 8, 2, -1, 0)), .Names = c("DESCRIPTION",
"prix", "quantity"), row.names = c(NA, -6L), class = "data.frame")
From: jim holtman [mailto:jholt...@gmail.com]
Sent: Wednesday, April 28, 2010 1:31
Next time you include a data frame that has spaces in the fields, please
consider using 'dput' to provided the data. It is hard to read in
otherwise.
Will this do it:
> x <- read.table(textConnection(" DESCRIPTIONprix
quantity
+ 1 'CORN Jul/10'-1.5
Dear group,
I need to modify some characters in a data frame. I want to use gsub and the
regex functionalities to do this.
Here is the data frame (df):
DESCRIPTIONprix quantity
1 CORN Jul/10-1.50
2 CORN May/10 -1082.0
riginal Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Christian Raschke
Sent: Monday, February 22, 2010 10:20 AM
To: r-help@r-project.org
Subject: Re: [R] gsub patterns from vector elements w/out loop?
Marianne,
The function substring2 from the
Here are a few possibilities using gsubfn in the gsubfn package
x <- c("one","two")
y <- paste(rep(x,2),"blah")
library(gsubfn)
# 1
gsubfn("\\w+", w ~ if (w %in% x) "something else" else w, y)
# 2
gsubfn("\\w+", list(one = "something else", two = "something else"), y)
# 3
L <- sapply(x, functio
1 - 100 of 126 matches
Mail list logo