[R] the integer of a given location

2009-09-12 Thread darkhorn
I have a huge number such as 78923698701 z-78923698701 I want to find the integer of a given location, for example here, what is the 2nd number? 8. Thanks in advance! -- View this message in context: http://www.nabble.com/the-integer-of-a-given-location-tp25418729p25418729.html Sent from the R

Re: [R] the integer of a given location

2009-09-12 Thread jim holtman
Is this what you want: z-78923698701 substring(as.character(z), 2, 2) [1] 8 On Sat, Sep 12, 2009 at 6:16 PM, darkhorn darkh...@gmail.com wrote: I have a huge number such as 78923698701 z-78923698701 I want to find the integer of a given location, for example here, what is the 2nd

Re: [R] the integer of a given location

2009-09-12 Thread Jorge Ivan Velez
Hi darkhorn, Here are two suggestions: # Suggestion 1 z - 78923698701 foo - function(x, pos) strsplit(as.character(x),)[[1]][pos] foo(z,2) # [1] 8 # Suggestion 2 foo2 - function(x, pos) substr(x,pos,pos) foo2(z,2) # [1] 8 See ?strsplit and ?substr for more details. HTH, Jorge On Sat, Sep 12,

Re: [R] the integer of a given location

2009-09-12 Thread darkhorn
Thank you very much. :-) as.integer(substring(as.character(z), 2, 2)) [1] 8 as.integer(foo2(z,2)) [1] 8 -- View this message in context: http://www.nabble.com/the-integer-of-a-given-location-tp25418729p25419555.html Sent from the R help mailing list archive at Nabble.com.