A data block, the data block referenced 2, 3 ranks modified name

1

x <- data.frame (col1, col2, col3, ...) # Vector col1, col2, col3, ... may be of any type, string, numeric, Logical

> x<- data.frame(a=c("a1","a2","a3"),b=c(1,2,3),d=c(TRUE,TRUE,FALSE))
> x
a b d
1 a1 1 TRUE
2 a2 2 TRUE
3 a3 3 FALSE

2

x[1,1]    

x[2,c(1,2)]

x $ d # is equivalent to x [, d]

3

colnames (data block) column name [1] # of a first modified

row.names (data frame) <- c ( "...", "...", "...") # modify Line Name

> colnames(x)[1]<-"aa"     #改列1名
> colnames(x)[2]<-"bb"
> x
aa bb d
1 a1 1 TRUE
2 a2 2 TRUE
3 a3 3 FALSE

> row.names(x)<- c("11","22","33")   #改行名
> x
aa bb d
11 a1 1 TRUE
22 a2 2 TRUE
33 a3 3 FALSE

 

Guess you like

Origin www.cnblogs.com/xhha/p/11669112.html