-
Notifications
You must be signed in to change notification settings - Fork 0
/
code_2022-01-27.R
115 lines (114 loc) · 2.01 KB
/
code_2022-01-27.R
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# CPSC 375-01
help(mean)
?mean
10 * 30
exp(10)
a <- 2
a
class(a)
class(TRUE)
a <- c(10,20,30)
a
a[1]
a * 2
mean(a)
c(T, F, T)
seq(1,10)
1:10
myvec <- c(120, 23, 45, 54, 67)
myvec[1]
myvec[1:2]
doe <- list(name="john", age=28, married=F)
doe
doe[1]
doe$name
class(doe)
class(doe$name)
data.frame(localisation = c("proximal","distal", "proximal"), tumorsize = c(6.3,8.0, 10.0), progress=c(FALSE, TRUE,FALSE))
mydf <- data.frame(localisation = c("proximal","distal", "proximal"), tumorsize = c(6.3,8.0, 10.0), progress=c(FALSE, TRUE,FALSE))
mydf
mydf[2,3]
mydf[2,]
mydf[,3]
mydata <- c(10,20,30, 40, 45, 56, 74, 23, 300)
mydata
mydata[c(6,7,9)]
mydata > 50
mydata[mydata > 50]
iris
class(iris$Species)
levels(iris$Species)
iris
iris[1:10,]
iris[,"Sepal.Length"]
iris[,1]
iris$Sepal.Length
mean(iris$Sepal.Length)
mean(iris[,1])
#Show all rows where Sepal.Length > 7.6
iris$Sepal.Length > 7.6
iris[iris$Sepal.Length > 7.6,]
iris[iris[,1] > 7.6,]
iris$Sepal.Length > 7.6
which(iris$Sepal.Length > 7.6)
# CPSC 375-02
help(mean)
?mean
10 * 30
sqrt(64)
a <- 2
class(a)
class(TRUE)
a <- c(10,20,30)
a
a[1]
a * 2
c(T, F, T)
seq(1,5)
1:5
a[1]
a[1:3]
1:3
doe <- list(name="john", age=28, married=F)
doe
class(doe)
doe[1]
doe$name
doe["name"]
data.frame(localisation = c("proximal","distal", "proximal"), tumorsize = c(6.3,8.0, 10.0), progress=c(FALSE,TRUE, FALSE))
df <- data.frame(localisation = c("proximal","distal", "proximal"), tumorsize = c(6.3,8.0, 10.0), progress=c(FALSE,TRUE, FALSE))
df
df[2,]
df[2]
a <- c(10, 25, 53, 15, 75, 24)
a
a[3,5]
a[c(3,5)]
# numerical indexing
a > 50
a[a > 50]
# logical indexing
a[a < 50]
a < 50
which(a < 50)
iris
class(iris$Species)
class(iris$Species)
iris
iris[1:10]
iris[1:10,]
iris[1]
iris$Sepal.Length
iris[1,]
iris[,1]
iris[,"Sepal.Length"]
iris[1:10,]
class(iris)
mean(iris[,1])
mean(iris$Sepal.Length)
mean(iris[1])
iris[1]
class(iris[1])
class(iris[,1])
iris$Sepal.Length>7.6
iris[iris$Sepal.Length>7.6,]