Part 6. Lists and RMarkdown
Class Video
Slides
Open the slides in a separate window: https://sph-r-programming.netlify.com/slides/06_intro_to_rmarkdown#1
Midterm assigned (Due February 12 @ 11:55 PM)
RStudio Project is now available. Please come to office hours or stay for class to discuss your data set.
Post-Class
Please fill out the following survey and we will discuss the results during the next lecture. All responses will be anonymous.
- Clearest Point: What was the most clear part of the lecture?
- Muddiest Point: What was the most unclear part of the lecture to you?
- Anything Else: Is there something you’d like me to know?
Muddiest Points
Lists are a little confusing. I think the homework will help.
Lists are still very new, so I’m planning to go through the part 6 file again.
Yes, lists are weird. But after part 7, hopefully you’ll see they’re very useful.
Still trying to wrap my head around [[]] vs [].
I will say that almost 99% of the time, you should be using double brackets [[]]
, because you want what’s in the list slot.
my_list <- list(cat_names = c("Morris", "Julia"),
hedgehog_names = "Spiny",
dog_names = c("Rover", "Spot"))
df <- my_list[["cat_names"]]
class(df)
## [1] "character"
Again, using []
returns a list of length 1, which is usually not what you want.
single_list <- my_list["cat_names"]
class(single_list)
## [1] "list"
single_list
## $cat_names
## [1] "Morris" "Julia"
To actually access the character
vector in single_list
, we need to access it out of the list structure with [[]]
.
single_list[["cat_names"]]
## [1] "Morris" "Julia"
Posting r html file on the website
Websites
That was a really quick demo and I will go over it more in detail when we get to working with websites.
If you want a preview, you can check out Sharing Online on Short Notice