Try out a few common, basic functions to learn what they do and how they work:
sqrt(64)
(you could also do this:
64^0.5
)exp(0)
, exp(1)
,
exp(-10)
,log(10)
, log(1), log(0)
,
log(-1)
, log(exp(2))
factorial(1)
, factorial(5)
,
factorial(-1)
, factorial(0)
round(3.1415)
,
round(3.1415, digits=2)
abs(-1)
, abs(1)
Here’s a couple more to foreshadow where we’ll be going:
rep("hello!", 100)
and take a look at the output.
What does rep()
do?hist(x=rnorm(300))
and see what happens. What do
you think the hist()
function does? What about the
rnorm()
function? How could you find out more about each
function?Make some objects using the following assignments:
w <- 1
x <- 1
y <- 2
z <- 3
Using only these objects, try writing code to answer the following questions:
z
to
w
that returns TRUE
x
to
w
that returns TRUE
TRUE
: (x __ y) & (z __ y)
Try answering some of these questions before running any code - reason through the commands, then run the code and see if you were correct:
"3" / 4
Inf / 10^20
TRUE
(Hint: read ahead to find out):(0.1 + 0.2) == 0.3
## [1] FALSE
Page sources:
Some content on this page has been modified from other courses, including: