Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 180

Fetching Data Drom a Database

Оглавление

Once connected to the database, we can select and download the data that we will use for our analysis in R.

# Prepare the query for the database result <- dbSendQuery(myConnection, “SELECT * from tbl_students WHERE age > 33”) # fetch() will get us the results, it takes a parameter n, which # is the number of desired records. # Fetch all the records(with n = -1) and store it in a data frame. data <- fetch(result, n = -1)

The Big R-Book

Подняться наверх