HW 1
HW 1
2024-09-12
x <‐ c(1, 3, 2, 5)
x
## [1] 1 3 2 5
x = c(1, 6, 2)
x
## [1] 1 6 2
y = c(1, 4, 3)
length(x)
## [1] 3
length(y)
## [1] 3
x + y
## [1] 2 10 5
ls()
rm(x, y)
ls()
## character(0)
## [,1] [,2]
## [1,] 1 3
## [2,] 2 4
sqrt(x)
## [,1] [,2]
## [1,] 1.000000 1.414214
## [2,] 1.732051 2.000000
x^2
## [,1] [,2]
## [1,] 1 4
## [2,] 9 16
x <‐ rnorm(50)
y <‐ x+rnorm (50, mean = 50, sd = .1)
cor (x,y)
## [1] 0.9952086
set.seed(1303)
x <‐ rnorm (50)
set.seed (3)
y <‐ rnorm (100)
mean (y)
## [1] 0.01103557
var(y)
## [1] 0.7328675
sqrt(var(y))
## [1] 0.8560768
sd(y)
## [1] 0.8560768
x <‐ rnorm(100)
y <‐ rnorm(100)
plot(x, y)
plot(x, y, xlab = "this is the x‐ axis ", ylab = "this is the y‐ axis ",
main = "Plot of X vs Y")
x <‐ seq (1,10)
x
## [1] 1 2 3 4 5 6 7 8 9 10
x <‐ 1:10
x
## [1] 1 2 3 4 5 6 7 8 9 10
A[2,3]
## [1] 10
## [,1] [,2]
## [1,] 5 13
## [2,] 7 15
A[1:3, 2:4]
A[1:2,]
A[, 1:2]
## [,1] [,2]
## [1,] 1 5
## [2,] 2 6
## [3,] 3 7
## [4,] 4 8
A[1,]
## [1] 1 5 9 13
A[‐c(1,3),]
## [1] 6 8
dim (A)
## [1] 4 4