dict_py= {"A":[4, 2, 5, 3], "B":[5, 2], "C":[6, 3, 2, 5, 5]}
···{'A': [4, 2, 5, 3], 'B': [5, 2], 'C': [6, 3, 2, 5, 5]}
import rpy2.robjects as robjects
x = robjects.ListVector( [(str(e), dict_py[e]) for i, e in enumerate(dict_py)] )
r = robjects.r('''
func <- function(List){
list.r <- list()
for (i in names(List)) {
list.r[[i]] <-unlist(List[[i]])
}
print(list.r)
}
''')
r(x)
···$A
···[1] 4 2 5 3
···$B
···[1] 5 2
···$C
···[1] 6 3 2 5 5
网友评论