[R] Sqldf INSERT INTO

Gabor Grothendieck ggrothendieck at gmail.com
Thu Apr 21 01:49:25 CEST 2011


On Wed, Apr 20, 2011 at 12:39 PM, new2R <bv_agrico at yahoo.co.in> wrote:
>  Hi,
>
> I am new to R and trying to migrate from SAS. I am trying to copy data from
> one table to another table which have same columns using sqldf. but not
> working and showing "NULL"
>
> I wrote statement as sqldf("INSERT INTO new select * from data") but showing
> NULL
>
> Please help me in this regard.
>

In your example new is a table in the sqlite database, not in R's
workspace, so you have to return it:

> library(sqldf)
> BOD
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
> New <- BOD[1, ]
> BOD1 <- BOD[2:3,]
> sqldf(c("insert into New select * from BOD1", "select * from New"))
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0


-- 
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