Week 3: Learning Log

My Coding Goals this Week

My goals this week were to complete the data wrangling modules. I was initially a bit intimidated by the sheer amount of info I saw in the first part of the modules, so my goal is to tackle part 1 and hopefully get through part 2 next week.

Last week, I really wanted to put in emojis but couldn’t figure out how. I try harder this week…

I also want to explore different themes for my learning logs using packages from github.

Challenges & Successes

After a bit of searching on the internet, I successfully installed a package of templates for rmarkdown documents from github!! Yay! I tried a few of them but ended up choosing this one which I think is really nice and clean.

I got excited to see if I could insert emojis too. I found a package from github again, but realised I had to install the devtools package and load it before downloading. I ran into a few problems here. I had to set a mirror for CRAN, which really confused me. I worked on it for a bit and did a LOT of Googling, and I did it!

# setting the CRAN mirror
options(repos = c(CRAN = "http://cran.rstudio.com"))


# installing and loading the packages
install.packages("emojifont")
## 
## The downloaded binary packages are in
##  /var/folders/cw/l9bfyrms3md0tbkr1866zbl80000gn/T//Rtmp16po71/downloaded_packages
library(emojifont)

# the smile emoji
search_emoji('smile')
## [1] "smiley"      "smile"       "sweat_smile" "smiley_cat"  "smile_cat"
emoji(search_emoji('smile'))
## [1] "😃" "😄" "😅" "😺" "😸"
# another emoji
search_emoji('relieved')
## [1] "relieved"              "disappointed_relieved"
emoji(search_emoji('relieved'))
## [1] "😌" "😥"
# one more for good measure
search_emoji('sunglasses')
## [1] "sunglasses"      "dark_sunglasses"
emoji(search_emoji('sunglasses'))
## [1] "😎" "🕶"

Now, on to data wrangling!

I initially was coding this learning log in RStudio and could not figure out how to import Danielle’s data into RStudio, so I decided to copy my code into RStudio Cloud where Danielle’s data is. Success!

# load packages I need
install.packages("tidyverse")
## also installing the dependency 'tidyr'
## 
## The downloaded binary packages are in
##  /var/folders/cw/l9bfyrms3md0tbkr1866zbl80000gn/T//Rtmp16po71/downloaded_packages
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
## ✓ tibble  3.1.0     ✓ dplyr   1.0.4
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
# read the data
frames <- read.csv(file = "data_reasoning.csv")

# inspecting the data
glimpse(frames)
## Rows: 4,725
## Columns: 8
## $ id          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ gender      <chr> "male", "male", "male", "male", "male", "male", "male", "m…
## $ age         <int> 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36…
## $ condition   <chr> "category", "category", "category", "category", "category"…
## $ sample_size <chr> "small", "small", "small", "small", "small", "small", "sma…
## $ n_obs       <int> 2, 2, 2, 2, 2, 2, 2, 6, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, …
## $ test_item   <int> 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6…
## $ response    <int> 8, 7, 6, 6, 5, 6, 3, 9, 7, 5, 6, 4, 4, 2, 8, 7, 6, 6, 4, 1…
# summary
vic_summary <- frames %>%
  group_by(test_item) %>%
  summarise(
    mean_respon = mean(response),
    sd_resp = sd(response)
  )

print(vic_summary)
## # A tibble: 7 x 3
##   test_item mean_respon sd_resp
## *     <int>       <dbl>   <dbl>
## 1         1        6.77    2.56
## 2         2        6.88    2.10
## 3         3        5.71    2.41
## 4         4        4.48    2.68
## 5         5        3.76    2.81
## 6         6        3.43    2.99
## 7         7        3.26    3.11

Trying the same thing but with different variables

# load the packages I need
library(tidyverse)

# read the data
frames <- read.csv(file = "data_reasoning.csv")

# inspecting the data
glimpse(frames)
## Rows: 4,725
## Columns: 8
## $ id          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ gender      <chr> "male", "male", "male", "male", "male", "male", "male", "m…
## $ age         <int> 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36…
## $ condition   <chr> "category", "category", "category", "category", "category"…
## $ sample_size <chr> "small", "small", "small", "small", "small", "small", "sma…
## $ n_obs       <int> 2, 2, 2, 2, 2, 2, 2, 6, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, …
## $ test_item   <int> 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6…
## $ response    <int> 8, 7, 6, 6, 5, 6, 3, 9, 7, 5, 6, 4, 4, 2, 8, 7, 6, 6, 4, 1…
# summary
vic2summary <- frames %>%
  group_by(gender) %>%
  summarise(
    mean_respon = mean(response),
    sd_resp = sd(response)
  )

print(vic2summary)
## # A tibble: 2 x 3
##   gender mean_respon sd_resp
## * <chr>        <dbl>   <dbl>
## 1 female        4.87    3.07
## 2 male          4.92    3.02

I found this kind of difficult to be honest, and at a much harder level than the previous modules. I tried to create a summary for data_forensic but couldn’t seem to figure it out.

I am quite proud of my new and improved Googling skills to fix any errors I encounter!

Next Steps

My goals for next week are to complete data wrangling pt 2 modules. I wanted to start the modules earlier in the week (as I said last week, yikes), but got caught up doing assignments. Next week, I hope (again) to start earlier and begin to look at the data for our 3361 group work.

Thank you for reading my learning log! :)