diff --git a/modules/Data_Input/Data_Input.Rmd b/modules/Data_Input/Data_Input.Rmd index 9831ec74..b0a84462 100644 --- a/modules/Data_Input/Data_Input.Rmd +++ b/modules/Data_Input/Data_Input.Rmd @@ -38,12 +38,15 @@ R Projects are a super helpful feature of RStudio. They help you: ## Why projects? -"The chance of the `setwd()` command having the desired effect – making the file paths work – for anyone besides its author is 0%. It’s also unlikely to work for the author one or two years or computers from now. The project is not self-contained and portable." - -- [Jenny Bryan](https://www.tidyverse.org/blog/2017/12/workflow-vs-script/) +"The chance of the `setwd()` command having the desired effect – making the file paths work – for anyone besides its author is 0%. It’s also unlikely to work for the author one or two years or computers from now. The project is not self-contained and portable." - [Jenny Bryan](https://www.tidyverse.org/blog/2017/12/workflow-vs-script/) **Let's go over how to create and use an R Project!** +```{r, fig.alt="If the first line of your R script is setwd C:Users jenny path that only I have I will come into your office and SET YOUR COMPUTER ON FIRE.", out.width = "40%", echo = FALSE, fig.align='center'} +knitr::include_graphics("images/Jenny_fire.jpg") +``` + + ## New R Project Let's make an R Project so we can stay organized in the next steps. Click the new R Project button at the top left of RStudio: @@ -244,7 +247,9 @@ knitr::include_graphics("images/files.jpg") ## Checking the working directory -Run the `getwd()` function to determine your working directory. +Run the `getwd()` function to determine your working directory. + +You can also click the ![R Logo](images/files_gear.png){width=25px} in the Files pane > Go To Working Directory. ```{r eval=FALSE} # Get the working directory diff --git a/modules/Data_Input/images/Jenny_fire.jpg b/modules/Data_Input/images/Jenny_fire.jpg new file mode 100644 index 00000000..4d4654bb Binary files /dev/null and b/modules/Data_Input/images/Jenny_fire.jpg differ diff --git a/modules/Data_Input/images/files_gear.png b/modules/Data_Input/images/files_gear.png new file mode 100644 index 00000000..1295da28 Binary files /dev/null and b/modules/Data_Input/images/files_gear.png differ diff --git a/resources/palette.R b/resources/palette.R new file mode 100644 index 00000000..ac31a62f --- /dev/null +++ b/resources/palette.R @@ -0,0 +1,33 @@ +# Script to create color palette +library(tidyverse) + +# Break data down into grid +r_colors <- + data.frame( + COLOR = colors(), + COL = rep(seq(1, 9), each = 73), + ROW = rep(seq(1, 73), times = 9) + ) + +# Get RGB values to help with label coloring, stick into the data frame +r_colors <- + cbind(r_colors, + map_dfr(map(r_colors$COLOR, col2rgb), ~ as.data.frame(t(.x)))) + +# Black label if the color is lighter +r_colors <- + r_colors |> + mutate(label_color = case_when(red + blue + green > 510 ~ "black", TRUE ~ "white")) + +# Make the palette +ggplot(r_colors, aes(x = COL, y = ROW)) + + geom_tile(fill = r_colors$COLOR) + + scale_fill_manual(values = r_colors$COLOR) + + geom_text(aes(label = COLOR), + color = r_colors$label_color, + size = 3) + + theme_void() + + theme(legend.position = "none") + +# Save +ggsave("resources/palette.jpg", height = 10, width = 11) diff --git a/resources/palette.jpg b/resources/palette.jpg new file mode 100644 index 00000000..b4dd0220 Binary files /dev/null and b/resources/palette.jpg differ