[R] different file types
Jason Turner
jasont at indigoindustrial.co.nz
Tue Mar 11 23:07:28 CET 2003
On Tue, Mar 11, 2003 at 03:39:36PM -0500, janet rosenbaum wrote:
>
> Hi. I am writing a program to read in different types of files from a
> GUI. While it's easy to read different types of text files, I am
> stymied how to make R execute the input.
>
> Ideally I could get the command from input and dereference it like
> `command`(filename)
> where command would be read.dta or read.table or read.xport or any of
> the similar commands.
> Also, is there a way to make associative arrays?
> It would be nice to be able to get the format from input and then have
> command<-array[format]
Not that I'm aware of. Since R is a rather nice functional
programming language, there are often other ways to do the same
thing. I'd have the front end supply a format (table, csv, xport,
etc), then use paste() and match.fun(), e.g.
file.format <- "csv" #this would be supplied by the gui
readCmd <- paste(sep=".","read",file.format)
readFunc <- match.fun(readCmd)
readFunc(file)
Cheers
Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz
More information about the R-help
mailing list