Reference no: EM132361839
Question
1. In R, you can choose almost any name you like for an object, as long as the name does not begin with a number or a special character like +, -, *, /, ^, !, @, or &. Note: Remember that the most helpful names will remind you what you put in your object. Which of these would be valid object names?
^-^
+1
foo
var
2. If your vector contains a sequence of contiguous integers, you can create it with the : shortcut. If run 1:5 in command line. What do you get?
1, 2, 3, 4, 5
[1] 1 2 3 4 5
1 : 5
3. You can extract any element of a vector by placing pair of brackets behind the vector. Inside the brackets place the number of the element that you'd like to extract.
If you assign vec <- c(1, 2, 4, 8, 16), then vec[3] would return:
vec[3]
4
16
3
4. Vector recycling: Predict what the code below will return.