[R] Creating a data table (frame?) from a SQL Statement?
Morkus
morkus at protonmail.com
Tue Oct 24 16:01:36 CEST 2017
Hello,
I'm new to R so this is probably a simple question for somebody.
I have an RScript that reads a CSV on the disk using read.table(...). It then does a boxM test using that data.
However, I'm now trying to load the same data via an SQL command, but I can't seem to get the data structure defined so R will like it -- using the included "iris" dataset.
I've tried these ways of loading the SQL statement into a compatible R Structure:
irisQuery <- data(dbGetQuery(conn, "select * from iris"))
irisQuery <- data.frame(dbGetQuery(conn, "select * from iris"))
irisQuery <- table(dbGetQuery(conn, "select * from iris"))
.
.
.
Followed by:
boxM(irisQuery[,-5], irisQuery[,5])
Nothing works work.
For example, if i use ...
irisQuery <- data.frame(dbGetQuery(conn, "select * from iris"))
I get this error from R on the boxM test: Error: is.numeric(x) || is.logical(x) is not TRUE
The SQL Statement is returning results, but their not CSV. Not sure if that matters.
-------------------
So, how do I read a SQL statement into an R structure like I read the CSV using "read.table" so the boxM test will work?
Thanks very much in advance.
- M
Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
[[alternative HTML version deleted]]
More information about the R-help
mailing list