[R] any function in R similar to the "scan" function in SAS?

Erik Iverson eriki at ccbr.umn.edu
Thu May 6 01:57:41 CEST 2010


karena wrote:
> I am wondering if there is any function in R that is similar to the "scan"
> function in SAS.
> I have a data.frame which has two columns as the following:
> one   two
> 1      2
> 3      4
> 5      6
> 
> I used the "paste" function to create the third column: three <-
> paste(one,'-',two,sep="")
> so the data.frame is like this now:
> one   two   three
> 1      2       1-2
> 3      4       3-4
> 5      6       5-6
> 
> My question is, is there any function in R that can do the opposite thing to
> what "paste" does?
> suppose I only have the third column "three" now, and I want to get the
> first and second columns. If in SAS, I can do the following:
> one = scan(three,1,'-')
> two = scan(three,-1,'-')
> 
> How can I do this in R?

?strsplit



More information about the R-help mailing list