![]() In the below example, we insert a new row of data into the trial-db table in the database using `dbExecute(). We can insert new rows into existing tables using: # 10 20 social tablet false 2 1 28 Namibia # 9 19 social tablet false 7 10 290 Colombia # 6 16 bing laptop true 1 1 995 United States # 4 14 yahoo tablet false 5 8 80 Philippines # 3 13 direct mobile false 9 14 406 Ireland # 2 12 direct tablet false 6 12 132 Estonia # 1 11 direct laptop true 9 1 738 Jamaica # 10 10 google mobile true 6 1 208 Czech Republic # 9 9 bing mobile false 3 19 209 Netherlands # 8 8 direct mobile true 10 1 908 Indonesia # 7 7 yahoo mobile true 10 1 75 Bangladesh # 6 6 yahoo laptop false 5 5 135 South Africa # 1 1 google laptop true 10 1 693 Czech Republic # id referrer device bouncers n_visit n_pages duration country Read Data in Batches query <- DBI::dbSendQuery(con, 'select * from ecom') Now that we know how to connect to a database and list the fields/columns, let us move on to the next section where we will learn how to query data from the tables present in the database. order_value: order value of visitor (in dollars).duration: time spent on the website (in seconds).device: device used to visit the website.referrer: referrer website/search engine.Let us take a look at the data dictionary to understand what these columns stand for: # "n_pages" "duration" "country" "purchase" "order_items" # "id" "referrer" "device" "bouncers" "n_visit" name of the table ( ecom) enclosed in single/double quotes.To list all the fields (columns) in a table, use dbListFields(). Let us go ahead and list all the fields/colums in the ecom table since we will be using it in the following sections. If you are using the RStudio Cloud project, we have already installed the packages in the project and you can just load them into the R session using library().Īs and when we come to the specific sections where we are using these packages, they will be reintroduced and we will look at their documentation and explore the functions we will use. In the R script we are sharing with you, we have commented out the code for installing the packages. If you do not have all the above packages installed, go ahead and install them. # install.packages(c("DBI", "dbplyr", "dplyr", "dbplot", "ggplot2", "modeldb", modeldb & tidypredict for modeling & prediction inside database.dbplot & ggplot2 for data visualization.Before we connect to and explore the local SQLite database, let us take a look at the R packages we will use in this post.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |