Answer the following by constructing appropriate R commands and/or giving a text narrative.
Show that names with different capitalization refer to different objects.
Variable = 1
variable = 2
variable
## [1] 2
Variable
## [1] 1
The name of the object being assigned to always goes to the left of the = operator. What happens if you put it on the right?
3 = Variable
## Error: invalid (do_set) left-hand side to assignment
Variable
## [1] 1
Show that a string and a name are different.
Assign a string value to an object.
Object = "String"
Object
## [1] "String"
Use scientific notation to create these numbers: 100, 10, 0.001, 0.0000001
100
## [1] 100
10
## [1] 10
0.001
## [1] 0.001
1e-07
## [1] 1e-07
Try these mathematical operations and explain what the values mean:
1/0
## [1] Inf
This produces Inf(inity) because it is a positive number divided by zero.
0/0
## [1] NaN
This produces NaN because it is zero divided by zero.
sqrt(-3)
## Warning: NaNs produced
## [1] NaN
This produces NaNs because it is an imaginary number?
Q: What's the difference between NaN and NA?
A: NaN has an answer, just not one that can be conventionally expressed. NA has none.
Show that the order of unnamed arguments makes a difference. Use seq() to illustrate this.
seq(1, 7)
## [1] 1 2 3 4 5 6 7
seq(7, 1)
## [1] 7 6 5 4 3 2 1
Find the names of the arguments to seq(). Show that when you use the names, the order doesn't matter.
What kind of object is created by date()?
date()
## [1] "Thu Feb 21 04:26:45 2013"
String?
Read in the data set “utilities.csv” with fetchData("utilities.csv")
How many rows are there?
What are the names of the variables?
Write the Markdown to reproduce this outline. See below for a hint.
Hint:
### Fruits
1. Sweet
* Apples