Hello, there.
I'm a newbie to rpy2.
I'm confused to access a datatable through rpy2 and would like to know how
to.
Rpy2 seems very powerful and functional. I tried accessing to SQLite by
using RSQLite, by Rpy2 on Python
robjects.r('library(RSQLite)')
drv = 'dbDriver("SQLite")'
This worked. Great.
I sent SQL command from Python to R, and made an Robject to represent a
dataframe.
con = 'dbConnect(%s , dbname = \"%s\")' % (drv, d) #
Suppose d is a directory name where an SQLite.db exists
data_table = robjects.r('dbGetQuery(%s, \"%s\")' % (con, sql)) # sql
is an SQL string, defined on Python, for instance
Processing those, the python interpreter gave back the data_table infomation
as we saw on R.
Question here. I want to give a column data of the data_table to an R
function, such as t.test. But I don't know how.
On R, if you have a data_table and want to specify a column data, you may
write:
data_table$column_name
and you can send the data to an R function; however, it seems impossible on
Rpy2(Yes, it is on Python!).
Additionally, if you name the data_frame data_table on Python, R cannot
recognize the name so that
a string of R command seems to make no sense to R.
robjects.r(some_r_function('%s$specified_column_name" % data_table)) #
This is no good. Doesn't work properly
Would anybody here please tell me how to access some elements to data frame
as an R object on Python with Rpy2?
Thanks, regards.
--
亀田馬志
Masahi Kameda
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list