-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyLab-1.R
More file actions
59 lines (49 loc) · 1.18 KB
/
MyLab-1.R
File metadata and controls
59 lines (49 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#create a vector
vect<- c(1,3,5,7)
# find length of vector
length(vect)
#list all of objects and then remove objects
ls()
rm(list = ls())
#convert discrete values into ordered categorical values
temperature_vector <- c("High", "Low", "High", "Low", "Medium")
factor_temperature_vector <- factor(temperature_vector, order = TRUE,
levels = c("Low", "Medium", "High"))
#create a matrix
mtr<- matrix(c(1,2,3,4),nrow=2,ncol=2)
mtr
sqrt(mtr)
A<- matrix(1:16,4,4)
dim(A)
A[3,2]
A[2:3,3:4]
#set random variables
set.seed(34)
y<- rnorm(50,mean = 10,sd=.3)
mean(y)
var(y)
sd(y)
#plotting
a<- rnorm(100)
b<-rnorm(100)
plot(a,b,xlab='x axis',ylab='y axis',main ='Randomized',col='blue')
pdf('Figure_1.pdf')
#create a sequence of numbers
z<- seq(1,23)
#load Auto data
library(ISLR)
head(Auto)
Auto[100:125,4:7]
which (is.na(Auto))
attach(Auto)
colnames(Auto)
pairs(~mpg+displacement+horsepower+weight+acceleration)
hist(mpg,main = 'Auto',col=3,breaks = 15)
plot(cylinders,mpg,col='red',varwidth=T,horizontal=T)
str(Auto)
summary(Auto)
names(Auto)
dim(Auto)
plot(Auto$cylinders,Auto$mpg,xlab = 'Mpg',ylab = 'Cyclinders',main = 'Automobile',col='dark blue')
#final
savehistory()