VincyaneBadouard / TreeData_broken

Harmonization and correction forest data tool.
https://vincyanebadouard.github.io/TreeData/
0 stars 1 forks source link

TwoValDiameterCor #77

Closed ValentineHerr closed 1 year ago

ValentineHerr commented 1 year ago

@VincyaneBadouard, I am looking into TwoValDiameterCor. Shouldn't the example fill in the NA's in DBHCor?

> library(data.table)
> data(TestData)
> 
> DataTree <- TestData[IdTree %in% "100771"]
> DataTree <- DataTree[order(Year)] # order de dt
> 
> DataTree$Diameter <- c(NA, 13, NA, 8, NA)
> 
> DBHCor <- DataTree$Diameter
> Time <- DataTree$Year
> 
> TwoValDiameterCor(DataTree,
+                   Data = TestData,
+                   DBHCor, Time,
+                   CorrectionType = "phylogenetic hierarchical",
+                   DBHRange = 10,
+                   MinIndividualNbr = 1, OtherCrit = NULL, DetectOnly = F)
$DBHCor
[1]       NA 13.00000       NA 13.05938       NA

$DataTree
   MinDBH IdCensus Year Month Day       Date    Site Cluster Plot PlotViewID Subplot PlotArea PlotElevation SubplotArea PlotLat PlotLon
1:  10.03     2016 2016     9  14 2016-09-14 Paracou    <NA>    6       <NA>       1     6.25            NA           0      NA      NA
2:  10.03     2017 2017     7  19 2017-07-19 Paracou    <NA>    6       <NA>       1     6.25            NA           0      NA      NA
3:  10.03     2018 2018     7   8 2018-07-08 Paracou    <NA>    6       <NA>       1     6.25            NA           0      NA      NA
4:  10.03     2019 2019     6   7 2019-06-07 Paracou    <NA>    6       <NA>       1     6.25            NA           0      NA      NA
5:  10.03     2020 2020     6   4 2020-06-04 Paracou    <NA>    6       <NA>       1     6.25            NA           0      NA      NA
   XPlotUTM YPlotUTM SubplotLat SubplotLon XSubplotUTM YSubplotUTM         ScientificName  VernName        Family       Genus    Species
1:       NA       NA         NA         NA          NA          NA Eschweilera decolorans maho noir Lecythidaceae Eschweilera decolorans
2:       NA       NA         NA         NA          NA          NA Eschweilera decolorans maho noir Lecythidaceae Eschweilera decolorans
3:       NA       NA         NA         NA          NA          NA Eschweilera decolorans maho noir Lecythidaceae Eschweilera decolorans
4:       NA       NA         NA         NA          NA          NA Eschweilera decolorans maho noir Lecythidaceae Eschweilera decolorans
5:       NA       NA         NA         NA          NA          NA Eschweilera decolorans maho noir Lecythidaceae Eschweilera decolorans
   Subspecies Variety Voucher IdLevel Authority CommercialSp LifeForm TreeFieldNum IdTree StemFieldNum        IdStem TreeLat TreeLon XTreeUTM
1:       <NA>    <NA>    <NA>    <NA>      <NA>        FALSE     tree          154 100771         <NA> 100771_1_auto      NA      NA       NA
2:       <NA>    <NA>    <NA>    <NA>      <NA>        FALSE     tree          154 100771         <NA> 100771_1_auto      NA      NA       NA
3:       <NA>    <NA>    <NA>    <NA>      <NA>        FALSE     tree          154 100771         <NA> 100771_1_auto      NA      NA       NA
4:       <NA>    <NA>    <NA>    <NA>      <NA>        FALSE     tree          154 100771         <NA> 100771_1_auto      NA      NA       NA
5:       <NA>    <NA>    <NA>    <NA>      <NA>        FALSE     tree          154 100771         <NA> 100771_1_auto      NA      NA       NA
   YTreeUTM XTreePlot YTreePlot XTreeSubplot YTreeSubplot LifeStatus Diameter BD Circ BCirc HOM  POM BHOM BPOM TreeHeight TreeFieldNumOriginal
1:       NA        NA        NA           NA           NA       TRUE       NA NA 94.5    NA 1.3 <NA>   NA <NA>         NA                  154
2:       NA        NA        NA           NA           NA       TRUE       13 NA 94.5    NA 1.3 <NA>   NA <NA>         NA                  154
3:       NA        NA        NA           NA           NA       TRUE       NA NA 94.5    NA 1.3 <NA>   NA <NA>         NA                  154
4:       NA        NA        NA           NA           NA       TRUE        8 NA 94.5    NA 1.3 <NA>   NA <NA>         NA                  154
5:       NA        NA        NA           NA           NA       TRUE       NA NA 94.5    NA 1.3 <NA>   NA <NA>         NA                  154
   IdTreeOriginal CommercialSpOriginal DateOriginal LifeStatusOriginal                 Comment DiameterCorrectionMeth   DBHCor
1:         100771                FALSE   2016-09-14               TRUE                                                      NA
2:         100771                FALSE   2017-07-19               TRUE                                                13.00000
3:         100771                FALSE   2018-07-08               TRUE                                                      NA
4:         100771                FALSE   2019-06-07               TRUE Abnormal diameter value                species 13.05938
5:         100771                FALSE   2020-06-04               TRUE                                                      NA

Warning message:
In `[.data.table`(DataTree, , `:=`(DBHCor, DBHCor)) :
  Invalid .internal.selfref detected and fixed by taking a (shallow) copy of the data.table so that := can add this new column by
 reference. At an earlier point, this data.table has been copied by R (or was created manually using structure() or similar). Avoid
 names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?
setnames and ?setattr. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can 
be fixed or this message improved.