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,
> &
o 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. However, there
&
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
;
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%", which I
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
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
L Carlson
> Department of Anthropology
> Texas A 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: Zile
016"
"2","8/24/2016"
"3","6/16/2016"
"4","6/16/2016"
-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352
-----Original Message-
From: R-help [mail
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
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
On Thu, Feb 12, 2015 at 3:40 PM, arnaud gaboury
arnaud.gabo...@gmail.com 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, vairis,
On Thu, Feb 12, 2015 at 7:12 PM, arnaud gaboury
arnaud.gabo...@gmail.com wrote:
On Thu, Feb 12, 2015 at 3:40 PM, arnaud gaboury
arnaud.gabo...@gmail.com wrote:
I have two df (and dt):
df1
structure(list(name = c(poisonivy, poisonivy, poisonivy,
poisonivy, poisonivy, poisonivy, poisonivy,
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 didn't submit pass codes for a
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 documentation explain
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]]]rray[n]
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:
code
DataGoogle1 - read.csv(file = DataGoogle2.csv, header = T,
stringsAsFactors = F)
head(DataGoogle1)
/code
Result 1:
Campaña
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,
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
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, Omar André
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,
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:
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
On Wed, May 8, 2013 at 5:08 AM, Thaler,Thorn,LAUSANNE,Applied
Mathematics thorn.tha...@rdls.nestle.com 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
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 - 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 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
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 a
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
important
:
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 file via:
x=read.csv(test.csv,header=TRUE,sep=\t
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 with
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]]
__
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 the problem
sub(I\\((.*?)\\), \\1, t1) # nongreedy
[1] (Ithis) test
On Thu, Jun 14, 2012 at 7:03 AM, nalluri pratap pratap_s...@yahoo.co.in 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
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 to get
Hi,
Try this:
sub((I)\\((.*?)\\),\\2,t1)
[1] (Ithis) test
A.K.
- Original Message -
From: nalluri pratap pratap_s...@yahoo.co.in
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). I need to get t2=(Ithis
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
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 mathijsdev...@gmail.com wrote:
Thanks! That works like a charm, but I am not sure if I fully understand the
syntax. I looked at the gsub page
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
help
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 -
Try this where you qualify how many characters you might match:
gsub(,{0,1} Inc[.]{0,1}, , DF)
[1] AetnaAlexander's Allegheny Energy
On Wed, May 30, 2012 at 6:05 PM, mdvaan mathijsdev...@gmail.com wrote:
Hi,
I have a vector like this:
DF - c(Aetna, Inc., Alexander's Inc.,
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
-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 backslashes with single backslash
On Wed, Mar 7, 2012 at 12:57 PM, Greg Snow 538
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
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
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
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 which is a
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 string).
-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 backslashes with single backslash
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:
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 right result
gsub(_.*$, , v)
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
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 syntax
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 more complex, we
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 sarah.gos...@gmail.com wrote:
In the example you gave, all that has to be done is
replace .sample.tif at 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,
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.
Hi Assa,
On Tue, Jan 24, 2012 at 6:30 AM, Assa Yeroslaviz fry...@gmail.com 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:
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,
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
Hi,
On Mon, Nov 14, 2011 at 7:59 PM, Debs Majumdar debs_st...@yahoo.com 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]
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]
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
On Fri, Aug 19, 2011 at 11:11 AM, Rebecca Gray atlas...@gmail.com 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
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 the
On Mon, Aug 15, 2011 at 10:34 AM, Rebecca Gray atlas...@gmail.com 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
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 are
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
-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Sverre Stausland
Sent: Saturday, July 16, 2011 7:20 PM
To: r-help@r-project.org
Subject: [R] gsub() with unicode and escape character
Dear helpers,
I'm trying to replace a character with a unicode code inside a data
-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Sverre Stausland
Sent: Saturday, July 16, 2011 7:20 PM
To: r-help@r-project.org
Subject: [R] gsub() with unicode and escape character
Dear helpers,
I'm trying to replace a character with a unicode code inside
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-mingw32/i386 (32-bit)
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 frame cannot have
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Sverre Stausland
Sent: Saturday, July 16, 2011 7:20 PM
To: r-help@r-project.org
Subject: [R] gsub() with unicode and escape character
Dear helpers,
I'm trying to replace
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
john...@fas.harvard.edu 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
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 -
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 - INFILTRATION
: 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 - INFILTRATION INF_BASE \n AIRCHANGE=1
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:
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:
Hello R
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
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:
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 this:
gsub(.)
[1] venere
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
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 the
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
the
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: 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
[mailto:r-help-boun...@r-project.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
-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] gsub issue in R 2.11.1, but not present in 2.9.2
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
formatted NA string into one that is a bit more consistent.
gsub(N\A, NA, N\A, fixed=TRUE)
This worked in R
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.222
On Fri, Jun 25, 2010 at 10:48 AM, Sebastian Kruk
residuo.so...@gmail.com 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
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 vector
m -
On Fri, Jun 25, 2010 at 11:11 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
On Fri, Jun 25, 2010 at 10:48 AM, Sebastian Kruk
residuo.so...@gmail.com 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
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
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
)), .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 PM
To: arnaud Gaboury
Cc: r-help@r-project.org
Subject: Re: [R] gsub,regex and replacing
Next time you include a data frame
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 using 'dput' to provided the data. It is hard to read in
otherwise.
Will this do it:
x - read.table(textConnection
Dear list,
I have two vectors:
x - c(one,two)
y - paste(rep(x,2),blah)
I want to replace all occurrences of each element of x in y with
something else, so that y looks like this:
y
[1] something else blah something else blah something else blah
[4] something else blah
I can do this using a
gsub(one|two, something else, y)
?
On Mon, Feb 22, 2010 at 4:25 PM, Marianne Promberger
marianne.promber...@kcl.ac.uk wrote:
Dear list,
I have two vectors:
x - c(one,two)
y - paste(rep(x,2),blah)
I want to replace all occurrences of each element of x in y with
something else, so that y
1 - 100 of 125 matches
Mail list logo