I'm trying to use rpy2 to run the multi.split function from the questionr package.
this is my code
from rpy2 import robjects
from rpy2.robjects.packages import importr
questionr = importr(str('questionr'))
data = ["red/blue", "green", "red/green", "blue/red", "red/blue", "green", "red/green", "blue/red", "red/blue", "green", "red/green", "blue/red", "red/blue", "green", "red/green", "blue/red", "red/blue", "green"]
data_vector = robjects.StrVector(data)
multi_split = questionr.multi_split
data_table = multi_split(data_vector, split_char='/')
after the last line I'm getting the following error:
RRuntimeError: Error in `colnames<-`(`*tmp*`, value = c("c(\"red/blue\",_\"green\",_\"red/green\",_\"blue/red\",_\"red/blue\",_\"green\",_.blue", :
'names' attribute [4] must be the same length as the vector [3]
I think that it has something to do with the size of the vector that I'm sending because if I remove the last item
data = ["red/blue", "green", "red/green", "blue/red", "red/blue", "green", "red/green", "blue/red", "red/blue", "green", "red/green", "blue/red", "red/blue", "green", "red/green", "blue/red", "red/blue"]
and then run
data_vector = robjects.StrVector(data)
multi_split = questionr.multi_split
data_table = multi_split(data_vector, split_char='/')
I get no error message. also if I change the "split_char' var, for example:
data_table = multi_split(data_vector, split_char='.')
I get no error message, no matter with size of an array I'm sending.
I have tried to run the matching code directly in R (with R-Studio) it runs with not problems. Any ideas on how can I solve this issue?