我有两个数据帧我正在进行相同的分析。在将三个新变量引入数据帧的.csv(s)之后,我在两个集合中的一个上遇到了重复出错。虽然网上有很多关于错误的参考,但我似乎找不到任何解决了我的具体案例的事情。
修改
我应该补充一下,我可以发布数据样本,但为了保护隐私和上传,样本将经过严格审查。
> # import datasets
...
>
> # set options
> options(max.print = .Machine$integer.max)
>
> # (attempt to) delete conflict data
> ImmatureTree_Data$SPE_TYP <- NULL
> MatureTree_Data$SPE_TYP <- NULL
> ImmatureTree_Data <- ImmatureTree_Data[ImmatureTree_Data$SPECIES_CO %in% names(which(table(ImmatureTree_Data$SPECIES_CO) > 9)), ]
> MatureTree_Data <- MatureTree_Data[MatureTree_Data$SPECIES_CO %in% names(which(table(MatureTree_Data$SPECIES_CO) > 9)), ]
>
> # remove dead trees
> MatureTree_Data <- subset(MatureTree_Data, TREE_STATU != 1)
> MatureTree_Data <- subset(MatureTree_Data, TREE_STATU != 2)
> MatureTree_Data <- subset(MatureTree_Data, TREE_STATU != 5)
> ImmatureTree_Data <- subset(ImmatureTree_Data, TREE_STATU != 1)
> ImmatureTree_Data <- subset(ImmatureTree_Data, TREE_STATU != 2)
> ImmatureTree_Data <- subset(ImmatureTree_Data, TREE_STATU != 5)
>
> # divide GDD and PCP by 1000
> MatureTree_Data$GDD <- MatureTree_Data$GDD/1000
> MatureTree_Data$PCP <- MatureTree_Data$PCP/1000
> ImmatureTree_Data$GDD <- ImmatureTree_Data$GDD/1000
> ImmatureTree_Data$PCP <- ImmatureTree_Data$PCP/1000
>
> # coerce variables Immature
> ImmatureTree_Data$DISTRICT <- as.factor(ImmatureTree_Data$DISTRICT)
> ImmatureTree_Data$PLOT_NUM <- as.factor(ImmatureTree_Data$DISTRICT)
> ImmatureTree_Data$TREE_NUM <- as.factor(ImmatureTree_Data$DISTRICT)
> ImmatureTree_Data$PLOTKEY <- as.character(ImmatureTree_Data$DISTRICT)
> ImmatureTree_Data$PLOTKEY_TREE <- as.character(ImmatureTree_Data$DISTRICT)
> ImmatureTree_Data$TREE_STATU <- as.character(ImmatureTree_Data$TREE_STATU)
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==0] <- " [Live - no defects]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==1] <- " [Dead - standing]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==2] <- " [Dead - leaning or down]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==3] <- " [Live - leaning]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==4] <- " [Live - down]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==5] <- " [Dead - broken top or stem]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==6] <- " [Live - broken top or stem]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==7] <- " [Live - dead top]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==8] <- " [Live - lateral takeover]"
> ImmatureTree_Data$TREE_STATU[ImmatureTree_Data$TREE_STATU==9] <- " [Tree not located]"
> ImmatureTree_Data$SPECIES_CO <- as.character(ImmatureTree_Data$SPECIES_CO)
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="wP"] <- " [White Pine]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="jP"] <- " [Jack Pine]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="Pl"] <- " [Other Pine]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="bS"] <- " [Black Spruce]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="wS"] <- " [White Spruce]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="bF"] <- " [Balsam Fir]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="tL"] <- " [Tamarack]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="tA"] <- " [Trembling Aspen]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="PO"] <- " [Other Poplar]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="wB"] <- " [White Birch]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="yB"] <- " [Yellow Birch]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="rM"] <- " [Red Maple]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="US"] <- " [*Unkown Softwood*]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="UH"] <- " [*Unknown Hardwood*]"
> ImmatureTree_Data$SPECIES_CO[ImmatureTree_Data$SPECIES_CO=="OH"] <- " [Other Hardwoods]"
> ImmatureTree_Data$AGE <- as.character(ImmatureTree_Data$AGE)
> ImmatureTree_Data$YEAR <- as.factor(ImmatureTree_Data$YEAR)
>
> # coerce variables Mature
> MatureTree_Data$DISTRICT <- as.factor(MatureTree_Data$DISTRICT)
> MatureTree_Data$PLOT_NUM <- as.factor(MatureTree_Data$DISTRICT)
> MatureTree_Data$TREE_NUM <- as.factor(MatureTree_Data$DISTRICT)
> MatureTree_Data$PLOTKEY <- as.character(MatureTree_Data$DISTRICT)
> MatureTree_Data$PLOTKEY_TREE <- as.character(MatureTree_Data$DISTRICT)
> MatureTree_Data$TREE_STATU <- as.character(MatureTree_Data$TREE_STATU)
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==0] <- " [Live - no defects]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==1] <- " [Dead - standing]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==2] <- " [Dead - leaning or down]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==3] <- " [Live - leaning]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==4] <- " [Live - down]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==5] <- " [Dead - broken top or stem]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==6] <- " [Live - broken top or stem]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==7] <- " [Live - dead top]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==8] <- " [Live - lateral takeover]"
> MatureTree_Data$TREE_STATU[MatureTree_Data$TREE_STATU==9] <- " [Tree not located]"
> MatureTree_Data$SPECIES_CO <- as.character(MatureTree_Data$SPECIES_CO)
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="wP"] <- " [White Pine]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="jP"] <- " [Jack Pine]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="Pl"] <- " [Other Pine]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="bS"] <- " [Black Spruce]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="wS"] <- " [White Spruce]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="bF"] <- " [Balsam Fir]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="tL"] <- " [Tamarack]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="tA"] <- " [Trembling Aspen]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="PO"] <- " [Other Poplar]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="wB"] <- " [White Birch]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="yB"] <- " [Yellow Birch]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="rM"] <- " [Red Maple]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="US"] <- " [*Unkown Softwood*]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="UH"] <- " [*Unknown Hardwood*]"
> MatureTree_Data$SPECIES_CO[MatureTree_Data$SPECIES_CO=="OH"] <- " [Other Hardwoods]"
> MatureTree_Data$YEAR <- as.factor(MatureTree_Data$YEAR)
>
> # data summaries
> summary(MatureTree_Data)
DISTRICT PLOT_NUM TREE_NUM PLOTKEY PLOTKEY_TREE YEAR SPECIES_CO TREE_STATU DBH TOTAL_HGT BA_cm2ha
16 : 728 16 : 728 16 : 728 Length:6327 Length:6327 2003 :1006 Length:6327 Length:6327 Min. : 1.80 Min. : 1.6 Min. : 4.072
9 : 564 9 : 564 9 : 564 Class :character Class :character 2000 : 970 Class :character Class :character 1st Qu.:11.20 1st Qu.: 8.6 1st Qu.: 157.633
10 : 513 10 : 513 10 : 513 Mode :character Mode :character 1999 : 940 Mode :character Mode :character Median :14.00 Median :10.4 Median : 246.301
15 : 489 15 : 489 15 : 489 2005 : 888 Mean :15.21 Mean :10.5 Mean : 328.496
8 : 463 8 : 463 8 : 463 1998 : 606 3rd Qu.:17.90 3rd Qu.:12.2 3rd Qu.: 402.639
14 : 456 14 : 456 14 : 456 2002 : 574 Max. :47.30 Max. :21.9 Max. :2811.461
(Other):3114 (Other):3114 (Other):3114 (Other):1343
BA_m2ha BASTAND_cm2ha BASTAND_m2ha BAHW_cm2ha BAHW_m2ha BASW_cm2ha BASW_m2ha BA_UPPER_cm2ha BA_UPPER_m2ha BA_MAX_cm2ha
Min. :0.0004072 Min. : 1328 Min. :0.1328 Min. : 0.0 Min. :0.00000 Min. : 2784 Min. :0.000 Min. : 3.154 Min. :0.0003154 Min. : 199.5
1st Qu.:0.0157633 1st Qu.:11132 1st Qu.:1.1132 1st Qu.: 0.0 1st Qu.:0.00000 1st Qu.:10694 1st Qu.:1.069 1st Qu.: 238.258 1st Qu.:0.0238258 1st Qu.: 517.8
Median :0.0246301 Median :14621 Median :1.4621 Median : 343.5 Median :0.03435 Median :13377 Median :1.338 Median : 410.531 Median :0.0410531 Median : 694.0
Mean :0.0328496 Mean :16742 Mean :1.6742 Mean : 1433.8 Mean :0.14338 Mean :15314 Mean :1.531 Mean : 542.346 Mean :0.0542346 Mean : 870.8
3rd Qu.:0.0402639 3rd Qu.:20004 3rd Qu.:2.0004 3rd Qu.: 1384.0 3rd Qu.:0.13840 3rd Qu.:18044 3rd Qu.:1.804 3rd Qu.: 693.689 3rd Qu.:0.0693689 3rd Qu.:1101.0
Max. :0.2811461 Max. :65523 Max. :6.5523 Max. :31894.1 Max. :3.18941 Max. :40272 Max. :4.027 Max. :4522.084 Max. :0.4522084 Max. :4660.6
NA's :1
BA_MAX_m2ha GROWTH GDD PCP LAT LONG ELEV_PROVIDED ELEV_INTERPOLATED GHI_INTERPOLATED SLOPE_INTERPOLATED
Min. :0.01995 Min. :0.01111 Min. :0.9842 Min. :0.9288 Min. :47.19 Min. :-58.73 Min. : 12.0 Min. : 11.0 Min. :2.890 Min. : 0.00078
1st Qu.:0.05178 1st Qu.:0.05000 1st Qu.:1.2748 1st Qu.:1.0660 1st Qu.:48.52 1st Qu.:-57.24 1st Qu.:106.0 1st Qu.:122.0 1st Qu.:3.074 1st Qu.: 4.42674
Median :0.06940 Median :0.10000 Median :1.3841 Median :1.1244 Median :49.03 Median :-56.22 Median :186.0 Median :190.0 Median :3.109 Median : 7.23443
Mean :0.08708 Mean :0.12476 Mean :1.3611 Mean :1.1645 Mean :49.05 Mean :-56.09 Mean :208.1 Mean :214.9 Mean :3.106 Mean : 9.13263
3rd Qu.:0.11010 3rd Qu.:0.17500 3rd Qu.:1.4770 3rd Qu.:1.2425 3rd Qu.:49.48 3rd Qu.:-55.08 3rd Qu.:295.0 3rd Qu.:308.0 3rd Qu.:3.139 3rd Qu.:12.48788
Max. :0.46606 Max. :1.00000 Max. :1.6458 Max. :1.5936 Max. :51.36 Max. :-52.77 Max. :553.0 Max. :527.0 Max. :3.345 Max. :42.10421
NA's :27 NA's :27 NA's :27 NA's :27 NA's :27 NA's :27
X
Mode:logical
NA's:6327
> str(MatureTree_Data)
'data.frame': 6327 obs. of 32 variables:
$ DISTRICT : Factor w/ 17 levels "1","2","4","5",..: 1 1 1 1 1 1 1 1 1 1 ...
$ PLOT_NUM : Factor w/ 17 levels "1","2","4","5",..: 1 1 1 1 1 1 1 1 1 1 ...
$ TREE_NUM : Factor w/ 17 levels "1","2","4","5",..: 1 1 1 1 1 1 1 1 1 1 ...
$ PLOTKEY : chr "1" "1" "1" "1" ...
$ PLOTKEY_TREE : chr "1" "1" "1" "1" ...
$ YEAR : Factor w/ 11 levels "1985","1989",..: 7 7 7 7 7 7 7 7 7 7 ...
$ SPECIES_CO : chr " [Black Spruce]" " [Balsam Fir]" " [Balsam Fir]" " [Balsam Fir]" ...
$ TREE_STATU : chr " [Live - lateral takeover]" " [Live - no defects]" " [Live - dead top]" " [Live - no defects]" ...
$ DBH : num 13.4 13 17.2 8 17.8 29.5 11 18.5 21.8 20 ...
$ TOTAL_HGT : num 7.2 9.1 10 6 10.1 14.5 9.2 11 10.6 13.4 ...
$ BA_cm2ha : num 225.6 212.4 371.8 80.4 398.2 ...
$ BA_m2ha : num 0.02256 0.02124 0.03718 0.00804 0.03982 ...
$ BASTAND_cm2ha : num 9230 12350 12350 12350 12350 ...
$ BASTAND_m2ha : num 0.923 1.235 1.235 1.235 1.235 ...
$ BAHW_cm2ha : num 9230 333 333 333 333 ...
$ BAHW_m2ha : num 0.923 0.0333 0.0333 0.0333 0.0333 ...
$ BASW_cm2ha : num 9230 12018 12018 12018 12018 ...
$ BASW_m2ha : num 0.923 1.202 1.202 1.202 1.202 ...
$ BA_UPPER_cm2ha : num 753 889 729 1021 703 ...
$ BA_UPPER_m2ha : num 0.0753 0.0889 0.0729 0.1021 0.0703 ...
$ BA_MAX_cm2ha : num 978 1101 1101 1101 1101 ...
$ BA_MAX_m2ha : num 0.0978 0.1101 0.1101 0.1101 0.1101 ...
$ GROWTH : num 0.1 0.1 0.1 0.325 0.425 0.025 0.05 0.1 0.1 0.05 ...
$ GDD : num 1.53 1.54 1.54 1.54 1.54 ...
$ PCP : num 1.3 1.29 1.29 1.29 1.29 ...
$ LAT : num 47.2 47.2 47.2 47.2 47.2 ...
$ LONG : num -53 -52.9 -52.9 -52.9 -52.9 ...
$ ELEV_PROVIDED : int 127 141 141 141 141 141 141 141 141 141 ...
$ ELEV_INTERPOLATED : int 87 94 94 94 94 94 94 94 94 94 ...
$ GHI_INTERPOLATED : num 3.12 3.14 3.14 3.14 3.14 ...
$ SLOPE_INTERPOLATED: num 2.29 12.55 12.55 12.55 12.55 ...
$ X : logi NA NA NA NA NA NA ...
> summary(ImmatureTree_Data)
DISTRICT PLOT_NUM TREE_NUM PLOTKEY PLOTKEY_TREE YEAR SPECIES_CO TREE_STATU DBH TOTAL_HGT AGE
1: 27 1: 27 1: 27 Length:40196 Length:40196 1994 :8705 Length:40196 Length:40196 Min. : 0.100 Min. : 1.300 Length:40196
2: 5231 2: 5231 2: 5231 Class :character Class :character 1998 :8101 Class :character Class :character 1st Qu.: 2.600 1st Qu.: 2.600 Class :character
4: 3508 4: 3508 4: 3508 Mode :character Mode :character 2002 :6819 Mode :character Mode :character Median : 4.900 Median : 4.200 Mode :character
5:12816 5:12816 5:12816 1989 :4892 Mean : 5.683 Mean : 4.515
6: 8710 6: 8710 6: 8710 1990 :3987 3rd Qu.: 8.000 3rd Qu.: 6.100
7: 7868 7: 7868 7: 7868 1985 :1715 Max. :30.600 Max. :16.400
8: 2036 8: 2036 8: 2036 (Other):5977
PLOT_SIZE_m2 BA_cm2ha BA_m2ha BASTAND_cm2ha BASTAND_m2ha BAHW_cm2ha BAHW_m2ha BA_UPPER_cm2ha BA_UPPER_m2ha BA_MAX_cm2ha
Min. : 20.0 Min. : 0.0013 Min. :1.300e-07 Min. : 44.6 Min. : 0.00446 Min. : 0.00 Min. :0.00000 Min. :-316.3 Min. :-0.03163 Min. : 2.262
1st Qu.: 70.0 1st Qu.: 2.2682 1st Qu.:2.268e-04 1st Qu.: 2658.8 1st Qu.: 0.26588 1st Qu.: 0.00 1st Qu.:0.00000 1st Qu.: 150.8 1st Qu.: 0.01449 1st Qu.: 166.190
Median : 100.0 Median : 8.4949 Median :8.495e-04 Median : 6079.0 Median : 0.60790 Median : 0.00 Median :0.00000 Median : 559.2 Median : 0.05557 Median : 608.212
Mean : 192.8 Mean : 26.5832 Mean :2.658e-03 Mean : 17885.8 Mean : 1.78858 Mean : 515.54 Mean :0.05053 Mean : 935.0 Mean : 0.09296 Mean : 956.434
3rd Qu.: 250.0 3rd Qu.: 27.1716 3rd Qu.:2.717e-03 3rd Qu.: 18756.3 3rd Qu.: 1.87563 3rd Qu.: 73.56 3rd Qu.:0.00721 3rd Qu.:1811.9 3rd Qu.: 0.18117 3rd Qu.:1822.647
Max. :1000.0 Max. :1560.9317 Max. :1.561e-01 Max. :882531.7 Max. :88.25317 Max. :15183.38 Max. :1.51834 Max. :2130.9 Max. : 0.21309 Max. :2131.277
NA's :801 NA's :232
BA_MAX_m2ha VOL_m3ha VOL_cm3ha GROWTH GDD PCP LAT LONG ELEV_PROVIDED ELEV_INTERPOLATED
Min. :0.0002262 Min. :0.0000001 Min. : 0.1 Min. :0.007692 Min. :1.053 Min. :0.9488 Min. :47.23 Min. :-55.91 Min. : 13.0 Min. : 24.0
1st Qu.:0.0166190 1st Qu.:0.0002639 1st Qu.: 263.9 1st Qu.:0.066667 1st Qu.:1.305 1st Qu.:1.0813 1st Qu.:48.30 1st Qu.:-55.13 1st Qu.: 60.0 1st Qu.: 69.0
Median :0.0608212 Median :0.0015200 Median : 1520.0 Median :0.125000 Median :1.438 Median :1.1809 Median :48.70 Median :-54.69 Median :116.0 Median :118.0
Mean :0.0956434 Mean :0.0077339 Mean : 7733.9 Mean :0.172492 Mean :1.407 Mean :1.2037 Mean :48.65 Mean :-54.66 Mean :116.9 Mean :123.7
3rd Qu.:0.1822647 3rd Qu.:0.0065559 3rd Qu.: 6555.9 3rd Qu.:0.240000 3rd Qu.:1.496 3rd Qu.:1.2669 3rd Qu.:48.99 3rd Qu.:-54.12 3rd Qu.:157.0 3rd Qu.:166.0
Max. :0.2131277 Max. :0.7735978 Max. :773597.8 Max. :1.475000 Max. :1.665 Max. :1.6313 Max. :49.61 Max. :-53.31 Max. :300.0 Max. :313.0
GHI_INTERPOLATED SLOPE_INTERPOLATED
Min. :3.014 Min. : 0.5763
1st Qu.:3.076 1st Qu.: 4.1655
Median :3.101 Median : 6.1261
Mean :3.096 Mean : 7.1956
3rd Qu.:3.116 3rd Qu.: 9.1594
Max. :3.178 Max. :26.6141
> str(ImmatureTree_Data)
'data.frame': 40196 obs. of 33 variables:
$ DISTRICT : Factor w/ 7 levels "1","2","4","5",..: 6 6 6 6 6 6 6 6 6 6 ...
$ PLOT_NUM : Factor w/ 7 levels "1","2","4","5",..: 6 6 6 6 6 6 6 6 6 6 ...
$ TREE_NUM : Factor w/ 7 levels "1","2","4","5",..: 6 6 6 6 6 6 6 6 6 6 ...
$ PLOTKEY : chr "7" "7" "7" "7" ...
$ PLOTKEY_TREE : chr "7" "7" "7" "7" ...
$ YEAR : Factor w/ 15 levels "1985","1986",..: 1 1 1 1 1 1 1 1 1 1 ...
$ SPECIES_CO : chr " [Balsam Fir]" " [Balsam Fir]" " [Balsam Fir]" " [Balsam Fir]" ...
$ TREE_STATU : chr " [Live - no defects]" " [Live - no defects]" " [Live - no defects]" " [Live - no defects]" ...
$ DBH : num 3.8 7.8 7.7 4.1 9.7 6.9 4.8 4.8 5.9 1.4 ...
$ TOTAL_HGT : num 4.4 6.3 6 4.7 7 5.3 4.1 4.4 4.3 2 ...
$ AGE : chr "21-40" "21-40" "21-40" "21-40" ...
$ PLOT_SIZE_m2 : int 40 40 40 40 40 40 40 40 40 40 ...
$ BA_cm2ha : num 3.17 13.37 37.25 21.12 11.82 ...
$ BA_m2ha : num 0.000317 0.001337 0.003725 0.002112 0.001182 ...
$ BASTAND_cm2ha : num 2084 2582 13915 40092 694 ...
$ BASTAND_m2ha : num 0.2084 0.2582 1.3915 4.0092 0.0694 ...
$ BAHW_cm2ha : num 0.637 291.799 0 NA 159.048 ...
$ BAHW_m2ha : num 6.37e-05 2.92e-02 0.00 0.00 1.59e-02 ...
$ BA_UPPER_cm2ha : num 1819.5 32.8 1785.4 377 14.2 ...
$ BA_UPPER_m2ha : num 0.18195 0.00328 0.17854 0.0377 0.00142 ...
$ BA_MAX_cm2ha : num 1822.6 46.2 1822.6 398.2 26.1 ...
$ BA_MAX_m2ha : num 0.18226 0.00462 0.18226 0.03982 0.00261 ...
$ VOL_m3ha : num 0.000586 0.003537 0.009388 0.00417 0.003476 ...
$ VOL_cm3ha : num 586 3537 9388 4170 3476 ...
$ GROWTH : num 0.18 0.12 0.02 0.02 0.12 0.04 0.1 0.04 0.04 0.06 ...
$ GDD : num 1.34 1.34 1.34 1.34 1.34 ...
$ PCP : num 1.52 1.52 1.52 1.52 1.52 ...
$ LAT : num 48 48 48 48 48 ...
$ LONG : num -55.6 -55.6 -55.6 -55.6 -55.6 ...
$ ELEV_PROVIDED : int 136 136 136 136 136 136 136 136 136 136 ...
$ ELEV_INTERPOLATED : int 152 152 152 152 152 152 152 152 152 152 ...
$ GHI_INTERPOLATED : num 3.11 3.11 3.11 3.11 3.11 ...
$ SLOPE_INTERPOLATED: num 9.6 9.6 9.6 9.6 9.6 ...
>
> # linear regression(s) - ALL
> Immature <- lm(GROWTH ~ DBH + TOTAL_HGT + AGE + BASTAND_m2ha + BAHW_m2ha + BA_UPPER_m2ha + BA_MAX_m2ha + GDD + PCP + SLOPE_INTERPOLATED + ELEV_INTERPOLATED + GHI_INTERPOLATED + TREE_STATU + SPECIES_CO, data=ImmatureTree_Data)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
> Mature <- lm(GROWTH ~ DBH + TOTAL_HGT + BASTAND_m2ha + BAHW_m2ha + BA_UPPER_m2ha + BA_MAX_m2ha + GDD + PCP + SLOPE_INTERPOLATED + ELEV_INTERPOLATED + GHI_INTERPOLATED + TREE_STATU + SPECIES_CO, data=MatureTree_Data)
>
> # linear regressions - RELATIONSHIPS
> Immature_Relationships <- lm(GROWTH ~ DBH + TOTAL_HGT + AGE + BASTAND_m2ha + BAHW_m2ha + BA_UPPER_m2ha + BA_MAX_m2ha + GDD + PCP + SLOPE_INTERPOLATED + ELEV_INTERPOLATED + GHI_INTERPOLATED + TREE_STATU + SPECIES_CO + GDD:SPECIES_CO + PCP:SPECIES_CO + SLOPE_INTERPOLATED:SPECIES_CO + ELEV_INTERPOLATED:SPECIES_CO + GHI_INTERPOLATED:SPECIES_CO, data=ImmatureTree_Data)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
> Mature_Relationships <- lm(GROWTH ~ DBH + TOTAL_HGT + BASTAND_m2ha + BAHW_m2ha + BA_UPPER_m2ha + BA_MAX_m2ha + GDD + PCP + SLOPE_INTERPOLATED + ELEV_INTERPOLATED + GHI_INTERPOLATED + TREE_STATU + SPECIES_CO + GDD:SPECIES_CO + PCP:SPECIES_CO + SLOPE_INTERPOLATED:SPECIES_CO + ELEV_INTERPOLATED:SPECIES_CO + GHI_INTERPOLATED:SPECIES_CO, data=MatureTree_Data)
>
> # linear regression(s) - SLIM
> Immature_Slim <- lm(GROWTH ~ DBH + BASTAND_m2ha + BAHW_m2ha + BA_UPPER_m2ha + BA_MAX_m2ha + GDD + PCP + TREE_STATU + SPECIES_CO, data=ImmatureTree_Data, na.action=na.exclude)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
> Mature_Slim <- lm(GROWTH ~ DBH + BASTAND_m2ha + BAHW_m2ha + BA_UPPER_m2ha + BA_MAX_m2ha + GDD + PCP + TREE_STATU + SPECIES_CO, data=MatureTree_Data, na.action=na.exclude)
答案 0 :(得分:0)
这是在准备数据时消除向量变化的问题。 TREE_STATU有“死亡植被”的例子。我最近的尝试尝试删除了。一旦准备好,TREE_STATU下只有一个关于&#39; live&#39;涉及不成熟数据帧的树。在成熟的数据框架中,活树的状态之间存在多个区别。一旦TREE_STATU从不成熟的数据帧中删除,模型就会运行。