Short question: I want to edit the postgresqlWriteTable function in the RPostgreSQL package and install it on R running on an Ubuntu machine.
Long explanation:
The root of my problem is that I am trying to write to a postgres table with an auto-incrementing primary key column from R using dbWriteTable from RPostgreSQL package.
I read this post: How do I write data from R to PostgreSQL tables with an autoincrementing primary key? which suggested a fix to my problem by changing the function postgresqlWriteTable in the RPostgreSQL package. It works when I interactively use fixInNamespace in OSX environment and edit the function.
Unfortunately I have to run my script on an AWS instance running R on Ubuntu. I have RPostgreSQL installed at this location on my machine: /usr/local/lib/R/site-library/RPostgreSQL . I installed it by invoking R CMD install RPostgreSQL_0.4-1.tar.gz
Now I am trying to find the function postgresqlWriteTable. It is supposed to be in the file PostgreSQLSupport.R . I have searched the whole library - there is no such file.
I realized that on my local machine in the OSX Finder , when I unzip the tar.gz package folder, I can see the file PostgreSQLSupport.R where I am supposed to change the function.
So I changed the function. Then I removed the installed RPostgreSQL from my Ubuntu machine and copied the new folder (from my local machine) into my Ubuntu machine and tried to use devtools to install the package as suggested in the post here: Loading an R Package from a Custom directory
here's what happened:
> library("devtools")
> install("/usr/local/lib/R/site-library/RPostgreSQL")
Error: Can't find '/usr/local/lib/R/site-library/RPostgreSQL'.
> install("RPostgreSQL", "/usr/local/lib/R/site-library/RPostgreSQL")
Installing RPostgreSQL
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet \
CMD INSTALL '/datasci/nikhil/RPostgreSQL' \
--library='/usr/local/lib/R/site-library' --install-tests
* installing *source* package ‘RPostgreSQL’ ...
file ‘R/PostgreSQLSupport.R’ has the wrong MD5 checksum
ERROR: 'configure' exists but is not executable -- see the 'R Installation and Administration Manual'
* removing ‘/usr/local/lib/R/site-library/RPostgreSQL’
Error: Command failed (1)
I am at my wit's end !
Copy the pacakge .tar.gz file to the AWS machine.
Unpack this file so you have a directory structure.
Edit the function inside the file and save your changes.
You may also have to increase the version number in the DESCRIPTION file.
Use devtools::build to create a new .tar.gz file.
Install this updated version of the package.
Related
I am trying to install package SBCK from R build using Rscript build.R -c -v -i in windows command prompt following the steps given here. However, I ended up with package SBCK being not installed because of following error/warning InstallationWarning: package 'SBCK' is in use and will not be installed. I have no package with name SBCK installed on my system, so I do not understand why I am getting this warning message and thus not to be able to install the R package.
I know that similar question have been asked before here but solution there does not work in my case.
I am using R version 4.2.0 on Windows 10.
Once 'build.R' is run, "SBCK_0.5.0.tar.gz" is created in the 'SBCK-R' folder.
You can now install it via the package archive file option or pointing to that file in the install.packages command. I faced the same issue and this solved it.
I'm trying to install an R package called "ncdf4".
I've tried installing it in the "packages" section in the R-studio interface, but have also tried entering install.packages("ncdf4") into the console.
This is the output I get in both instances:
Installing package into ‘/home/user/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/ncdf4_1.17.tar.gz'
Content type 'application/x-gzip' length 124458 bytes (121 KB)
==================================================
downloaded 121 KB
* installing *source* package ‘ncdf4’ ...
** package ‘ncdf4’ successfully unpacked and MD5 sums checked
** using staged installation
configure.ac: starting
checking for nc-config... no
-----------------------------------------------------------------------------------
Error, nc-config not found or not executable. This is a script that comes with the
netcdf library, version 4.1-beta2 or later, and must be present for configuration
to succeed.
If you installed the netcdf library (and nc-config) in a standard location, nc-config
should be found automatically. Otherwise, you can specify the full path and name of
the nc-config script by passing the --with-nc-config=/full/path/nc-config argument
flag to the configure script. For example:
./configure --with-nc-config=/sw/dist/netcdf4/bin/nc-config
Special note for R users:
-------------------------
To pass the configure flag to R, use something like this:
R CMD INSTALL --configure-args="--with-nc-config=/home/joe/bin/nc-config" ncdf4
where you should replace /home/joe/bin etc. with the location where you have
installed the nc-config script that came with the netcdf 4 distribution.
-----------------------------------------------------------------------------------
ERROR: configuration failed for package ‘ncdf4’
* removing ‘/home/user/R/x86_64-pc-linux-gnu-library/3.6/ncdf4’
Warning in install.packages :
installation of package ‘ncdf4’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpXcbO2y/downloaded_packages’
Is anybody able to decipher what went wrong from the code that I've provided?
Thanks.
I am using Ubuntu 20.4 and ran into the same problem.
Step 1: in the terminal
sudo apt-get update -y
Step 2: in the terminal
sudo apt-get install -y libnetcdf-dev
Step 3: in rstudio
install.packages("ncdf4")
After that ncdf4 was installed successfully
Reference:
https://zoomadmin.com/HowToInstall/UbuntuPackage/libnetcdf-dev
I finally managed to install ncdf4.
I read a similar problem here:
https://r.789695.n4.nabble.com/Problem-installing-ncdf-library-td4646986.html
I installed all the libnetcdf packages in the linux terminal by typing:
sudo apt install libnetcdf-*
If you are running Ubuntu18.04 or a derived version of it, you can look for the library netcdf4.1 by doing:
sudo apt-cache search libnetcdf
In my session (Linux Mint), I get:
libnetcdf-c++4 - legacy NetCDF C++ interface
libnetcdf-c++4-1 - C++ interface for scientific data access to large binary data
libnetcdf-c++4-dbg - debugging symbols for NetCDF C++
libnetcdf-c++4-dev - creation, access, and sharing of scientific data in C++
libnetcdf-c++4-doc - NetCDF C++ API documentation
libnetcdf-cxx-legacy-dbg - debugging symbols for legacy NetCDF C++ interface
libnetcdf-cxx-legacy-dev - legacy NetCDF C++ interface - development files
libnetcdf-dev - creation, access, and sharing of scientific data
libnetcdf13 - Interface for scientific data access to large binary data
libnetcdff-dbg - debugging symbols for NetCDF Fortran
libnetcdff-dev - creation, access, and sharing of scientific data in Fortran
libnetcdff-doc - NetCDF Fortran documentation
libnetcdff6 - Fortran interface for scientific data access to large binary data
So, installing the libnetcdf-c++4-1 should solve your issue:
sudo apt-get update
sudo apt-get install libnetcdf-c++4-1
Does it answer your question ?
For Arch Linux users, you probably haven't installed netcdf. You can use pacman to install netcdf
sudo pacman -S netcdf
just install netcdf via apt
apt-get install libnetcdf-dev
it worked for me (ubuntu 20.04 and R 4)
For reasons that are too long to explain here, I must use R.2.8.1 (unfortunately). I need to have the xlsx package installed on it. Since I am on R 2.8.1, about ten years old, I can't use the latest version of xlsx but an older version, for instance xlsx_0.1.3 from 2010 seems a good choice. However the previous releases per R-CRAN policy are only available in tar.gz.
This is very unfortunate to me because I have to use RGui on windows which only accepts .Zip packages in installation. Therefore I tried the following stuff, in vain:
1-I tried to use Rcmd but I get the following error message:
C:\Program Files (x86)\R\R-2.8.1\bin>Rcmd INSTALL C:\Users\username\Downloads\xlsx_0.1.3.tar.gz
Can't use 'defined(#array)' (Maybe you should just omit the defined()?) at C:\PROGRA~2\R\R-28~1.1/bin/INSTALL line 42.
so I give up on this one.
2-Then I think that the best solution is to convert the package xlsx_0.1.3.tar.gz into a compatible xlsx_0.1.3.zip package by building it using R.2.8.1 but I can't make it. Here is one of the things I have tried so far.
I have unziped xlsx_0.1.3.tar.gz and I organized it in the following way, which brought me the furthest:
Documents\xlsx
Documents\xlsx\activate.bat
Documents\xlsx\build_xlsx.bat
Documents\xlsx\R
Documents\xlsx\R\inst
Documents\xlsx\R\man
Documents\xlsx\R\other
Documents\xlsx\R\R
Documents\xlsx\R\DESCRIPTION
Documents\xlsx\R\NAMESPACE
Documents\xlsx\R\NEWS
Documents\xlsx\R\WISHLIST
inside activate.bat, I wrote:
SET TMP=C:\Users\username\Documents\TOTO\xlsx\tmp
SET TEMP=%TMP%
SET RTOOLSPATH=C:\DEV_307\toto\Rtools
SET RPATH=C:\DEV\toto\R\R-2.8.1
SET PATH=%RTOOLSPATH%\bin;%RTOOLSPATH%\MinGW\bin;%RPATH%\bin;%PATH%
inside build_xlsx.bat, I wrote:
R CMD BUILD R
R CMD check --no-examples --no-tests R
R CMD build --docs=normal --binary R
Then I still get:
C:\Users\username\Documents\TOTO\xlsx>R CMD BUILD R
* checking for file 'R/DESCRIPTION' ... OK
* preparing 'R':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
Can't use 'defined(#array)' (Maybe you should just omit the defined()?) at C:\DEV\toto\R\R-2.8.1/bin/INSTALL line 42.
ERROR
Installation failed.
Removing 'C:/Users/username/Documents/Rinst1210839349'
Thank you for your help
I can't include structured content in comments. This is really a comment.
The structure of source packages (which is what you have with xlsx_0.1.3.tar.gz if you pulled it from the CRAN archives) hasn't changed (much) since 2.8.1.
You'll also need to grab rJava_0.8-3.tar.gz and xlsxjars_0.2.0.tar.gz from the archive as xlsxjars + xlsx rely on rJava.
Extract each (since Windows R 2.8.1 seems to not grok gz files). They should make rJava, xlsxjars and xlsx directories each.
Move to the parent directory of both.
Run:
R CMD javareconf
R CMD build rJava
R CMD INSTALL rJava_0.8-3.zip # I believe this will be the name
R CMD build xlsxjars
R CMD INSTALL xlsxjars_0.2.0.zip
R CMD build xlsx
R CMD INSTALL xlsx_0.1.3.zip
and you should be gtg.
I've been having trouble downloading the shinyapps package on my windows computer. I've updated my versions of R and studio, tried the devtools download devtools::install_github('rstudio/shinyapps') and I've also tried the manual download of the shinyapps-master.zip (github.com/rstudio/shinyapps/archive/master.zip) and using install_local() all to no avail.
Here is the error I get with each method:
Installing shinyapps
"C:/Program Files/R/R-3.1.1/bin/i386/R" --vanilla CMD INSTALL \
"C:\Users\MyName\AppData\Local\Temp\Rtmpma2fl1\devtools10cc1745fe7\shinyapps-master" \
--library="C:/Program Files/R/R-3.1.1/library" --install-tests
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed (1)
After doing the excellent tutorial for shiny I would love to be able to use shinyapps.io but can't so far due to this. Any ideas? Much appreciated!
The app does not like the fact that R is installed in a directory that includes a space. I recommend reinstalling R to a location without a space, e.g. c:/R/.
I got a similar problem. I deleted the shinyapp folder first and then the file with that name. All my packages are saved in ~/Documents/R/win-library/3.1 folder on Windows 7 PC as I have not specified the lib folder. Then I installed the shinyapps package again using devtools::install_github('rstudio/shinyapps') command in R. HTH
This question already has answers here:
Cannot install R-forge package using install.packages
(4 answers)
Closed 8 years ago.
I am not able to install the Vennerable R package from https://r-forge.r-project.org/projects/vennerable/ on my Windows 7 with newest R (2.13.0).
I tried following:
installed from RGui and selecting R-Forge repos:
there was no Vennerable package in the list
installed from RGui using "install package from local zip file":
can not open compressed file 'Vennerable.tar.gz/DESCRIPTION'
converted tar.gz into zip and installed from RGui using "install package from local zip file":
can not open compressed file 'Vennerable.tar.gz/DESCRIPTION'
tried manual install: install.packages("D:/Downloads/Vennerable.tar.gz", repos = NULL)
can not open compressed file 'Vennerable.tar.gz/DESCRIPTION'
Error in install.packages : cannot open the connection
Note: there is a file DESCRIPTION.
What should I do to install this package?
Links on package page are dead (to either Windows build and package source).
You can checkout the source: open the terminal and run the following command
svn checkout svn://svn.r-forge.r-project.org/svnroot/vennerable
Then build without vignettes.
cd vennerable/pkg
R CMD build Vennerable/ --no-build-vignettes
and finally to install it:
R CMD INSTALL Vennerable_3.0.tar.gz
(Your build might be in a different name than Vennerable_3.0.tar.gz).
For me it generated the following error:
ERROR: dependencies ‘graph’, ‘RBGL’, ‘xtable’ are not available for package ‘Vennerable’
Then I had to go to R, run the following command:
install.packages(c("graph", "RBGL", "xtable"))
and then go back to the terminal and run the R CMD INSTALL ... command again.
Vennerable package has been updated and now version 2.1 is available from R-forge using
install.packages("Vennerable", repos="http://R-Forge.R-project.org")
I had the same problem and figured it out. The issue was with how the package is archived. There is a directory called 'Vennerable' within the top level directory which is called "Vennerable_2.2'. I unzipped the archive. Then I navigated to the 'Vennerable' subdirectory, and zipped that. Then I ran the installation using the new 'Vennerable.zip' archive. Worked like a charm.
If you have a tar.gz archive, you likely have the package's source files. You must build it first before installing the package. See section 1.3 of the Writing R Extensions manual
See also your other related question, where I provided this link to the built package for R 2.13.0 x86_64:
http://commondatastorage.googleapis.com/jthetzel-public/Vennerable_1.1.1.1.zip