Re: [R] named character question

2012-08-13 Thread arun
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

Re: [R] named character question

2012-08-13 Thread David L Carlson
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 >

Re: [R] named character question

2012-08-13 Thread arun
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

Re: [R] named character question

2012-08-13 Thread David Winsemius
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

Re: [R] named character question

2012-08-12 Thread Joshua Wiley
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

Re: [R] named character question

2012-08-12 Thread R. Michael Weylandt
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

[R] named character question

2012-08-12 Thread Erin Hodgess
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