-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNames.R
More file actions
60 lines (28 loc) · 789 Bytes
/
Names.R
File metadata and controls
60 lines (28 loc) · 789 Bytes
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
#### Names
x <- 1:3
x
names(x)
names(x) <- c( "NY", "LA", "KY" )
x
names(x)
attributes(x)
#### Lists can also have names
x <- list( "AB" = 1, "CD" = 2, "EF" = 3 )
x
names(x)
class(x)
attributes(x)
### Naming in Matrices.
# Create the matrix
m <- matrix( 1:4, nrow = 2, ncol = 2)
# Print the matrix
m
# Set the dimension names through the function dimnames()
dimnames(m) <- list( c( "RowA", "RowB" ), c( "ColA", "ColB" ))
# Now print the matrix again and see the difference.
m
# Try to set the dimension names by the functions rownames() and colnames()
colnames(m) <- c( "RANew", "RBNew" )
rownames(m) <- c( "CANew", "CBNew" )
# Print the matrix again and check whether the new names are set.
m