This message was deleted.
# ask-anything
s
This message was deleted.
🙌 2
e
do you mean the template task? Currently no, we added it to facilitate the concept explanation for new users @Jess Mankewitz (they/she) has been doing a lot of stuff with R. 😀 but I'm unsure if she has experience mixing R and Python. I also did a bit of this successfully, I was using parquet to allow R/Python interoperability. since you can install the R interpreter and R packages with conda-forge, you can declare a single environment.yml to document all your dependencies. please share your experience with us!
j
Hi! I have a project that switches seamlessly between my python scripts and my r scripts using ploomber and conda as the “glue”. The main quirk we experienced were needing to initialize our conda environment with both R and Python. We’ve also had some conda troubles when switching machines, but we think that was a conda problem not a ploomber problem.
👍 1
We havent tried e.g. using magic cells in a jupyter notebook to switch between R and Python in the same jupyter nb but we may need to in the future when we start generating our plots + switching to ggplot in the same analysis
👍 1
🙏 1
e
thanks for sharing your experience! for solving thr problem when switching machines. have you tried
conda env export --no-build > environment.yml
? this will produce a portable yml file that you can use to re-create environments on other machines
👍 1
i
@Jess Mankewitz (they/she) is there a use case of running both R and python in the same notebook with magics?
j
in my very humble opinion, not really lol but some of my collaborators like to do exploratory modeling and on-the-fly plotting in the same notebook
we also heavily use some r packages/api for some of our datasets (shameless plug for https://github.com/langcog/childesr and https://github.com/langcog/wordbankr), though im working on porting some over to python (even more shameless plug for https://github.com/langcog/childespy) so its nice to pull the data in R, do our more ML adjacent stuff in python, and then report the results in R
m
So you have a separate environment.yml for conda. What d u use for R environment management and how does it blend together in the env.yml of conda? I.e. How does your project set up look like? I mean the following:
Copy code
Conda env create ... 
Pip install -e
j
yeah we have a .yml for our conda environment that has both r and python like…
Copy code
name: proj_pipeline
channels:
  - conda-forge
  - defaults
dependencies:
  - ploomber=0.19.4
  - python=3.8.13
  - r-base=4.0.5
m
If u have specific r libraries where d u put them? Just r-.... ?
j
for most of them! we have some that arent on forge. in that case, our full setup commands are
Copy code
conda env create -f proj_pipeline.yml

conda activate proj_pipeline
ploomber scaffold --entry-point pipeline.preprocessing.yaml
ploomber scaffold --entry-point pipeline.modeling.yaml
#install childesr in R, not conda
R
install.packages(c("childesr", "dclone"))  # mirror 76

#setup the nltk
python
import nltk
nltk.download('wordnet')
nltk.download('omw-1.4')
nltk.download('semcor')
m
And can you conda export the complete .yml including the specific packages or r?
j
so we enter R from within our conda environment and install the non-conda R packages manually
m
I see. Not the neatest solution but it works.
j
I dont think so, i think conda export skips over the non-conda packages?
i havent checked in a while
either way theyd fail to install because theyd search on forge and not find them
we’ve considered doing some work for our R packages and adding them to conda forge, but we cant do anything for other folks (like dclone)
m
I LL have to try and play around with this. Perhaps, R has very different idea on how reproducible environments should be done. I wonder if this mixing is a good idea or just trouble waiting to happen. For me even just pure conda often fails to keep reproducible env.
j
yeah there are some reproducibility focused R packages, but they all function within R and dont play nice with conda
m
so u do not mix conda + renv for the underlying R