Note: Only make edits in places where we specifically tell you to edit. Doing otherwise may result in an error when running the code. An error in your code could result in a zero on the assignment. As you get more comfortable with this process, we’ll progressively relax these rules.

Introduction

In this course we will program with the R programming language. We will use a particular kind of file called an R Markdown file (.Rmd) to communicate our code, results, explanations, and anything else for a problem set within a single file. An .Rmd file is a text document that allows you to create dynamic and reproducible documents by intertwining code, text, and the output of the code, such as graphs and tables. It’s used within the R programming environment. In an .Rmd file, you can write narrative text along with R code chunks, and when you process the file through R, it executes the code and embeds the results (like plots) within a final document. This document can be rendered into various formats like HTML, PDF, or Word, making it easy to share analyses and reports with others.

Before moving forward, click on the “Knit” button next to the blue ball of yarn right above this file window in RStudio. This will show you what the output of an .Rmd file can look like. You should have a pdf pop-up in a new browser tab showing this file in a formatted state.

This week, your assignment is to familiarize yourself with the Rstudio environment and successfully knit an R markdown file. At the conclusion of each assignment, you will upload the .Rmd file to Canvas for grading. Each week during discussion section, you will work in pairs or small groups to complete the tasks.


Editing the Header

First, be sure the author line above (line 3) contains your full name

(for example, my line 3 reads: ‘author: “Liam Mueller”’)

Second, change the date in line 4 to today’s date

(for example, my line 4 reads: ‘date: “08 Jan 2025”’)

Be sure not to change anything other than your name in the author line (line 3) and the date in the date line (line 4) in lines 1-20 as it will change how the file knits and is saved.


Creating objects out of your name

We use an auto-grader for this course. Each week you will need to save your first name, last name, and UCSD username in this section inside the quotation marks or you will not get credit for your assignment!

Your Information:

firstname <- "Eric"   # example: "Liam". Here, we're creating an object named 'firstname' where we can store a first name like "Liam".
lastname <- "Nguyen"  # example: "Mueller", Similarly, we're creating an object named 'lastname' where we can store a last name like "Mueller".
username <- "etn010" # example: "lomueller" As above, we are creating an object named username which will store information, in this case, your UCSD username (your ucsd email with out the @ucsd.edu part)

Question 1

  1. By ancient tradition (1967 or 1972 or 1978 depending on who you ask), the first line of code a programmer writes when learning to code is an attempt to print the statement: “Hello, World!”. If this is your first time programming, please type the statement: “Hello, World!” on the line that begins with q1 <-. If you are coming into this class with prior programming experience, please print a statement describing your past coding experience, then see if you can help other students around you with your additional coding experience!
# save your output in variable name "q1". (for example: q1 <- "your answer")
q1 <- "Hello World!"
# Now try and print the object q1 by typing a function on the line after this note. A function is a pre-made set of instructions that you can command the computer to do on an object. For example: pasting the function: abs(-13) in your console and pressing enter will give the absolute value of -13. Hint: print() is a function.
  print(q1)
## [1] "Hello World!"

Question 2

Examine the course schedule. Which topic are you the most excited about? Why? Hint, in your answer, don’t nest quotation marks!

q2 <- "I feel excited about learning a new language of coding."
# Write your answer within the quotes. On the line below please print out your response.
print(q2)
## [1] "I feel excited about learning a new language of coding."

Question 3:

Examine the course schedule. Which topic do you think will be the hardest or most confusing for you? Why? Hint, in your answer, don’t nest quotation marks!

q3 <- "I think the most confusing part will be learning the language since coding is all new to me."
# Write your answer within the quotes. On the line below please print out your response.
print(q3)
## [1] "I think the most confusing part will be learning the language since coding is all new to me."

Finally, You can check your work by clicking on the blue yarn ball next to the word Knit. This will bring up an html file that will allow you to inspect all of your work and the output it produces in one file. If you don’t see any missing chunks or errors, you are done!

Once you are done, save the .rmd file with week number and your full name in the file name. I also like to make it clear which file is complete, like so:

(for example: “DONE-BILD5_week1_Liam_Mueller.rmd”).

Then upload the .rmd file to canvas under the Week 1 Section Assignment before the deadline.

And that is it for this week!