wired transform

19 views
Skip to first unread message

yifan li

unread,
Jun 18, 2018, 11:29:45 AM6/18/18
to web2py-users
1. vector= robjects.FloatVector([4,3,2,2,1,2,4,5])
2. print("vector is: ",type(vector),vector)
3. cal = robjects.r('''
4.      vector
5.  '''
6. )
7. print('this is type of cal', type(cal()))

Hi all,

I have encountered a very strange problem. I was trying to pass a python float list into R code. In my example, I'm passing [4,3,2,2,1,2,4,5] to R code. My code is above. Before executing R code, the result of print statement on second line is my type of my vector is a float vector. However, after I execute R code from line 3 to line 6, I print the type of vector a again at line 7, the type of my vector becomes a Boolean vector. Does anyone know how can I solve this problem or how can I pass a vector into R? Thank you!

Best regards,
Yifan

Leonel Câmara

unread,
Jun 18, 2018, 5:46:02 PM6/18/18
to web2py-users
I'm guessing you're asking in the wrong group, and I don't really use R. I'm guessing the problem is:

cal = robjects.r(''vector'')

Which according to the rpy2 documentation I've looked at for the first time should probably be:

cal = robjects.r(''vector'')[0]
Reply all
Reply to author
Forward
0 new messages