[R] a question on sqldf's handling of missing value and factor

Gabor Grothendieck ggrothendieck at gmail.com
Wed Mar 2 14:02:07 CET 2011


On Tue, Mar 1, 2011 at 11:52 PM, xin wei <xinwei at stat.psu.edu> wrote:
> Dear subscribers:
>
> I am using the following code to read a large number of big text files:
> library(sqldf)
> tempd <- file(XXXX)
> tempdx <- sqldf("select * from tempd", dbname = tempfile(), file.format =
> list(header = T, sep="\t", row.names = F))
>
> The problem is: all my numberical variable become factor (maybe because
> these columns all contain missing value). It would be quite cubersome to
> convert them to numeric variable using as.numeric one by one. Does anyone
> know how to re-set SQLDF so that it would automatically read the numeric
> column with missing row as real numeric instead of factor?
>

If you can provide a minimal ***reproducible*** example it would help.
 Maybe sqldf(..., method = "raw") will give you what you want but I
can't say for sure without the example.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list