Skip to content
Prev 207722 / 398502 Next

RMySQL - Bulk loading data and creating FK links

On Wed, Jan 27, 2010 at 8:56 AM, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
read.csv.sql
In the SQLite database it automatically assigns a self incrementing
hidden column called rowid to each row. e.g. using SQLite via the
sqldf package on CRAN and the BOD data frame which is built into R we
can display the rowid column explicitly by referring to it in our
select statement:
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
rowid Time demand
1     1    1    8.3
2     2    2   10.3
3     3    3   19.0
4     4    4   16.0
5     5    5   15.6
6     6    7   19.8
In SQLite you can get the top 3 values, say, like this (continuing the
prior example):
Time demand
1    7   19.8
2    5   15.6
3    4   16.0