use rpy2
to call r in python, here is a demo, the numpy array data
is sharing memory with x
in R:
import rpy2.robjects as robjects
data = robjects.r("""
set.seed(1)
x <- runif(5)
""")
print np.array(data)
data[1] = 1.0
print robjects.r["x"]
More Related Contents:
- Binary random array with a specific proportion of ones?
- Working with floating point NumPy arrays for comparison and related operations
- Generate random array of floats between a range
- What are the advantages of NumPy over regular Python lists?
- ValueError: setting an array element with a sequence
- Numpy `logical_or` for more than two arguments
- What is the difference between contiguous and non-contiguous arrays?
- Quick way to upsample numpy array by nearest neighbor tiling [duplicate]
- Count consecutive occurences of values varying in length in a numpy array
- Concatenate two NumPy arrays vertically
- Getting the indices of several elements in a NumPy array at once
- How to create a density plot in matplotlib?
- How to do n-D distance and nearest neighbor calculations on numpy arrays
- How to conditionally combine two numpy arrays of the same shape
- How to specify upper and lower limits when using numpy.random.normal
- Numpy: efficient way to generate combinations from given ranges
- Subtracting numpy arrays of different shape efficiently
- Selecting close matches from one array based on another reference array
- Better way to shuffle two numpy arrays in unison
- Input and output numpy arrays to h5py
- Why does numpy have a corresponding function for many ndarray methods?
- Numpy sub-array assignment with advanced, mixed indexing
- Efficiently sorting a numpy array in descending order?
- Numpy: Divide each row by a vector element
- Setting the fmt option in numpy.savetxt
- Access n-th dimension in python [duplicate]
- Numpy shuffle multidimensional array by row only, keep column order unchanged
- Randomly select from numpy array
- How to “scale” a numpy array?
- Numpy `ValueError: operands could not be broadcast together with shape …`