[R] dataTable manipulation in R

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Sun Nov 6 19:15:50 CET 2005


Marc, thanks for pointing out. I completely misread Xiaofan's post.

In addition to your advice, I like to point out the function which()
which selects only the true values. This is comes in handy when one has
missing values or if the condition generates missing values in the data.

Regards, Adai


On Sun, 2005-11-06 at 11:59 -0600, Marc Schwartz wrote:
> Adai,
> 
> I suspect that Xiaofan was looking for the use of a function like
> subset(), which of course does enable one to specify filtering criteria
> and return a subset of rows in a data frame that satisfy the criteria.
> 
> I am presuming that the SQL reference was more towards using SQL
> Select/Where type statements within a database as an example, as opposed
> to wanting to query a SQL database from within R.
> 
> Xiaofan, see ?subset for more information. The function will also let
> you specify a subset of columns using the 'select' argument.
> 
> In addition to subset(), there is also the use of [.data.frame, which
> will enable you to specify criteria using the typical "[row, column]"
> extraction approach. See ?"[.data.frame" for more information.
> 
> Which approach is taken is to some extent personal preference. I find it
> easier to use subset() when the criteria are more complex boolean
> expressions and/or where I only want a subset of the columns.
> 
> HTH,
> 
> Marc Schwartz
> 
> 
> On Sun, 2005-11-06 at 17:44 +0000, Adaikalavan Ramasamy wrote:
> > Check out the R Data Import/Export manual, especially
> > http://cran.r-project.org/doc/manuals/R-data.html#DBI-_002f-RMySQL
> > and the RMySQL package.
> > 
> > 
> > On Sun, 2005-11-06 at 03:37 +0000, Xiaofan Li wrote: 
> > > Dear colleague,
> > > 
> > > Is it able in R to manipulate data tables as in SQL-based databases?
> > > Is there any good method in R to locate a special subset of data rows, which
> > > satisfy a certain expression of restrictions (e.g. dataTable$peakValue <
> > > 3.0)? Then if located, is it able for manipulations, for example, to delete
> > > them from the dataTable?
> > > 
> > > Cheers,
> > > Xiaofan
> > > 
> 
> 
-- 
Adaikalavan Ramasamy                    ramasamy at cancer.org.uk
Centre for Statistics in Medicine       http://www.ihs.ox.ac.uk/csm/
Wolfson College Annexe                  Tel : 01865 284 408
Linton Road, Oxford OX2 6UD             Fax : 01865 284 424




More information about the R-help mailing list