I’m trying to use reticulate to run some simple Python code in an RMarkdown document. I’ve found that if Matplotlib is in the conda environment, I get errors when trying to run a python code chunk, but I can run Python from R directly. Here’s a simple example of what I see: My first thought was that reticulate was not
Tag: r
Is there a hypergeometric function in python?
Is there any module/function in python that supply the same functionality as the Hypergeometric Function in R? (dhyper, phyper, qhyper, rhyper)- docs for the function in R Answer Looks like this is implement in scipy. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hypergeom.html
For loop is several times faster in R than in Python using the rpy2 library
The following simply for block takes about ~3 sec to complete in R: The same code run in Python through the rpy2 library takes between 4-5 times more: Is this just because I’m using the rpy2 library to communicate with R or is there something else at play? Can this be improved in any way (while still running the code
Index Pandas Dataframe mixing row number and column name
Coming from R and finding the index rules for pandas dataframes to be not easy to use. I have a dataframe where I want to get the ith row and some columns by their names. I can clearly understand using either iloc or loc as shown below. Conceptually what I want is something like: Meaning the first row with those
Getting word count of doc/docx files in R
I have a stream of doc/docx documents that I need to get the word count of. The procedure so far is to manually open the document and write down the word count offered by MS Word itself, and I am trying to automate it using R. This is what I tried: Unfortunately, wordCount is NOT what MS Word suggests. For
“How to consolidate Values present in Unique Rownames” and add a row containing their Sum
I want to append 2 Rows (Yes/No) for Each Unique Session name. Eg: Take 1st Session I want to Add 2 Rows Yes and No which comprises of values as stated below Yes -> “On Duty + Attended + Online Prescence” => 25+30+40 = 95 No -> “Did Not Attend => 10. Is there any way to do it in
How to import r-packages in Python
I’m a bit troubled with a simple thing. I was trying to install a package called hunspell, but I discovered it is originally an R package. I installed this version: https://anaconda.org/conda-forge/r-hunspell, but I’m not being able to import it. Is this package supposed to work with Python? Should I use rpy2 to import it? First time using cross-platform packages so
R reticulate libstdc++so GLIBCXX_3.4.21 not found issue
I was trying to use pandas from R . I used the reticulate library for the same. The sample code I used is given below library(reticulate) use_condaenv(“my_env_37”,required=T) py_discover_config() py_run_string(“import pandas as pd”) Error Output from py_discover_config() Conda version : 4.6.8 Python Version : 3.6.8 Pandas Version : 0.24.2 OS: RHEL 7.4 R Version : 3.5.1 reticulate Version : 1.9 Is
%% Cell magic tag not working in Jupyter notebook?
I’m new to Jupyter notebook and I’m trying to set one up with Python and R, using rpy2. I have the line which gives me the error SyntaxError: invalid syntax However when I use just one %, such as this works fine. How can I fix this issue? I am using Python 2.7. Answer % prefix is for a line
How to plot (inline) with rpy2 in Jupyter notebook?
I’m learning to use rpy2 in Jupyter notebook. I’m having troubles with the plotting. When I use this example from the rpy2 docs for interactive work: Jupyter opens a new window with the plot. The window “title” reads: R Graphics: Device 2 (ACTIVE) (Not Responding). My Jupyter kernel is active. When I try to close the window with the plot,