[R] when to use textConnection ??

2010-08-16 Thread skan
Hello. I don't uderstant when to use textConnection and when not. Some examples do it, some not. I've even seen something like con - textConnection(rev(rev(ReadLines('data.txt'))[-(1:2])) data - read.table(con) close(con) -- View this message in context:

Re: [R] when to use textConnection ??

2010-08-16 Thread Joshua Wiley
Hi, One useful case is when data is sent in an email. For instance: T1 T2 T3 -0.24 -0.26 -0.67 -1.58 0.04 0.14 -1.21 1.55 -0.45 0.31 0.48 -1.39 One could read it in via con - textConnection( T1 T2 T3 -0.24 -0.26 -0.67 -1.58 0.04 0.14 -1.21 1.55 -0.45 0.31 0.48 -1.39)

Re: [R] when to use textConnection ??

2010-08-16 Thread Matt Shotwell
Also, many R functions are designed to operate on R connections, to input and output text. Alternatively, we may wish to provide the input text as an R character vector, or output text to a character vector. The textConnection makes a character vector look like a connection, so R routines that

Re: [R] when to use textConnection ??

2010-08-16 Thread skan
OK, thanks Some time ago I asked in the forum how to read data from a file in order to use it with zoo. Someone suggested to use textConnection That's why I'm a little bit confused. I guess I don't need to use textConnection in order to read from files, it's just for text copied from other

Re: [R] when to use textConnection ??

2010-08-16 Thread Gabor Grothendieck
On Mon, Aug 16, 2010 at 1:40 PM, skan juanp...@gmail.com wrote: OK, thanks Some time ago I asked in the forum how to read data from a file in order to use it with zoo. Someone suggested to use textConnection That's why I'm a little bit confused. I guess I don't need to use textConnection

Re: [R] when to use textConnection ??

2010-08-16 Thread skan
Gabor Grothendieck wrote: Note that zoo does have the read.zoo function which can read a file returning a zoo object. See help(read.zoo) . I know, but there are many different ways to read and I wanted to know what's the proper in my case. For example I've seen these ones, what's

Re: [R] when to use textConnection ??

2010-08-16 Thread skan
I've just seen that sep sep cannot be , because there are not commas in the file. but I want it to take the first and second columns (date and time) as a whole, the index. -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327622.html Sent

Re: [R] when to use textConnection ??

2010-08-16 Thread Gabor Grothendieck
On Mon, Aug 16, 2010 at 8:00 PM, skan juanp...@gmail.com wrote: I've just seen that sep sep cannot be ,  because there are not commas in the file. but I want it to take the first and second columns (date and time) as a whole, the index. In the latest version of zoo index.column= can be a

Re: [R] when to use textConnection ??

2010-08-16 Thread skan
Error in .subset(x, j) : invalid subscript type 'list' Maybe is because I'm using Revolution Analytics and is based on an older version of R. I use it because I need to manage very big files and the common version of R shows me an out of memory error. -- View this message in context:

Re: [R] when to use textConnection ??

2010-08-16 Thread Gabor Grothendieck
On Mon, Aug 16, 2010 at 8:36 PM, skan juanp...@gmail.com wrote: Error in .subset(x, j) : invalid subscript type 'list' Maybe is because I'm using Revolution Analytics and is based on an older version of R. I use it because I need to manage very big files and the common version of R shows

Re: [R] when to use textConnection ??

2010-08-16 Thread skan
Oh, I got it with these code: tmp - read.table(file.txt) mydata - zoo(z$V3, as.chron(paste(z$V1,z$V2))) but that way I cannot specify the format of the date cheers -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327656.html Sent from the

Re: [R] when to use textConnection ??

2010-08-16 Thread Gabor Grothendieck
On Mon, Aug 16, 2010 at 8:50 PM, skan juanp...@gmail.com wrote: Oh, I got it with these code: tmp - read.table(file.txt) mydata - zoo(z$V3, as.chron(paste(z$V1,z$V2))) but that way I cannot specify the format of the date The default method of as.chron has a format= argument which uses the

Re: [R] when to use textConnection ??

2010-08-16 Thread Gabor Grothendieck
On Mon, Aug 16, 2010 at 8:07 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Mon, Aug 16, 2010 at 8:00 PM, skan juanp...@gmail.com wrote: I've just seen that sep sep cannot be ,  because there are not commas in the file. but I want it to take the first and second columns (date and