Names = make.names(names, unique=TRUE, allow_=TRUE)Ĭolnames(iris) = dbSafeNames(colnames(iris)) Here’s a function to make the column names db safe: # make names db safe: no '.' or other illegal characters, The column names of this data frame are problematic for databases (and especially PostgreSQL) for a few reasons: the “.”s in the names can be an issue, and PostgreSQL expects column names to be all lowercase. # Sepal.Length Sepal.Width Petal.Length Petal.Width First, let’s create a data frame that we want to insert into the database. Now you want to work with the data in that database in R.
You have your PostgresSQL database up and running. If you happen to be on a Mac, then Postgres.app provides a “serverless” (or application oriented) install option.įor the rest of this post, we give a quick how-to on using the RpostgreSQL package to interact with Postgres databases in R.
To get PostgreSQL for Windows, OSX, or Unix use the instructions at PostgreSQL downloads. We assume for this how-to that you already have a PostgreSQL database up and running.