Seems more likely to be related to changes in the options stringr uses
when it invokes the regex code? See the different response coming from
base R when told to use a different regex engine:
grep( "+proj", "syz+project" )
[1] 1
grep( "+proj", "syz+project", perl=TRUE )
Error in grep("+proj
"+" is a special character in regular expressions that requires a preceding
pattern to apply to. See ?base::regex.
You need to escape the special with a backslash to remove the special behavior,
and escape the backslash so the R parser will be happy.
str_extract("+proj=utm +zone=19 +datum=WGS84
thanks that makes sense... in the previous version of R it worked for
some reason.
On Thu, Aug 13, 2015 at 4:33 PM, Sarah Goslee
wrote:
> Hi,
>
> The + is a special character in regular expressions. If you want to
> match a literal + you need to escape it:
>
> str_extract("+proj=utm +zone=19
Hi,
The + is a special character in regular expressions. If you want to
match a literal + you need to escape it:
str_extract("+proj=utm +zone=19 +datum=WGS84 +units=m +no_defs
+ellps=WGS84 +towgs84=0,0,0", "\\+proj=[a-zA-Z0-9]*")
Sarah
On Thu, Aug 13, 2015 at 2:55 PM, Mauricio Romero
wrote:
>
Hi,
I'm running R 3.2.1 and im having an unexpected problem... when I run the
follwing code it returns an error
library(stringr)
str_extract("+proj=utm +zone=19 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0", "+proj=[a-zA-Z0-9]*")
But I can't find whats wrong with my code.
Thanks
> with(dat, data.frame(X=rep(X, each=2), Y=unlist(strsplit(Y, split=" - "
str_split_fixed would be a bit safer here.
Hadley
--
Chief Scientist, RStudio
http://had.co.nz/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-
a.frame(X=rep(dat1$X,each=2),Y=
unlist(str_split(dat1$Y,"-")),stringsAsFactors=FALSE)
dat2
# X Y
#1 ab su
#2 ab di
#3 ac pi
#4 ac tu
#5 ad tu
#6 ad tu
A.K.
- Original Message -
From: Sudip Chatterjee
To: R help
Cc:
Sent: Wednesday, April 10, 2013 12:25 PM
Subject: [R]
On Wed, Apr 10, 2013 at 12:25 PM, Sudip Chatterjee
wrote:
> Hi Group,
>
> I have a question on Stringr package
>
> I have a table like this
> X Y
> absu - di
> acpi - tu
> adtu - tu
>
> I want output like this
> XY
> ab su
> ab di
> ac pi
>
X Y
#1 ab su
#2 ab di
#3 ac pi
#4 ac tu
#5 ad tu
#6 ad tu
A.K.
- Original Message -
From: Sudip Chatterjee
To: R help
Cc:
Sent: Wednesday, April 10, 2013 12:25 PM
Subject: [R] Stringr Package
Hi Group,
I have a question on Stringr package
I have a table like this
X Y
ab
Hi Group,
I have a question on Stringr package
I have a table like this
X Y
absu - di
acpi - tu
adtu - tu
I want output like this
XY
ab su
ab di
ac pi
ac tu
ad tu
ad tu
I am wondering if this operation can be done
10 matches
Mail list logo