Skip to content

Tag: r

Python from RMarkdown – Matplotlib problems

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 …

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

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 th…

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 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? Shoul…

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…