generated from coatless-tutorials/quarto-book-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a bit of content... Just some friendly notes.
- Loading branch information
Showing
8 changed files
with
169 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,9 @@ vignettes/*.pdf | |
|
||
# R Environment Variables | ||
.Renviron | ||
|
||
/.quarto/ | ||
|
||
/.luarc.json | ||
|
||
*_book/ |
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,68 @@ | ||
# Base R Graphics | ||
|
||
|
||
## Customizing Plot Appearance | ||
|
||
### Adjusting Axis Labels and Titles | ||
|
||
```{r} | ||
# Example 1 | ||
x <- 1:10 | ||
y <- x^2 | ||
plot(x, y, main = "Quadratic Function", xlab = "X", ylab = "Y") | ||
# Example 2 | ||
df <- data.frame(Time = 1:10, Value = cumsum(rnorm(10))) | ||
plot(df$Time, df$Value, main = "Cumulative Sum", xlab = "Time", ylab = "Cumulative Value") | ||
``` | ||
|
||
### Changing Line Types, Colors, and Symbols | ||
|
||
```{r} | ||
# Example 1 | ||
x <- 1:5 | ||
y1 <- x | ||
y2 <- 2 * x | ||
y3 <- 3 * x | ||
plot(x, y1, type="b", col="red", pch=16, lty=1, ylim=c(0, 15), main="Multiple Lines Example") | ||
points(x, y2, col="blue", pch=17, lty=2) | ||
lines(x, y3, col="green", lty=3) | ||
# Example 2 | ||
set.seed(123) | ||
x <- rnorm(50) | ||
y <- x + rnorm(50, mean=2) | ||
plot(x, y, col="purple", pch=19, main="Scatter Plot with Customized Symbols", xlab="X", ylab="Y") | ||
``` | ||
|
||
```{r} | ||
# Create data | ||
x <- 1:10 | ||
y <- 1:10 | ||
# Line Types | ||
par(mar=c(4, 4, 2, 2)) | ||
plot(x, y, type="n", main="All Line Types", xlab="X", ylab="Y", ylim=c(0, 6)) | ||
for (i in 0:5) { | ||
lines(x, rep(i*.5, length(x)), lty=i, col="black", lwd=2) | ||
} | ||
legend("topright", legend=0:5, title="Line Types", lty=0:5, col="black", lwd=2, ncol=3) | ||
``` | ||
|
||
```{r} | ||
# Colors | ||
par(mar=c(4, 4, 2, 2)) | ||
plot(x, y, type="n", main="All Colors", xlab="X", ylab="Y", ylim=c(0, 9)) | ||
for (i in 1:8) { | ||
lines(x, rep(i*.5, length(x)), col=i, lwd=2) | ||
} | ||
legend("topright", legend=1:8, title="Colors", col=1:8, lwd=2, ncol=2) | ||
``` | ||
|
||
```{r} | ||
# symbols | ||
# todo | ||
``` |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,4 @@ | ||
|
||
|
||
## Welcome {.unnumbered} | ||
|
||
Welcome splash page! Provide an overview of the book. | ||
|
||
Sample evaluation of R and Python in a side-by-side manner: | ||
|
||
::: {layout-ncol=2} | ||
#### R | ||
|
||
```{r} | ||
my_list = list(1, 2, 3) | ||
typeof(my_list) | ||
``` | ||
|
||
#### Python | ||
|
||
```{python} | ||
my_list = [1, 2, 3] | ||
type(my_list) | ||
``` | ||
::: | ||
Hello there! You've stumbled across a reference guide that contains different useful R code and/or links. There isn't a lot of depth associated with each page if you are expecting a through walkthrough of the material. |
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,66 @@ | ||
# R Environment Variables | ||
|
||
Setting up and using environment variables in R is useful for handling configuration | ||
details and/or suppressing private information. | ||
|
||
## Retrieve/access environment variables: | ||
|
||
Values stored in the system environment can be retrieved using `Sys.getenv("VAR_NAME")`. | ||
|
||
```{r} | ||
# Example: Accessing environment variable named API_KEY | ||
api_key <- Sys.getenv("API_KEY") | ||
api_key | ||
``` | ||
|
||
In the case where the value might not be found, make sure to specify an **unset** value that acts as a default. | ||
|
||
```{r} | ||
# Example: Accessing environment variable named API_KEY | ||
api_key <- Sys.getenv("API_KEY", unset = NA) | ||
api_key | ||
``` | ||
|
||
Note, the `Sys.getenv()` function only returns a `character` value. | ||
|
||
## Set environment variables in your R environment | ||
|
||
Environment variables can be set in R by using `Sys.setenv()`. | ||
|
||
```{r} | ||
Sys.setenv(API_KEY = "your_api_key") | ||
``` | ||
|
||
## Use an `.Renviron` file for configuration: | ||
|
||
Frequently using environment variables? Instead of defining them for each script, aim to store | ||
environment variables in a `.Renviron` file in the project directory. | ||
|
||
Variables are specified in the `.Renviron` file with the format `VAR_NAME=value`. | ||
|
||
:::callout-note | ||
Avoid using spaces around the `=` sign. | ||
::: | ||
|
||
```ini | ||
# Example .Renviron file | ||
API_KEY=your_api_key | ||
``` | ||
|
||
## Access `.Renviron` from R using `browseURL()` or `usethis` package | ||
|
||
The `.Renviron` file may be accessed using either `browseURL("~/.Renviron")` or with `usethis::edit_r_environ()` for editing. | ||
|
||
```{r} | ||
#| eval: false | ||
# Example: Load .Renviron file with browseURL() | ||
utils::browseURL("~/.Renviron") | ||
``` | ||
|
||
```{r} | ||
#| eval: false | ||
# Example: Load .Renviron file with the usethis package | ||
usethis::edit_r_environ() | ||
``` | ||
|
||
### TODO: mention `dotenv` for managing environment variables? |
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,8 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
} | ||
], | ||
"settings": {} | ||
} |