-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Barret Schloerke <schloerke@gmail.com> Co-authored-by: Cass (Z.) Wilkinson Saldaña <12399460+zoews@users.noreply.github.com> Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
- Loading branch information
1 parent
5ff9030
commit 3460acb
Showing
9 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "Multi-language exercises" | ||
author: "Cass (Z.) Wilkinson Saldaña" | ||
output: learnr::tutorial | ||
runtime: shiny_prerendered | ||
--- | ||
|
||
```{r setup, include = FALSE} | ||
library(learnr) | ||
# altered from https://datacarpentry.org/R-ecology-lesson/05-r-and-databases.html | ||
if (!file.exists("portal_mammals.sqlite")) { | ||
download.file(url = "https://ndownloader.figshare.com/files/2292171", | ||
destfile = "portal_mammals.sqlite", mode = "wb") | ||
} | ||
mammals <- DBI::dbConnect(RSQLite::SQLite(), "portal_mammals.sqlite") | ||
``` | ||
|
||
### Python or R? | ||
|
||
The following two code exercises run language agnostic code. It will finally evaluate to either 5 or 10. | ||
|
||
```{r r-not-python, exercise=TRUE, exercise.lines = 5} | ||
# if running in R, this should return 10 | ||
# if running in Python, this should return FALSE and 5 | ||
x = 5 | ||
x <-10 | ||
print(x) | ||
``` | ||
|
||
```{python python-not-r, exercise=TRUE, exercise.lines = 5} | ||
# if running in R, this should return 10 | ||
# if running in Python, this should return FALSE and 5 | ||
x = 5 | ||
x <-10 | ||
print(x) | ||
``` | ||
|
||
### Bash | ||
|
||
Execute exercises in bash | ||
|
||
```{bash bash-not-r, exercise = TRUE} | ||
echo "hello world" | ||
date | ||
``` | ||
|
||
### SQL | ||
|
||
Use a SQL connection defined in a setup chunk. | ||
|
||
```{sql sql-not-r, exercise = TRUE, connection="mammals"} | ||
SELECT * | ||
FROM `surveys` | ||
LIMIT 10 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters