-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathr_sql.Rmd
More file actions
59 lines (40 loc) · 1.05 KB
/
r_sql.Rmd
File metadata and controls
59 lines (40 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
title: "R+ SQL"
author: "Corey Sparks PhD"
date: "7/7/2021"
output: html_document
---
Go to this site and Download the database:
<https://github.com/coreysparks/r_courses/blob/master/data/PUMS_data>

and save it to your local computer. I recommend putting the file *PUMS_data* in your User folder on your computer.
```{r}
library(tidyverse)
library(DBI)
library(RSQLite)
```
```{r}
con <-dbConnect(SQLite(),
dbname = "~/PUMS_data")+
con
dbListTables(con)
```
```{r}
test.table<- dbGetQuery(con,
'select * from pums_tx_ca limit 10;')
test.table
```
```{r}
#dbfile <- tempfile(".sqlite") # not created yet, just a place holder
download.file("https://github.com/coreysparks/r_courses/blob/master/data/PUMS_data?raw=true",destfile = "~/Downloads/PUMS_data")
library(RSQLite)
DB <- dbConnect(SQLite(), dbname="~/Downloads/PUMS_data")
dbListTables(DB)
```
```{r}
query<-"
select *
from ds_nsf_ncses.dbo.nsf_sed
where phdfy >= 2015
"
```