Some remarks:
If you refer to an earlier question, please provide a link to that question.
Of course we can find it, but more help from you leads to more help from us.
The first error/warning you get is often the most important.
When the mutate
is not done correctly how reliable would be the succeeding regression?
I changed the call for the type.convert
function with the data you provided in your last question.
Then the creation of data
works without errors/warnings.
However the regression still fails because the date
variable is not numeric (and in this dataset only one-valued).
The code I used you find below. My advice is to have a good look at the data before applying the software.
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyr)
library(tibble)
Species_measurement_merged <- structure(list(Art=c("Acerbuergerianum","Acerbuergerianum",
"Acerbuergerianum","Acerbuergerianum","Acerbuergerianum",
"Acerrufinerve","Acerrufinerve","Acerrufinerve","Acerrufinerve",
"Acerrufinerve","Carpinusjaponica","Carpinusjaponica","Carpinusjaponica",
"Carpinusjaponica","Carpinusjaponica","Celtisaustralis",
"Celtisaustralis","Celtisaustralis","Celtisaustralis","Celtisaustralis"
),Date=c("AMay","AMay","AMay","AMay","AMay","AMay","AMay",
"AMay","AMay","AMay","AMay","AMay","AMay","AMay","AMay",
"AMay","AMay","AMay","AMay","AMay"),Ind=c(1,2,3,4,
5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5),WaterPot_Dawn=c("NA",
"NA","0.41","0.59599999999999997","0.78","NA","NA","0.62",
"0.75","0.44800000000000001","0.12","0.48799999999999999",
"0.73","NA","NA","0.35499999999999998","0.28000000000000003",
"0.41","0.27800000000000002","0.505"),WaterPot_Noon=c("NA",
"NA","0.14000000000000001","0.28000000000000003","0.31","NA",
"NA","0.255","0.42","0.182","0.31","0.62","0.91","NA",
"NA","0.85","0.93","0.52","NA","NA"),ChloroCont=c("NA",
"NA","21.2","18.100000000000001","18.399999999999999","NA",
"NA","26.1","24.7","26","27.4","24.3","24.8","26.7","23.9",
"31.6","6.2","17.2","29.5","18.7"),Leaf_area=c("NA","NA",
"52.6","63.29","22.97","NA","NA","332","318.04000000000002",
"338.9","41.76","56.04","47.83","65.03","56.11","5.92",
"2.99","7","5.95","3.57"),Fresh_weight=c("NA","NA","1.1599999999999999",
"1.26","0.79","NA","NA","7.23","5.84","5.05","1.06","1.29",
"1.22","1.46","1.24","0.6","0.56999999999999995","0.61",
"0.62","0.6"),Dry_weight=c("NA","NA","0.26","0.27","0.1",
"NA","NA","2.25","1.84","1.6","0.31","0.39","0.3","0.44",
"0.37","4.7E-2","2.4E-2","3.5000000000000003E-2","4.9000000000000002E-2",
"3.9E-2"),DBH=c("NA","NA","18","14.8","9.8000000000000007",
"NA","NA","10","10","10.199999999999999","11.4","10","11.6",
"11.2","9.6","12","11.8","11.8","13.2","13.7"),Height=c("NA",
"NA","371","397","303","NA","NA","352","309","337","251",
"293","313","307","270","372","379","372","362","385"
),'1st_leaf'=c("NA","NA","189","179.5","185","NA","NA",
"182.5","169","178","157","173","195","168","164","196",
"210","185","189","195"),Axis_1=c("NA","NA","123","146",
"80","NA","NA","87","61","68","95","116","118","94",
"124","50","63","67","65","70"),Axis_2=c("NA","NA",
"112","106","90","NA","NA","92","58","63","81","104",
"133","105","109","94","68","69","59","53"),Canopy_size=c("NA",
"NA","182","217.5","118","NA","NA","169.5","140","159",
"94","120","118","139","106","176","169","187","173",
"190"),Leaf_dry_cont=c("NA","NA","0.22413793103448279",
"0.2142857142857143","0.12658227848101267","NA","NA","0.31120331950207469",
"0.31506849315068497","0.31683168316831684","0.29245283018867924",
"0.30232558139534882","0.24590163934426229","0.30136986301369861",
"0.29838709677419356","7.8333333333333338E-2","4.2105263157894743E-2",
"5.7377049180327877E-2","7.9032258064516137E-2","6.5000000000000002E-2"
),Crown_area=c("NA","NA","10502268.842726992","14099593.493017135",
"3558796.1579865171","NA","NA","5682839.5174491908","2074791.564234795",
"2853219.580731479","3029877.6188281402","6064027.8036651621",
"7757187.0699222777","5746726.945652592","6001262.9712366425",
"3464967.2573993024","3032667.3531045276","3621213.3208280397",
"2779073.8053165548","2952678.2153539266"),Specific_leaf=c("NA",
"NA","202.30769230769229","234.40740740740739","229.7","NA",
"NA","147.55555555555554","172.84782608695653","211.81249999999997",
"134.70967741935485","143.69230769230768","159.43333333333334",
"147.79545454545456","151.64864864864865","125.95744680851064",
"124.58333333333334","199.99999999999997","121.42857142857143",
"91.538461538461533")),row.names=c(NA,-20L),class=c("tbl_df",
"tbl","data.frame")) %>% as_tibble()
data <- Species_measurement_merged %>%
mutate(across(where(is.character), ~na_if(., "NA"))) %>%
type.convert(as.is=F)
Date.WPD.lm <- lm(Date ~ WaterPot_Dawn, data=data)
#> Warning in model.response(mf, "numeric"): using type = "numeric" with a factor
#> response will be ignored
#> Warning in Ops.factor(y, z$residuals): '-' not meaningful for factors
sapply(data,class)
#> Art Date Ind WaterPot_Dawn WaterPot_Noon
#> "factor" "factor" "integer" "numeric" "numeric"
#> ChloroCont Leaf_area Fresh_weight Dry_weight DBH
#> "numeric" "numeric" "numeric" "numeric" "numeric"
#> Height 1st_leaf Axis_1 Axis_2 Canopy_size
#> "integer" "numeric" "integer" "integer" "numeric"
#> Leaf_dry_cont Crown_area Specific_leaf
#> "numeric" "numeric" "numeric"
Created on 2023-01-02 with reprex v2.0.2