Exam # 1

Craig Freeman

date()
## [1] "Sat Sep 15 00:12:02 2012"

Due Date: September 14, 2012, 2pm
Total Points: 30

(0) Assign to a variable m the value of 12. Add 8 to this variable (5).

m = 12
m + 8
## [1] 20

(1) Assign to a variable x the sum of 3 and 5. Find the square root of x (5).

x <- 3 + 5
sqrt(x)
## [1] 2.828

(2) Create a vector called y with elements 5, 10, and -20 (5).

y <- c(5, 10, -20)

print(y)
## [1]   5  10 -20

(3) Create a vector z as a concatenation of the variable x and the vector y (5).

z <- c(x, y)

print(z)
## [1]   8   5  10 -20

(4) List the variables in your workspace (5).

ls.str()
## m :  num 12
## x :  num 8
## y :  num [1:3] 5 10 -20
## z :  num [1:4] 8 5 10 -20

(5) Remove the variables from your workspace (5).


rm(list = ls())
ls()
## character(0)

Notes: