> one <- c( 1, 1, 1, 1 )
> z <- matrix( c( 1, 2, 3, 4, 1, 1, 0, 0, 1, 0, 1, 0 ),nrow=4 )
> class(z)
[1] "matrix"
> cbind( one, z )
     one      
[1,]   1 1 1 1
[2,]   1 2 1 0
[3,]   1 3 0 1
[4,]   1 4 0 0
> qq = cbind( one, z )
> class(qq)
[1] "matrix"
> A=matrix(1:6,nrow=2);A
     [,1] [,2] [,3]
[1,]    1    3    5
[2,]    2    4    6
> apply(A,1,sum)
[1]  9 12
> apply(A,2,mean)
[1] 1.5 3.5 5.5

R的简单操作

> a = list(name = c("张三","李四"),age = 13,sex = "男",score = c(45,67,89))
> a
$`name`
[1] "张三" "李四"

$age
[1] 13

$sex
[1] "男"

$score
[1] 45 67 89

R的简单操作

R的简单操作

 

 

 

 

 

 

 

相关文章: