0

I am new to R. I installed R with apt-get on ubuntu. I want to run a R script locally that connects to DB using RJDBC.

I am trying to install RJDBC package. I installed it with following steps

 R> install.packages("RJDBC")

It asked if I want to create personal directory I entered yes.

Now when I try library(RJDBC) in R script it gives me an error no such package found.

I am not installing RStudio. I want to simply create R script and run it with Rscript command. I installed Rscript for the same reason.

Am I missing something?

I'm using Ubuntu instance. Any help is greatly appreciated.

install.packages("/tmp/RtmpRgKgmc/downloaded_packages/txtplot_1.0-3.tar.gz", repos= NULL , type = "source")

Installing package into ‘/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)

> library('txtplot')
Error in library("txtplot") : there is no package called ‘txtplot’
> 

UPDATE:

I have been trying it for hours now. But its not installing any package. I am on Ubuntu 14.04 and after installation it is installing R 3.0.2 version.

I ran below on R console. But it never installs it. Just downloads packages into temp folder.

trying URL 'http://cran.cnr.berkeley.edu/src/contrib/plumber_0.4.6.tar.gz'
Content type 'application/x-gzip' length 83174 bytes (81 Kb)
opened URL
==================================================
downloaded 81 Kb


The downloaded source packages are in
    ‘/tmp/RtmppYMbcW/downloaded_packages’

What Do I do next?

I followed installation steps from here. https://medium.com/@GalarnykMichael/install-r-and-rstudio-on-ubuntu-12-04-14-04-16-04-b6b3107f7779

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 1
    Did you see any error messages? Try installing the package again, and copy the output of the command in your question. – Scott Ritchie Nov 15 '18 at 14:58
  • @ScottRitchie added –  Nov 15 '18 at 15:24
  • There has probably been an error during the installation; You may have seen something like ["installation of... had non-zero exit status"](https://stackoverflow.com/q/27893230/4770166). If you post the output of that error message it may be possible to help. – RHertel Nov 15 '18 at 15:25
  • @Pat Your edit does not contain the complete / relevant part of the output. – RHertel Nov 15 '18 at 15:26
  • @RHertel I opened R console and typed `library()` I could see base packages installed. After that I did the above. After above steps I run library() again it gives me nothing except warning. –  Nov 15 '18 at 15:28
  • @RHertel I didnt get to that output yet. I am trying to run library() on R console but not getting normal output itself for function call. just above warning statement –  Nov 15 '18 at 16:11
  • @Pat how did you install R out of curiosity? – Scott Ritchie Nov 15 '18 at 17:13
  • @ScottRitchie `sudo apt-get -y install r-base` –  Nov 15 '18 at 17:23
  • It is strange that there is no error message and no output concerning the success of the installation of the package. Perhaps you could check if all the usual compilers are installed on your linux system (g++, gfortran, gcc). – RHertel Nov 16 '18 at 09:44
  • @RHertel I was able to fix it. I installed it on Ubuntu 18 strangely it didnt work at all for 14. Thank you so much for following up on the question. –  Nov 16 '18 at 13:45

1 Answers1

0

Try this to choose the installation path of the library (where my_user is your user, 3.4 the version of R, my_package is your package. Repos is optional)

install.packages('mypackage',
      lib='/home/my_user/R/x86_64-pc-linux-gnu-library/3.4',
      repos='http://cran.rstudio.com/'
)

And this to add this path at the top of your R source

.libPaths(c(
    .libPaths(),
    "/home/my_user/R/x86_64-pc-linux-gnu-library/3.4/"
))

If you use Shiny you may have to edit the file /etc/R/Renviron with R_LIBS_SITE or R_LIBS_USER in the file something like to R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}. This for packages not optional for Shiny Server. For the others they could stay in your home user.

phili_b
  • 885
  • 9
  • 27
  • Thanks phili. I am not using Rstudio / shiny. I want only R and some R packages. Wanted to run R code directly without R studio –  Nov 15 '18 at 15:25
  • Except the last paragraph all I've said could be, and have to be, typed in simple R environment. – phili_b Nov 15 '18 at 18:49