0

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 !

Community
  • 1
  • 1
vagabond
  • 3,526
  • 5
  • 43
  • 76
  • @dirk.eddelbuettel Do you want to get in on this since you're one of the contributors? – Hack-R Jul 18 '16 at 03:01
  • Please also consider [contacting the package authors](http://dirk.eddelbuettel.com/code/rpostgresql.html) and perhaps [filing an issue](https://code.google.com/archive/p/rpostgresql/) (though that page looks rather inactive) in case you think your adjustment could benefit other users without breaking current functionality. – MichaelChirico Jul 18 '16 at 18:24
  • honestly I'm not advanced enough to know that but @dirk.eddelbuettel is one of the contributors to `RPostgreSQL` and he has been tagged. – vagabond Jul 18 '16 at 18:36

1 Answers1

2
  1. Copy the pacakge .tar.gz file to the AWS machine.
  2. Unpack this file so you have a directory structure.
  3. Edit the function inside the file and save your changes.
  4. You may also have to increase the version number in the DESCRIPTION file.
  5. Use devtools::build to create a new .tar.gz file.
  6. Install this updated version of the package.
Richie Cotton
  • 118,240
  • 47
  • 247
  • 360