我正在尝试使用包提供的示例数据来学习名为TropFishR的包。包提供的数据同时包括向量和矩阵。我如何安排我的数据
> data(alba)
> print(alba)
$sample.no
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14
$midLengths
[1] 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5 12.5 13.5 14.5
$dates
[1] "1976-04-17" "1976-07-02" "1976-09-19" "1976-12-15" "1977-02-18" "1977-
04-30"
[7] "1977-06-24"
$catch
1976.29315068493 1976.50136986301 1976.71780821918 1976.95616438356
1977.13150684931
[1,] 0 0 0 2
0
[2,] 0 1 9 1
1
[3,] 0 1 34 3
0
[4,] 1 0 96 3
0
[5,] 1 1 68 4
2
[6,] 1 0 50 21
attr(,"class")
[1] "lfq"
答案 0 :(得分:1)
您可以通过以下代码了解...
### Data generte.....
sample.no<-seq(1,14)
dates<-c("1976-04-17","1976-07-02","1976-09-19","1976-12-15","1977-02-18",
"1977-04-30","1977-06-24")
catch<-matrix(rbinom(25,20,0.5),5,5)
colnames(catch)<-c(10,20,30,40,50)
### Including within list named 'Yourdata'
Yourdata<-list(sample.no,dates,catch)
names(Yourdata)<-c("sample.no","dates","catch")
Yourdata
输出:
$sample.no
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14
$dates
[1] "1976-04-17" "1976-07-02" "1976-09-19" "1976-12-15" "1977-02-18"
[6] "1977-04-30" "1977-06-24"
$catch
10 20 30 40 50
[1,] 11 8 11 8 9
[2,] 10 11 12 8 9
[3,] 9 8 8 8 9
[4,] 12 12 11 10 11
[5,] 11 10 9 9 15