x <- 1.1
a <- 2.2
b <- 3.3
z = x^{a^b}
print(z)
[1] 3.61714
z = (x^a)^b
print(z)
[1] 1.997611
z = 3*x^3 + 2*x^2 + 1
print(z)
[1] 7.413
rep
and seq
functions, create
the following vectors:z <- c(seq(1:8), seq(from = 7, to = 1))
print(z)
[1] 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
z <- c(1:5)
z <- rep(x=z,times=z)
print(z)
[1] 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
z <- c(1:5)
z <- rep(x=5:1,times=z)
print(z)
[1] 5 4 4 3 3 3 2 2 2 2 1 1 1 1 1
asin()
, acos()
,
or atan()
), convert these numbers into polar
coordinatesset.seed(2)
cartesian <- runif(2)
polar <- c(sqrt(cartesian[1]^2 + cartesian[2]^2), atan(cartesian[2] / cartesian[1]))
print(polar)
[1] 0.7262993 1.3134100
queue <- c("sheep", "fox", "owl", "ant")
where queue
represents
the animals that are lined up to enter Noah’s Ark, with the sheep at the
front of the line. Using R expressions,
update queue
as:queue <- c("sheep", "fox", "owl", "ant")
print(queue)
[1] "sheep" "fox" "owl" "ant"
queue <- c(queue, "serpent")
print(queue)
[1] "sheep" "fox" "owl" "ant" "serpent"
queue <- queue[-1]
print(queue)
[1] "fox" "owl" "ant" "serpent"
queue <- c("donkey", queue)
print(queue)
[1] "donkey" "fox" "owl" "ant" "serpent"
queue <- queue[-5]
print(queue)
[1] "donkey" "fox" "owl" "ant"
queue <- queue[-3]
print(queue)
[1] "donkey" "fox" "ant"
queue <- c(queue[1:2],"aphid",queue[3])
print(queue)
[1] "donkey" "fox" "aphid" "ant"
aphid_pos <- which(queue=="aphid")
print(aphid_pos)
[1] 3
num <- seq(1, 100, by = 1)
num_filt <- num[!(num %% 2 == 0 | num %% 3 == 0 | num %% 7 == 0)]
print(num_filt)
[1] 1 5 11 13 17 19 23 25 29 31 37 41 43 47 53 55 59 61 65 67 71 73 79 83 85 89 95 97