[R] specifying header in sqldf() and RSQLite

Gabor Grothendieck ggrothendieck at gmail.com
Wed Apr 7 14:08:49 CEST 2010


You could do this:

DF <- read.csv.sql("myfile.csv", skip = 1, header = FALSE)
names(DF) <- vector of desired names

If you want to use the first line as the basis of creating the heading
vector you could do this to read it in:

hdg <- readLines("myfile.csv", n = 1)
names(DF) <- ... some transformatin of hdg ...

On Wed, Apr 7, 2010 at 12:18 AM, Andrew Yee <yee at post.harvard.edu> wrote:
> I have a file that I'm planning on manipulating with sqldf().  The header
> for this file is malformed, and I was wondering if there's a way to specify
> the values of the header ahead of time.  I can see there are T/F options for
> header in sqldf(... list(header=T, ...), but was wondering if there's a way
> to explicitly stated what the header should be.
>
> Thanks,
> Andrew
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list