I have a pandas framework that I convert to an R data file using the convert_to_r_dataframe method from pandas.rpy.common. I configured it as such:
self.event = pd.read_csv('C://' + self.event_var.get() + '.csv') final_products = pd.DataFrame({'Product': self.event.Product, 'Size': self.event.Size, 'Order': self.event.Order}) r.assign('final_products', com.convert_to_r_dataframe(final_products)) r.assign('EventName', self.event_var.get()) r.assign('EventTime', self.eventtime_var.get()) r.source('application.r')
where self.event_var.get () retrieves user input in the GUI (I am building an application using Tkinter). Product, size and order are columns from the CSV file.
Since Rpy2 installs the R environment in Python, I expect the final R-data_product to be understood by the R environment. Unfortunately, while the R script is running, it does not give the correct results (I create graphs using the R script, but they are just empty when the program ends). However, the EventName and EventTime variables work. Is there something I'm missing here? Any ideas why the purpose of the R-frame in Python is misinterpreted by the R framework?
Received error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in __call__ return self.func(*args) File "G:\Development\workspace\GUI\GUI.py", line 126, in evaluate r.source('application.r') File "C:\Python27\lib\site-packages\rpy2\robjects\functions.py", line 86, in __call__ return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs) File "C:\Python27\lib\site-packages\rpy2\robjects\functions.py", line 35, in __call__ res = super(Function, self).__call__(*new_args, **new_kwargs)
python r dataframe rpy2
Kidsudi
source share