'how to use R-package in Python via rpy2?
I want to use an R-package called SimSpin:https://github.com/kateharborne/SimSpin in jupyter notebook (Python) to analyse simulation snapshots of galaxies. I have never used R, so I am using rpy2 to make use of SimSpin in python. I have a simulation snapshot called "SimSpin_example_Gadget.g2" and I want to analyse it the same way as given in examples of the SimSpin documentation:https://rpubs.com/kateharborne/713848
So, I want to transfer the following R code to python code using rpy2 and I need some help with that:
#load package (I guess this is similar to import in python)
library(SimSpin)
#input "SimSpin_example_Gadget" file into the function make_simspin_file.
gadget2_binary_galaxy = make_simspin_file(filename = system.file("extdata",
"SimSpin_example_Gadget",
package = "SimSpin"),
disk_age=5, bulge_age=10, # ages in Gyr
disk_Z=0.024, bulge_Z=0.001, # metallicities
template="BC03lr", # spectral template choice
**write_to_file = FALSE**) # output data to environment, rather than file
I mainly want to know how I can use this "make_simspin_file" R-function in python via rpy2. Any help is appreciated. Thanks a lot!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
