Does the R plugin work?

In Xubuntu 20.10 I get the error

Installing package into `/usr/local/lib/R/site-library'
(as `lib' is unspecified)
Warning in install.packages(pack, repos = NULL, type = "source") :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Error: ERROR: no packages specified

Does anyone know how to make it work?
Edit: it could help, as someone in Hacker News says they want to try it :slight_smile:

R by default doesn’t utilize a personal library if it doesn’t exist (it won’t be in the paths), but when you attempt to install a package if the first library is found not writeable it will ask you to create a personal library at ~/R/%p-library/%v (e.g. ~/R/x86_64-pc-linux-gnu-library/4.0). If this directory exists, even if empty, R will pick it up.

The problem is that it tries to install the TeXmacs package in the system-wide library which is expected behavior if you’ve never installed any R package before. If you make the previous directory, it should fix it.

Alternatively, you can explicitly set a path to user library by setting R_LIBS_USER in ~/.Renviron. Either one of the previous, or if you don’t want extra folders in home

R_LIBS_USER=~/.local/lib/R

and then doing mkdir -p ~/.local/lib/R.

1 Like

Thanks, I have tested the solution with

R_LIBS_USER=~/.local/lib/R

and despite that there is still an error message

The following object is masked from `package:utils':

    ?

Error: ERROR: no packages specified

it is possible to enter commands and see the output—I am going to link to this answer in the HN thread.

Is this persistent error appearing everytime you start a session or only appears during first-time run?

I have opened two sessions so far and it appeared in both. It did not affect the commands that I tried but I tried a few simple ones.

A separate thing that would be good for the plugin would be to have the possibility to embed plots (maybe there is, but I did not yet investigate enough).
In the Python plugin as far as I know this is achieved by having the plot saved as pdf and then read into the document.
If we don’t know of any way of doing this I could report having embedded plots as a wish on the bug tracker in Savannah—and I would report the error message as well.

If you’re feeling adventurous you can try it in the experimental Jupyter plugin with the IRkernel :wink:

1 Like

The help for the R plugin shows that it should work in that plugin by using v():

The v() function can be used in order to include the contents of the R graphics window inside your worksheet.

Actually plots embedding works fine and the workflow is close to R console. After doing a plot as you say, a new window with the plot opens. For example

t=seq(0,10,0.1)
y=sin(t)
plot(t,y,type="l",xlab="t",ylab="sin(t)")

Then you can build it step-by-step, such as doing

title("sin(t)")
legend("bottomright",legend=c("sin(t)"),lty=1:2,cex=0.8)

After having your graph, you can embed it with

v()

You can close the window programmatically with

dev.off()

Edit: Oh, you found it.

1 Like

@jeroen found it, I did not make the effort of reading the help :slight_smile: