Skip to content

Commit bac1568

Browse files
committed
remove first mutate example
1 parent 2258317 commit bac1568

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

hands-on.qmd

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ species_db %>%
187187

188188
Note it means the full query is going to be ran and save in your R environment. This might slow things down, so you generally want to collect on the smallest data frame you can.
189189

190+
190191
#### How can you see the SQL query?
191192

192193
Adding `show_query()` at the end of your code block will let you see the SQL code that has been used to query the database.
@@ -210,7 +211,6 @@ Here is how you could run the query using the SQL code directly:
210211
dbGetQuery(conn, "SELECT Scientific_name FROM Species WHERE (Relevance = 'Study species') ORDER BY Scientific_name LIMIT 3")
211212
```
212213

213-
214214
You can do pretty much anything with these quasi-tables, including grouping, summarization, joins, etc.
215215

216216
Let's count how many species there are per Relevance categories:
@@ -230,26 +230,6 @@ species_db %>%
230230
show_query()
231231
```
232232

233-
You can also create new columns using mutate:
234-
235-
```{r}
236-
species_db %>%
237-
mutate(Code = paste("X", Code)) %>%
238-
head()
239-
```
240-
241-
How does the query looks like?
242-
243-
```{r}
244-
species_db %>%
245-
mutate(Code = paste("X", Code)) %>%
246-
head() %>%
247-
show_query()
248-
```
249-
250-
:::{.callout-caution}
251-
***Limitation: no way to add or update data in the database, `dbplyr` is view only. If you want to add or update data, you'll need to use the `DBI` package functions.***
252-
:::
253233

254234
### Average egg volume analysis
255235

@@ -261,14 +241,19 @@ eggs_db <- tbl(conn, "Bird_eggs")
261241
nests_db <- tbl(conn, "Bird_nests")
262242
```
263243

264-
Compute the volume using the same code as previously!!
244+
Compute the volume using the same code as previously!! Yes, you can use mutate to create new columns on the tables object
265245

266246
```{r}
267247
# Compute the egg volume
268248
eggs_area_db <- eggs_db %>%
269249
mutate(egg_volume = pi/6*Width^2*Length)
270250
```
271251

252+
:::{.callout-caution}
253+
***Limitation: no way to add or update data in the database, `dbplyr` is view only. If you want to add or update data, you'll need to use the `DBI` package functions.***
254+
:::
255+
256+
272257
Now let's join this information to the nest table, and average by species
273258

274259
```{r}

0 commit comments

Comments
 (0)