Re: [R] Convert a column of numbers to a column of strings

2010-02-01 Thread Gabor Grothendieck
Issue this first: library(chron) On Mon, Feb 1, 2010 at 2:42 PM, Gabor Grothendieck wrote: > Try this > >> Lines <- "Date Time Data > + 20091209 1200 1 > + 20091209 1500 2 > + 20091209 1800 3 > + 20091210 800 4 > + 20091210 1000 5 > + 20091210 1600 6" >> >> toChron <- function(x) as.chron(sprint

Re: [R] Convert a column of numbers to a column of strings

2010-02-01 Thread Gabor Grothendieck
Try this > Lines <- "Date Time Data + 20091209 1200 1 + 20091209 1500 2 + 20091209 1800 3 + 20091210 800 4 + 20091210 1000 5 + 20091210 1600 6" > > toChron <- function(x) as.chron(sprintf("%d %04d", x[,1], x[,2]), "%Y%m%d > %H%M") > > DF <- read.table(textConnection(Lines), header = TRUE) > toChr

Re: [R] Convert a column of numbers to a column of strings

2010-02-01 Thread Erik Iverson
Also, although you don't need it to accomplish what you want, you were probably looking for the as.character function instead of toString... Tam Le wrote: Hello, Please excuse me if this question has been asked before. I'm new to R, and have been trying to google the answers without any succes

Re: [R] Convert a column of numbers to a column of strings

2010-02-01 Thread Erik Iverson
Hello, Tam Le wrote: Hello, Please excuse me if this question has been asked before. I'm new to R, and have been trying to google the answers without any success. I would like to convert a set of date and time into R date-time class. Right now, the dates and times are in integer format, so I f

[R] Convert a column of numbers to a column of strings

2010-02-01 Thread Tam Le
Hello, Please excuse me if this question has been asked before. I'm new to R, and have been trying to google the answers without any success. I would like to convert a set of date and time into R date-time class. Right now, the dates and times are in integer format, so I first need to convert the