Re: [R] Sqldf INSERT INTO

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed, 20 Apr 2011 19:49:25 -0400

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

______________________________________________
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.
Received on Wed 20 Apr 2011 - 23:51:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Apr 2011 - 00:00:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive