0
votes

Working with a relatively new R package called "eegAnalysis" through rpy2 and getting an error for a time-series object required by the FeatureEEG function.

table_query = R_DBI.dbGetQuery(DBI_Connection, "SELECT * FROM {0}".format(a_table)) 

where table_query is returned from a PostgreSQL database, a small portion of the data looks like

'data.frame': 52000 obs. of 68 variables:
lfg1 : num 205 200 185 183 175 ...
lfg10: num -135.1 -124.1 -127.1 -116.1 -80.1 ...
lfg11: num -132 -109 -101 -103 -116 ...
lfg12: num -259 -246 -232 -196 -203 ...

soon there-after a time-series object is created using table_query from above

ts = R_ts.timeSeries(table_query, start = 1, end = table_query.nrow, frequency = 1)

several lines below used for the important line even further below

n_columns = ts.ncol
col_middle = n_columns / 2
if round(col_middle) != col_middle:
    col_middle = col_middle + 0.5
group_1 = int(col_middle)
group_2 = int(n_columns - group_1)
classification = R_base.c(R_base.rep(1, group_1), R_base.rep(2, group_2))

the important line is here

featureEEG = R_EEGA.FeatureEEG(ts, rec_Id = ts.nrow, classes_Id = classification)  

FeatureEEG is a function from the R eegAnalysis package. After processing for a few moments the following error is returned

Traceback (most recent call last): File "D:\Projects\Kaggle\UPenn_and_Mayo_Clinic_Seizure_Detection\Scripts\py_test01.py", line 135, in featureEEG = R_EEGA.FeatureEEG(ts, rec_Id = ts.nrow, classes_Id = classification) File "C:\Python33\lib\site-packages\rpy2-2.3.8-py3.3-win32.egg\rpy2\robjects\functions.py", line 86, in call return super(SignatureTranslatedFunction, self).call(*args, **kwargs) File "C:\Python33\lib\site-packages\rpy2-2.3.8-py3.3-win32.egg\rpy2\robjects\functions.py", line 35, in call res = super(Function, self).call(*new_args, **new_kwargs) rpy2.rinterface.RRuntimeError: Error in UseMethod("months") : no applicable method for 'months' applied to an object of class "c('integer', 'numeric')"*

From what I can tell, the line creating featureEEG is processed, and it is in the processing where the error occurs. Most of the message is understandable except for the part starting at the RRuntimeError. Could someone explain what it is saying? Or where can I find out?

Thank You.

1

1 Answers

0
votes

The RRuntimeError is reporting an error message generated by R.

Here it appears to try calling a generic months(). I am suspecting that ts in your code is not of the right type. The authors of eegAnalysis might be able to help.