076"
A.K.
- Original Message -
From: Erin Hodgess
To: R help
Cc:
Sent: Sunday, August 12, 2012 11:33 PM
Subject: [R] named character question
Dear R People:
Here is a goofy question:
I want to extract the zip code from an address and here is my work so far:
> add1
ent: Sunday, August 12, 2012 10:34 PM
> To: R help
> Subject: [R] named character question
>
> Dear R People:
>
> Here is a goofy question:
>
> I want to extract the zip code from an address and here is my work so
> far:
>
> > add1
>
HI,
Try this:
add11<-strsplit(add1,split=",")
gsub("TX","",add11[[1]][3])
#[1] " 77076"
A.K.
- Original Message -
From: Erin Hodgess
To: R help
Cc:
Sent: Sunday, August 12, 2012 11:33 PM
Subject: [R] named character question
Dear R Pe
On Aug 12, 2012, at 8:33 PM, Erin Hodgess wrote:
Dear R People:
Here is a goofy question:
I want to extract the zip code from an address and here is my work
so far:
add1
results.formatted_address
"200 W Rosamond St, Houston, TX 77076, USA"
add1[1][32:36]
NA NA
Hi Erin,
The first element of the character vector is a string. You cannot
extract specifically characters from a string; try something like
?nchar
or perhaps better use regular expressions to extract things between
commas after two characters (or whatever logical rule accurately gets
the zip co
It's best if you make these things available to us using dput() in the future.
You're probably looking for the substr() function.
Since _strings_ (not characters) in R are "primitive" (Not in the
primitive/internal sense: just in the primordial sense) you can't
subset them with the brackets opera
Dear R People:
Here is a goofy question:
I want to extract the zip code from an address and here is my work so far:
> add1
results.formatted_address
"200 W Rosamond St, Houston, TX 77076, USA"
> add1[1][32:36]
NA NA NA NA NA
> str(add1)
Named chr "200 W Rosamond
7 matches
Mail list logo