gpt4 book ai didi

r - x[j] : invalid subscript type 'list' while using subset in R 中的错误

转载 作者:行者123 更新时间:2023-12-01 03:28:36 24 4
gpt4 key购买 nike

我在尝试对数据框进行子集化时遇到问题。这是我用来导入数据文件和子设置的代码;

fiber_val<-read.csv(file.choose(), header=TRUE, dec=",", check.names=FALSE,stringsAsFactors=FALSE)
y<-14
z<-16
fiber_val[, y:z] <- sapply(fiber_val[, y:z], as.numeric)

fiber_val$sg<-(fiber_val$airdryweight/1.077)/fiber_val$waterweight

fiber_val<-subset(fiber_val, select = c(id,sample,standtreedisk,density,sg))

运行最后一行后,它对我大喊大叫
Error in x[j] : invalid subscript type 'list'

这是我正在使用的数据集的一部分;
id  stand   tree    disk    species region  standtreedisk   nirblock    sample  barktopith  pithtobark  length  sections    ringssection    airdryweight    waterweight density
1 160 7 10 131 6 160x7x10 749 16907 4 2 52 5 2 0.6489 1.3245 0.48992
2 160 7 10 131 6 160x7x10 749 16905 2 4 52 5 3 0.6062 1.2206 0.49664
3 160 7 12 131 6 160x7x12 750 16915 2 3 43 4 2 0.6438 1.3279 0.48483
4 160 7 13 131 6 160x7x13 750 16919 2 2 30 3 3 0.5816 1.4101 0.41245
5 161 17 12 131 6 161x17x12 760 17166 4 2 50 5 1 0.5702 1.3952 0.40869
6 161 17 12 131 6 161x17x12 760 17167 5 1 50 5 1 0.5454 1.3307 0.40986
7 161 17 12 131 6 161x17x12 760 17163 1 5 50 5 1 0.6947 1.5702 0.44243
8 161 17 13 131 6 161x17x13 760 17170 3 1 32 3 2 0.4357 1.2244 0.35585
9 26 9 7 131 4 26x9x7 140 3883 8 1 82 8 2 0.4595 1.3503 0.34029
10 161 17 13 131 6 161x17x13 760 17169 2 2 32 3 1 0.484 1.2843 0.37686
11 136 50 1 131 6 136x50x1 579 12482 9 1 96 9 2 0.5392
12 137 54 5 131 4 137x54x5 586 12636 4 4 73 7 1 0.4692
13 137 54 5 131 4 137x54x5 586 12638 6 2 73 7 2 0.4555
14 137 54 6 131 4 137x54x6 586 12640 1 6 65 6 4 0.6449
15 137 54 1 131 4 137x54x1 585 12606 5 5 90 9 1 0.7035
16 137 54 1 131 4 137x54x1 585 12610 9 1 90 9 2 0.4963
17 137 54 1 131 4 137x54x1 585 12609 8 2 90 9 2 0.5193
18 137 54 1 131 4 137x54x1 585 12603 2 8 90 9 3 0.6427
19 137 54 6 131 4 137x54x6 586 12644 5 2 65 6 1 0.4654
20 137 54 4 131 4 137x54x4 585 12632 7 1 76 7 2 0.4974
21 137 54 5 131 4 137x54x5 586 12639 7 1 73 7 2
22 137 5 3 131 4 137x5x3 582 12557 2 7 82 8 3
23 137 74 3 131 4 137x74x3 588 12679 3 5 71 7 2
24 137 74 3 131 4 137x74x3 588 12683 7 1 71 7 1
25 137 5 3 131 4 137x5x3 582 12562 7 2 82 8 1
26 137 74 5 131 4 137x74x5 588 12695 6 1 61 6 2
27 138 108 1 131 4 138x108x1 594 12830 6 5 104 10 1
28 138 108 1 131 4 138x108x1 594 12831 7 4 104 10 2
29 138 108 1 131 4 138x108x1 594 12832 8 3 104 10 2
30 138 66 1 131 4 138x66x1 592 12781 5 4 87 8 2

任何帮助,将不胜感激 :)

最佳答案

您的对象类型似乎有问题。您可以尝试使用 unlist、as.data.frame() 等将其转换为数据框。

关于r - x[j] : invalid subscript type 'list' while using subset in R 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39751135/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com