unexpected input in "%load_ext rpy2.ipython" in R - ipython - r

I am new to R and trying to execute the code in this site but unfortunately, I am experiencing this error "Error: unexpected input in "%load_ext rpy2.ipython"" when entering "%load_ext rpy2.ipython" in the R console and I tried searching google for answers but no luck.
Any help would be appreciated. Thank you in advance.

rpy2.ipython is an extension for ipython, and Jupyter, when you use the IPython kernel. Not for R. What you linked to is using IPython and calling into R from IPython, not calling in Python from within R. Not sure why they do that in what you linked, from a quick read they should use a R kernel, which would work without saying %%R each time.
So you should be able to reproduce what's there by not loading the rpy2 magic, skipping the %%R prefixes.
If you want to reproduce exactly you will need to install IPython/jupyter and run the code from the Python console.

Related

Problem with mismatched perl binaries using system2 command

I am trying to run an executable script from within RStudio. The script runs perfectly from Terminal, however, when trying to run it form within R I get the following error message:
setwd("/users/admin")
command <- "/users/admin/Test_script.command"
system2(command)
> lib/Bio/DB/HTS/Faidx.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed 0xc500080)
I am running MacOS X Big Sur and I use perlbrew with perl version 5.26.2, I guess the problem is that RStudio tries to use my system perl version - but I couldn't find a way to change that…
Any ideas? Thanks!
I found a way to get it running by looking into the actual script, which is perl based. Then I was able to solve the problem by following the answer to https://stackoverflow.com/a/65553736/4253357 as Michal suggested. Thanks again for your help!

R CMD Check does not finish the step "Checking PDF version of manual ..."

I am creating an R package using R Studio version 0.99.489 together with the most current R development version on Windows 7. I created documentation .Rd files using roxygen2 and a .Rmd vignette using knitr. Until now everything worked out fine, but when I run the R CMD check within RStudio, the check gets stuck at the step "Checking PDF version of manual ...". I neither get an "OK" nor any error or warnings message. The step just does not proceed, even if I run it over night. I do not get any error or warning messages for the other steps as well, I have "OK"s everywhere.
Consequently, I do not find a PDF manual in the package.Rcheck folder. I already created the manual myself using R CMD Rd2pdf package, which worked out fine. I copied it to several locations within the package folder but this did not help at all.
I searched really a lot but I could not find any solution for this since I do not get any error message. I thought about administration, latex, or R version problems, but I cannot figure out if it is any of those or something else.
One thing I recognized is that when the package is build, it prints out:
CMD build "..PATH...\package" --no-resave-data \ --no-manual
although I did not specify the --no-manual option in the Build options from RStudio. Additionally, I did not find a way to change this. Might this be the problem?
Can anyone help me with this? I would really appreciate any hints. Please let me know if you need any output or any other information from me.
Thanks!
You could do it yourself using:
shell('R CMD Rd2pdf . --output=man/figures/manual.pdf --force --no-preview')
This will create the PDF and save it to yourpackage/man/figures/manual.pdf.
I use it, so I know it works before I send it to CRAN.
I faced the same problem. It was really frustrating that it didn't give any error message. But then I tried this:
install.packages("devtools")
Actually I don't really know how it works, but I guess it also install other requirements and now the checking process is done via devtools and not directly by roxygen2. Hope it helps.
I also come across with this problem, which I think it's a bug of RStudio. Try R CMD check <YOUR PROJECT NAME> in terminal, in my case, it finally generates an error,
* checking PDF version of manual without hyperrefs or index ... ERROR
Re-running with no redirection of stdout/stderr.

Kernel loading forever in jupyter notebook

I'm using OSX Yosemite.
I've update ipython via conda and turns out notebook also has updated version, which I'm very excited to try this.The notebook has been converted into jupyter.
I'm using python 2.X, and already have existing .ipynb files. When I open it, new window appears but there's blank and nothing. I can create first cell there, but I already have my notebook. And the kernel also loading forever. There isn't any error log in the console. What do I have to do? Please help!
Nevermind, this solve the problem https://github.com/ipython/ipython/issues/5746
I'm using ccp notebook extension, and as Ian Hawke mentioned in the thread, remove the call to the extention at profile/static/custom/custom.js

Running the R console from Sublime Text 2

I am quite new with Sublime Text 2. I would like to write my script in ST2 and run/send it to the R console. I don't want to use SublimeREPL (most of the forums deal with this) because I want to have my R console open on the side.
I tried to install "R Tools" and the installation of this package seems to work. However, when I open my script.r file and try to run it, nothing happens. I also tried to specify the path to go to R in TOols>Build systems> new build systems... withou being successful.
Can someone give me a trick to solve this?
Thanks a lot!
The easiest way is to install the Enhanced-R package via the Package Manager in Sublime:
Install the Package Control here
Access the Package Manager within Sublime (on Windows: Ctrl+Shift+P)
Type Install Package and then Enhanced-R
Send the highlighted code to R console (on Windows: Ctr+Enter)
You can see the Enhanced-R package description and relevant key bindings here
I just stumbled upon this post because I had a similar problem using Sublime and R. Maybe this helps someone who wants to have a similar setup. Hopefully there will be more and more R users considering Sublime. I figured out the following solution using the Sublime build system in an external xterm terminal (for Linux, but it should be very similar to a setup on Win/Mac systems):
Sublime Text 3 build system: keep console running

Start R with commands R Studio

I use RStudio, it's fantastic. Recent adjustments to my BLAS installation, however, require me to start R with the command
taskset 0xffff R
To get parallel processing to work. Is there a way tell RStudio to start it's R session with this command so I can use RStudio with parallel?
(I know parallel and GUI's don't play that nice)
Thanks.
EDIT: I'm running kUbuntu.
You should be able to do this by customizing your Rprofile.site file, as described here:
http://www.statmethods.net/interface/customizing.html

Resources