Show More
@@ -83,11 +83,9 b' def Rconverter(Robj, dataframe=False):' | |||
|
83 | 83 | rownames = ro.r('rownames') # with pandas, these could be used for the index |
|
84 | 84 | names = ro.r('names') |
|
85 | 85 | |
|
86 | ||
|
87 | 86 | if dataframe: |
|
88 | 87 | as_data_frame = ro.r('as.data.frame') |
|
89 | 88 | cols = colnames(Robj) |
|
90 | rows = rownames(Robj) | |
|
91 | 89 | _names = names(Robj) |
|
92 | 90 | if cols != ri.NULL: |
|
93 | 91 | Robj = as_data_frame(Robj) |
@@ -336,7 +334,9 b' class RMagics(Magics):' | |||
|
336 | 334 | |
|
337 | 335 | In line mode, this will evaluate an expression and convert the returned value to a Python object. |
|
338 | 336 | The return value is determined by rpy2's behaviour of returning the result of evaluating the |
|
339 | final line. Multiple R lines can be executed by joining them with semicolons:: | |
|
337 | final line. | |
|
338 | ||
|
339 | Multiple R lines can be executed by joining them with semicolons:: | |
|
340 | 340 | |
|
341 | 341 | In [9]: %R X=c(1,4,5,7); sd(X); mean(X) |
|
342 | 342 | Out[9]: array([ 4.25]) |
@@ -398,8 +398,11 b' class RMagics(Magics):' | |||
|
398 | 398 | * If the final line results in a NULL value when evaluated |
|
399 | 399 | by rpy2, then None is returned. |
|
400 | 400 | |
|
401 | The --dataframe argument will return structured arrays | |
|
402 | from dataframes in R. This is useful for dataframes with | |
|
401 | * No attempt is made to convert the final value to a structured array. | |
|
402 | Use the --dataframe flag or %Rget to push / return a structured array. | |
|
403 | ||
|
404 | The --dataframe argument will attempt to return structured arrays. | |
|
405 | This is useful for dataframes with | |
|
403 | 406 | mixed data types. Note also that for a data.frame, |
|
404 | 407 | if it is returned as an ndarray, it is transposed:: |
|
405 | 408 | |
@@ -427,9 +430,8 b' class RMagics(Magics):' | |||
|
427 | 430 | array([(1, 2.9, 'a'), (2, 3.5, 'b'), (3, 2.1, 'c'), (4, 5.0, 'e')], |
|
428 | 431 | dtype=[('x', '<i4'), ('y', '<f8'), ('z', '|S1')]) |
|
429 | 432 | |
|
430 |
The --dataframe argument first tries colnames, then |
|
|
431 |
If |
|
|
432 | ||
|
433 | The --dataframe argument first tries colnames, then names. | |
|
434 | If both are NULL, it returns an ndarray (i.e. unstructured):: | |
|
433 | 435 | |
|
434 | 436 | In [1]: %R mydata=c(4,6,8.3); NULL |
|
435 | 437 | |
@@ -452,7 +454,6 b' class RMagics(Magics):' | |||
|
452 | 454 | In [8]: mydata |
|
453 | 455 | Out[8]: array([ 4. , 6. , 8.3]) |
|
454 | 456 | |
|
455 | ||
|
456 | 457 | ''' |
|
457 | 458 | |
|
458 | 459 | args = parse_argstring(self.R, line) |
General Comments 0
You need to be logged in to leave comments.
Login now