covariance matrix r语言_R 1)bootstrap 2) name dim class 3)vector > matrix

Bootstrap : sample with replacement

——cf. R cookbook

R向量转变为类似于python字典的方法:names()

die <- 1:6

names(die)<-c("one" , "two" , "three" ,"four", "five" , "six")

# >die

##one two three four five six

##1 2 3 4 5 6

注:取消方法 names(die)<-NULL

R向量转变为matrix的方法:dim()/matrix ()

die <- 1:6

dim(die)<-c(2, 3)

# >die

[,1] [,2] [,3]

[1,] 1 3 5

[2,] 2 4 6

继续变为data.frame方法: as.data.frame(die)

注:取消方法 dim(die)<-NULL

m<- matrix(die, nrow=2) 默认bycolumn将6个数字排列成两行

汇总:一个向量变成一个matrix的三种方法

hand1 <- c("ace", "king", "queen", "jack", "ten", "spades", "spades", "spades", "spades", "spades")

matrix(hand1, nrow = 5)

matrix(hand1, ncol = 2)

dim(hand1) <- c(5, 2)

hand2 <- c("ace", "spades", "king", "spades", "queen", "spades", "jack", "spades", "ten", "spades")

matrix(hand2, nrow = 5, byrow = TRUE)

matrix(hand2, ncol = 2, byrow = TRUE)

CLASS

changing the dimensions of your object (VECTOR) will not change the type of the object (double), but it will change the object's class (matrix)

综上

str 整体结构

typeof 数据类型

names 维度一 name

dim 维度二 dim

class 维度三 class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值