My code is as follows:
lat <- 24.419
lon <- 54.502
days <- 1
Tmax <- 44.3
Tmin <- 26.0
tal <- 0.72
BCb_guess <- 0.13
epsilon <- 0.5
rad_mea <- 254
sirad::bccal(lat, days, rad_mea, extraT = NULL, Tmax, Tmin, tal)
When I execute my function bccal()
from the sirad
package, I get the following error:
Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
invalid 'trim' argument
I am completely new to R any help in solving the issue will be highly appreciated, Thanks
Not sure if this is causing the error you're getting, but I think you have the date
argument wrong. You're giving it the number of days you want to calculate for, but bccal
(and most other functions in R) can infer this from the length of other arguments.
The date
argument should be a vector of the actual dates you want to calculate this for. For example:
# for one day
lat <- 24.419
lon <- 54.502
days <- as.Date('2015-06-22')
Tmax <- 44.3
Tmin <- 26.0
tal <- 0.72
BCb_guess <- 0.13
epsilon <- 0.5
rad_mea <- 254
sirad::bccal(lat, days, rad_mea, extraT = NULL, Tmax, Tmin, tal)
# for several days
lat <- 24.419
lon <- 54.502
days <- c(as.Date('2015-06-22'), as.Date('2015-07-16'))
Tmax <- c(44.3, 43.7)
Tmin <- c(26.0, 25.1)
tal <- 0.72
BCb_guess <- 0.13
epsilon <- 0.5
rad_mea <- c(254, 253)
sirad::bccal(lat, days, rad_mea, extraT = NULL, Tmax, Tmin, tal)
I have debugged this. the bccal function is defined here .
https://github.com/cran/sirad/blob/master/R/bccal.R
the problem is coming in line 16 .
dtempM <- mean(as.numeric(aggregate(Zdtemp, by = format(time(Zdtemp),
"%m"), FUN = mean, na.rm = TRUE)), na.rm = T)
specifically here
format(time(Zdtemp), "%m")
I dont really know what you want to achieve(dont have a clue about bccal ,all i can say its dependent on Tmax,Tmin and days) ,so thats all I can do for now. may be it would ring a bell for you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With