<- rnorm(20, 10, 5) x
Homework 3
Key
Click link above for answers to homework 3.
Instructions
For this assignment, include all code and relevant output in your rendered html document1.
Exercises
- Organize your files for this class in a way that facilitates reproducible research.
- You can do this any number of ways, such as:
- Creating a project for this class. If you already have a folder for this class you can retoractively turn it into a project by selecting File > New Project… > Existing Directory and browsing to that folder.
- Creating a folder for this class and making weekly subfolders which are each, themselves, projects. You would need to retroactively make week 1 and 2 folders projects by using the method above. For any new weekly folders you can directly create that directory by selecting File > New Project… > New Directory
- Create your .qmd for this homework within your new project2.
- When you’re done organizing the folder for this class, write out its current organizational structure (i.e. something similar to the solution to lab question 53 with the specific names for files and folders that you used). Write a one-sentence description of how you’ve organized your project/projects for this class.
- You can do this any number of ways, such as:
- Create the vector above:
- Look at the help file for
rnorm
and in your own words describe what arguments it takes and what it produces. - Which arguments are required and which are optional (if any)?
- What does the
r
inrnorm
stand for? - Using
[
, select every value except the last one - Using
[
, select only values that are greater than 10.
- Look at the help file for
ggplot(mpg, aes(x = class)) +
geom_bar()
ggplot(mpg, aes(x = cty, y = hwy)) +
geom_point()
ggsave("mpg-plot.png")
- Run the code above.
- Which of the two plots is saved as mpg-plot.png? Why?4
- In the files tab of the lower-right pane of your RStudio, look at the project folder for this homework and re-write the current organizational structure for this class with any changes that have occurred (i.e. update your answer to question 1.iii.).
- Go to the RStudio Tips Twitter account and find one tip that makes sense to you and looks interesting. Describe it and link to it5 in your qmd. Maybe practice using it!6
<- tibble(a = seq(1, 10, 2),
y b = c("apple", "banana", "strawberry", "peach", "mango"),
c = c(rep(TRUE, 3), rep(FALSE, 2)))
- Create the tibble above.
- What does
seq
do in this example and what arguments does it take? - What does
rep
do in this example and what arguments does it take? - Index
y
using[
to arrive at the results:
- What does
> # A tibble: 2 × 1
> b
> <chr>
> 1 banana
> 2 mango
iv) Index y
using $
to arrive at the results:
> [1] TRUE TRUE TRUE FALSE FALSE
v) What does y[3:5, ]
produce? What does :
do?
Due Dates
# | Homework Due | Peer Review Due |
---|---|---|
1 | 2 April | 7 April |
2 | 9 April | 14 April |
3 | 16 April | 21 April |
4 | 23 April | 28 April |
5 | 30 April | 5 May |
6 | 7 May | 12 May |
7 | 14 May | 19 May |
8 | 21 May | 26 May |
9 | 28 May | 2 June |
Footnotes
You can set the
echo: true
(and other) code chunk option(s) globally (will set it as the document default) by specifying it in your YAML header like so:--- title: "My Document" execute: echo: true ---
You’ll notice that the upper-right hand corner of your RStudio IDE now displays the name of that new project. This is your current working directory. Whatever files you create will have a working directory of the folder/subfolder of the project they’re saved within.↩︎
You can embed output-looking text like this example by using a code chunk without the
{r}
like so:
↩︎``` CSSS 508 Homework1/ ...etc... ```
Hint: Check out the help page!↩︎
No need to demonstrate this in your qmd.↩︎