You can read from a character vector as if it were a file like this:
x <- c("1-2", "3-4", "5-6")
read.table(textConnection(x), sep = "-", col.names = c("one", "two"))
one two
1 1 2
2 3 4
3 5 6
On Wed, May 5, 2010 at 12:45 PM, karena <dr.jzhou at gmail.com> 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