As part of my R workflow for one of my projects, I am loading data from a postgreSQL table located on a remote server.
My code looks like this (anonymous credentials).
First, I opened an ssh connection with a remote server in the terminal .
ssh -p Port -L LocalPort:IP:RemotePort servername"
Then I connect to the postgres database in R.
# Load the RPostgreSQL package library("RPostgreSQL")
This approach works fine, and I can upload data without any problems.
However, I would like to take the first step - i.e. create an ssh connection - in R, not in the terminal. Here is my attempt to do this with an accompanying error.
# Open the ssh connection in R system("ssh -T -p Port -L LocalPort:IP:RemotePort servername")
To clarify my question, I would like to complete this entire workflow (establish a connection, load postgreSQL data) completely in R without any steps in the terminal.
source share