Open inesltt opened 2 years ago
I managed to load the data from PostgreSQL using this code:
install.packages(c('DBI', 'RPostgres')) #installing relevant packages if you haven't already
library(DBI) #calling the necessary packages
library(RPostgres)
con <- DBI::dbConnect(
RPostgres::Postgres(),
dbname = 'assignment 1', #input name of DB where the file was uploaded
host = 'localhost',
port = 5432,
user = 'postgres', #input your username (it's probably postgres)
password = 'Helopanda16!') #lol pls don't hack into my stuff
dbListTables(con) #shows all the different tables which were uploaded in DB
propertylisting <- dbReadTable(con, "propertylistings") #reads the specific table in the DB we want, and converts it into a data frame
Some pretty helpful documentation I referred to:
let me know if this works!!
Another easier (in my opinion haha) method is to export the necessary files into a .csv format, then loading them into R!
To export the file (which our group already loaded into a database in DBeaver last week), right click the table > Export > select "CSV" as the Export target > Click next for everything (use the standard settings) > Click finish.
Then upload the .csv file into your working directory in R Studio cloud (in the bottom right box, click upload > Choose file to upload). And then input this code to read in the .csv file:
proplisting <- read.csv("propertylistings_202204011043.csv") #you can name the file sth other than proplisting of course
y
Thanks Shannon, but the second method doesn't work as well :):):) ;((((((
I managed to load the data from PostgreSQL using this code:
install.packages(c('DBI', 'RPostgres')) #installing relevant packages if you haven't already library(DBI) #calling the necessary packages library(RPostgres) con <- DBI::dbConnect( RPostgres::Postgres(), dbname = 'assignment 1', #input name of DB where the file was uploaded host = 'localhost', port = 5432, user = 'postgres', #input your username (it's probably postgres) password = 'Helopanda16!') #lol pls don't hack into my stuff dbListTables(con) #shows all the different tables which were uploaded in DB propertylisting <- dbReadTable(con, "propertylistings") #reads the specific table in the DB we want, and converts it into a data frame
Some pretty helpful documentation I referred to:
- https://www.rstudio.com/blog/working-with-databases-and-sql-in-rstudio/
- https://cran.r-project.org/web/packages/RPostgres/RPostgres.pdf
- https://nceas.github.io/oss-lessons/sql-database-access-in-r/sql-database-access-in-r.html
let me know if this works!!
@inesltt sorry for my late reply. Best is that you can allow me to have a close look into the problem --> I am OK for 30 minutes one-to-one discussion if you still face the issue.
Note that in Rcloud, sometimes the issue is with the server.
Hi Nam,
I'm facing some issues uploading files into my cloud directory; I receive an error message saying "Unexpected response from server". I've attempted to consult prof google and found tips to use either the wget or curl function, but alas, I am facing issues using them as well. Would appreciate your helP!!