This is not a real lab. This is a practice lab. It serves two purposes:
For this lab, you will create a single .R
file called lab00.R
. The following exercises will ask you to write code. Place all requested code in this .R
file separated by comments which indicate which code corresponds to which exercise.
Note: A comment in R begins with a #
. For example:
# this line is a comment, the following line is real code
print("This is code that will run!")
Copy-paste the above code into an R console. You’ll find that the first line has no effect (because it was commented) while the second line will create output.
Submit your lab to the corresponding assignment on Canvas. We will “grade” your lab as a way of letting you know that you have submitted a lab that matches our expectations. You have unlimited attempts before the deadline. Your final submission before the deadline will be graded.
This lab is not graded. However, this section exists to show that in general, we will provide information on how each individual lab is graded.
It is tradition when learning a new programming language for the first program you write to be something called “Hello World.” That is, your task is to write code which returns Hello World!
.
In R, the code to accomplish this task is:
print("Hello World!")
Place this code in your .R
file for this exercise. Also, run the code!
Write R code that does the following:
a
that stores the value 42
.b
that stores the value "STAT 385"
.c
that stores the integers from 1
to 100
.