diff --git a/CABLAB_R_online.Rmd b/CABLAB_R_online.Rmd index 39c5d71..58be404 100644 --- a/CABLAB_R_online.Rmd +++ b/CABLAB_R_online.Rmd @@ -197,7 +197,7 @@ library(ggplot2) ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/exercise_solutions/week2_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week2_exercise.r) @@ -256,10 +256,10 @@ Pressing tab again will enter into a directory, thus showing me the contents of ```{r Assign working directory to object called "Path"} # For Windows -Path <- "C:/datasets/" +Path <- "C:/Users/tuh20985/Desktop/CABLAB-R-Workshop-Series-main/datasets/" # For Mac -Path <- "datasets/" +Path <- "/Users/tuh20985/Desktop/CABLAB-R-Workshop-Series-main/datasets/" ``` @@ -281,14 +281,12 @@ There were also 3 experimental conditions: Control, Share, and Test. For the first two segments (Delirium and Take 13), all participants toured the segment in the Control condition. However, in the last two segments (Crypt and Machine Shop), some participants toured the segments in the Control condition, other participants toured Machine Shop in the Share condition and Crypt in the Test condition, while other participants toured Machine Shop in the Test condition and Crypt in the Share condition. -After completing the haunted house tour, participants were assessed at two time points: immediately afterwards and again 1-week later. During the Immediate assessments, participants completed a recency discrimination task and freely recalled their memory for 1 low-threat and 1-high threat haunted house segment. During the one week-delay assessments, participants completed a recency discrimination task and freely recalled their memory for *all* haunted house segments. Check out the study design below. +After completing the haunted house tour, participants were assessed at two time points: immediately afterwards and again 1-week later. During the Immediate assessments, participants completed a recency discrimination task and freely recalled their memory for 1 low-threat and 1-high threat haunted house segment. During the one week-delay assessments, participants completed a recency discrimination task and freely recalled their memory for *all* haunted house segments. Check out the study design below as well as the vignette illustrating when the three experimental conditions (i.e., Control, Share, and Test) took place throughout the haunted house tour. ![](images/fright night study design.png){width=70%} -Here is a quick vignette illustrating when the three experimental conditions (i.e., Control, Share, and Test) took place throughout the haunted house tour. - ![](images/fright night study design conditions.png){width=60%} @@ -365,7 +363,7 @@ Amazing! Now we have hundreds of columns of data, like we should. We might also 2) Print out the first few rows using the head() function -3) Open up the df_wide dataframe by using the View() function OR by clicking on the df_wide dataframe in the global enviroment +3) Open up the df_wide dataframe by using the View() function OR by clicking on the df_wide dataframe in the global environment ```{r Week 3 Exercise, code="'\n\n\n\n'", results=F} @@ -385,7 +383,7 @@ View(df_wide) ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week3_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week3_exercise.r) @@ -402,6 +400,21 @@ So how do we access rows? How do we access columns? And how can we check what da dataframe$column will print out all the rows in that column. Let's print out all the participant IDs that exist in the data frame. +For the purposes of this week's workshop, let's read in the frightnight_practice csv file + +```{r} + +# For Mac +Path <- "/Users/tuh20985/Desktop/CABLAB-R-Workshop-Series-main/datasets/" + +setwd(Path) #use the setwd() function to assign the "Path" object that we created earlier as the working directory + +df <- read.csv(file = "frightnight_practice.csv") #Load in the fright night practice csv file + + +``` + + ```{r} df$PID @@ -543,7 +556,7 @@ df2 <- subset(df, select=c(PID, Section, Stage, Fear.rating, TOAccuracy)) ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week4_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week4_exercise.r) ## Missing data @@ -690,7 +703,7 @@ df$Year <- ifelse(df$Section == "Infirmary" | df$Section == "GhostlyGrounds", "2 ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week5_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week5_exercise.r) @@ -902,7 +915,7 @@ for (i in 1:length(x3)) { ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week6_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week6_exercise.r) @@ -1106,7 +1119,7 @@ df_long <- df_wide_exercise %>% pivot_longer( ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week7_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week7_exercise.r) @@ -1235,7 +1248,7 @@ merged_data <- merge(low.df, high.df, by=c("PID", "Section", "Stage", "Threat", ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week8_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week8_exercise.r) ## Week 8 Assignment: Merging data frames @@ -1480,7 +1493,7 @@ report(m1) ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week9_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week9_exercise.r) @@ -1519,7 +1532,7 @@ report(model2) ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week9_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week9_exercise.r) @@ -1711,7 +1724,7 @@ report(m1) ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week10_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week10_exercise.r) @@ -1858,7 +1871,7 @@ ggplot(data = df_plot, aes(x = Condition, y = TOAccuracy, fill = Condition)) + # ``` -[Click for solution](https://github.com/TU-Coding-Outreach-Group/intro-to-coding-2023/blob/main/R/solutions/week11_exercise.r) +[Click for solution](https://steventmartinez.github.io/CABLAB-R-Workshop-Series/exercise_solutions/week11_exercise.r) So we already learned how to add a plot title, an x-axis title, and a y-axis title, as well as how to change x-axis text labels and legend text labels. We can still customize additional plot aesthetics that we'll talk about below. diff --git a/index.html b/index.html index ebb335c..c4c6a7f 100644 --- a/index.html +++ b/index.html @@ -3049,7 +3049,7 @@

Week 2 Exercise: Installing and Loading Packages

' -

Click +

Click for solution

@@ -3122,10 +3122,10 @@

Working Directories in R: Specifying your Working Directory

arrow (<-) and the value that object is taking on the right side of it.

# For Windows
-Path <- "C:/datasets/"
+Path <- "C:/Users/tuh20985/Desktop/CABLAB-R-Workshop-Series-main/datasets/"
 
 # For Mac
-Path <- "datasets/"
+Path <- "/Users/tuh20985/Desktop/CABLAB-R-Workshop-Series-main/datasets/"

This format of assigning a value to an object is really important and we’ll keep coming back to it throughout this tutorial.

@@ -3167,11 +3167,10 @@

Intro to “Fright Night” dataset

and 1-high threat haunted house segment. During the one week-delay assessments, participants completed a recency discrimination task and freely recalled their memory for all haunted house segments. -Check out the study design below.

+Check out the study design below as well as the vignette illustrating +when the three experimental conditions (i.e., Control, Share, and Test) +took place throughout the haunted house tour.

-

Here is a quick vignette illustrating when the three experimental -conditions (i.e., Control, Share, and Test) took place throughout the -haunted house tour.

To assess memory accuracy, we focused on temporal memory accuracy specifically. Temporal memory refers to memory for the order in which @@ -3268,14 +3267,14 @@

Week 3 Exercise: Working Directories

“df_wide”

  • Print out the first few rows using the head() function

  • Open up the df_wide dataframe by using the View() function OR by -clicking on the df_wide dataframe in the global enviroment

  • +clicking on the df_wide dataframe in the global environment

    '
     
     
     
     '
    -

    Click +

    Click for solution

    @@ -3293,6 +3292,14 @@

    Week 4: Subsetting in R

    check what data is missing?

    dataframe$column will print out all the rows in that column. Let’s print out all the participant IDs that exist in the data frame.

    +

    For the purposes of this week’s workshop, let’s read in the +frightnight_practice csv file

    +
    # For Mac
    +Path <- "/Users/tuh20985/Desktop/CABLAB-R-Workshop-Series-main/datasets/"
    +
    +setwd(Path) #use the setwd() function to assign the "Path" object that we created earlier as the working directory
    +
    +df <- read.csv(file = "frightnight_practice.csv") #Load in the fright night practice csv file
    df$PID 
    ##   [1] 1001 1001 1001 1001 1001 1001 1002 1002 1002 1002 1002 1002 1003 1003 1003
     ##  [16] 1003 1003 1003 1004 1004 1004 1004 1004 1004 1005 1005 1005 1005 1005 1005
    @@ -3689,7 +3696,7 @@ 

    Week 4 Exercise: Subsetting in R

    '
    -

    Click +

    Click for solution

    @@ -3848,7 +3855,7 @@

    Week 5 Exercise: If Else statements

    ' -

    Click +

    Click for solution

    @@ -4009,7 +4016,7 @@

    Week 6 Exercise: Intro to For Loops in R

    ' -

    Click +

    Click for solution

    Next, let’s map the for loop onto the dataset we’ve been using! I’ll also try to convert the structure of the ifelse() function into the @@ -4172,7 +4179,7 @@

    Week 7 Exercise: Pivoting data from wide to long and long to ' -

    Click +

    Click for solution

    @@ -4271,7 +4278,7 @@

    Week 8 Exercise: Merging data frames

    ' -

    Click +

    Click for solution

    @@ -4647,7 +4654,7 @@

    Week 9 Exercise: Analyzing Data w/ Categorical Independent ' -

    Click +

    Click for solution

    @@ -4669,7 +4676,7 @@

    Week 9 Assignment: Analyzing Data w/ Categorical Independent ' -

    Click +

    Click for solution

    @@ -4961,7 +4968,7 @@

    Week 10 Exercise: Analyzing Data w/ Continuous Independent ' -

    Click +

    Click for solution

    @@ -5064,7 +5071,7 @@

    Week 11 Exercise: Visualizing data: Intro to ggplot

    ' -

    Click +

    Click for solution

    So we already learned how to add a plot title, an x-axis title, and a y-axis title, as well as how to change x-axis text labels and legend @@ -5313,7 +5320,7 @@

    Violin plots!

    #Add in the jittered points that reflect each individual participant p + geom_jitter(shape=16, position=position_jitter(0.2)) -

    +

    While we didn’t add too many customization to this plot, hopefully you can see why some people prefer to store plots in data objects and add in their customizations one line a time, rather than all at