Unmarked Assignment: Hello R, Hello GitHub
This worksheet introduces you to R, R scripts, and R Markdown. You will run R commands in code chunks, combine code and explanations in one document, and use Git and GitHub to submit your work to your course repository.
Before submitting, follow the Classroom 50 setup steps to create your personal course repository.
Things you need for this worksheet
- R — the interpreter can be installed on any operating system.
- RStudio — we recommend using RStudio for (interactive) programming with R.
- Git installed and available to RStudio. GitHub Desktop is an optional graphical client for working with Git.
Hello R and GitHub submission
Create an R Markdown (.Rmd) document with HTML output for the following task.
- Assign the value of five to a variable called
aand the value of two to a variable calledb. - Compute the sum, difference, product and ratio of a and b (a always in the first place) and store the results in four different variables called
r1,r2,r3, andr4. - Create a vector
v1which contains the values stored within the four variables from step 2. - Add a fifth entry to vector
v1which representsaraised to the power ofb(i.e.a**b). - Show the content of vector
v1(e.g. use theprintfunction or just type the variable name on a separate line). - Create a second vector
v2which contains information on the type of mathematical operation used to derive the five results. This vector should have five entries describing the operations: sum, difference, product, ratio, and power. - Show the content of vector
v2. - Combine the two vectors
v1andv2into a data frame calleddf. Each vector should become one column of the data frame so you will end up with a data frame with five rows and two columns. - Name the column containing
v1Results and the column containingv2Operation. - Show the entire content of
df. - Show just the entry of the cell in the second row and first column.
Save your .Rmd file in your course repository and knit it to HTML. Commit both the .Rmd source and the generated HTML file, then push your changes to GitHub. Check that both files are present in your Classroom 50 course repository.
Completing the R code is only part of the assignment. You must also knit the document, commit the source and HTML files, and push them to your course repository on GitHub.