In this lab you can use the interactive console to explore or Knit the document. Remember anything you type here can be “sent” to the console with Cmd-Enter (OS-X) or Cntr-Enter (Windows/Linux) in an R code chunk.
my.num
that contains 6 numbersmy.num = c(5,4,7,8,12,14)
my.num
by 4my.num * 4
## [1] 20 16 28 32 48 56
my.char
that contains 5 character stringsmy.char = c("Andrew", "John", "John", "Andrew","John")
my.num
and my.char
into a variable called both
both = c(my.num, my.char)
both
?length(both)
## [1] 11
both
?class(both)
## [1] "character"
both
by 3, what happens?both / 3
## Error in both/3: non-numeric argument to binary operator
x
x = c(1,2,3,4,5,6)
y
y = c(10,20,30,40,50)
x + y
## Warning in x + y: longer object length is not a multiple of shorter
## object length
## [1] 11 22 33 44 55 16
y = c(y, 60)
x + y
## [1] 11 22 33 44 55 66
x * y
## [1] 10 40 90 160 250 360