你能帮我用 rnorm 和 hist 函数创建下面矩阵的直方图吗?
还请您帮我回答以下问题吗?
m1 <-matrix(sample(x = 1:4, size = 35*15, replace = TRUE), nrow = 35, ncol = 15)
m1
getwd()
write.table(m1, file = "mymatrix.txt", sep = "\t",
col.names = TRUE, row.names = TRUE)
dir()
rm(m1)
dir()
m1
m1imported <- read.table(file = "mymatrix.txt", sep = "\t",
header = TRUE, row.names = 1) # read any file
m1imported
us<-c("CALIFORNIA", "FLORIDA", "ARIZONA", "MICHIGAN",
"WASHINGTON", "GEORGIA", "TEXAS", "OHIO", "ALABAMA",
"COLORADO","NEW JERSEY","VIRGINIA","MONTANA","OREGON","NEW YORK")
colnames (m1imported) = us
m1imported
num <- c(1:35)
rownames (m1imported) = num
m1imported
#I tried the following to create the histogram but gave me an error
# Error in hist.default(m1imported) : 'x' must be numeric
hist(m1imported)