[R] can't open file

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jul 7 15:37:38 CEST 2010


On Wed, Jul 7, 2010 at 9:16 AM, Sebastian Kruk <residuo.solow at gmail.com> wrote:
> I have a text file log2.log encoded Ansi in Windows.
>
> When I execute:
>
> out <- read.zoo(readLines(con <- file("log2.log",
> encoding="UCS-2LE")),FUN = as.chron)
>
> have errors:
>
> Error en file(file, "rt") : no se puede abrir la conexión
> Además: Mensajes de aviso perdidos
> 1: In file(file, "rt") :
>  sólo fue usado el primer elemento del argumento 'description'
> 2: In file(file, "rt") :
>  no fue posible abrir el archivo '#Software: Microsoft Internet
> Information Services 5.0': No such file or directory
>
> Why?
>

The file argument of read.zoo is a character string giving the *name*
of the file, not the contents of the file as a vector of character
strings.  Alternately it can be a connection (undocumented but works)
or a data.frame so you likely want one of these:

read.zoo(file("log2.log", encoding="UCS-2LE"), FUN = as.chron)
read.zoo("log2.log", FUN = as.chron)

See the examples section of ?read.zoo for more examples.



More information about the R-help mailing list