在r [duplicate]中创建数字向量

时间:2021-03-04 23:00:50

This question already has an answer here:

这个问题在这里已有答案:

I imported a 70104 x 1 matrix with hourly wind speeds into r. I am trying to fit various energy distributions to the data. however, when I try to fir the models, this error comes up "data must be a numeric vector of length greater than 1". How do I rectify this issue?

我将带有每小时风速的70104 x 1矩阵导入r。我试图将各种能量分布拟合到数据中。但是,当我尝试冷却模型时,出现此错误“数据必须是长度大于1的数字向量”。我该如何纠正这个问题?

1 个解决方案

#1


2  

We can just wrap with c to convert it to a vector

我们可以用c包装将其转换为矢量

v1 <- c(mat)

Or explicitly use as.vector to strip off the dim attributes

或者明确使用as.vector去除dim属性

as.vector(mat)

data

set.seed(24)
mat <- matrix(rnorm(70104))

#1


2  

We can just wrap with c to convert it to a vector

我们可以用c包装将其转换为矢量

v1 <- c(mat)

Or explicitly use as.vector to strip off the dim attributes

或者明确使用as.vector去除dim属性

as.vector(mat)

data

set.seed(24)
mat <- matrix(rnorm(70104))