You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear package maintainers, I created this issue since I would like to highlight a small problem within the package (which is discussed in greater detail here) but, first of all, I would like to thank you for your work since I've recently started learning about FDA and this package (with the companion book) is extremely useful.
Reprex of the problem (using the CRAN version of fda) taken from the scripts within this package:
library(fda)
#> Loading required package: splines#> Loading required package: fds#> Loading required package: rainbow#> Loading required package: MASS#> Loading required package: pcaPP#> Loading required package: RCurl#> Loading required package: deSolve#> #> Attaching package: 'fda'#> The following object is masked from 'package:graphics':#> #> matplot# Create an fd object represeting the weather in 4 canadian stationsfig1.11Stns= c('Montreal', 'Edmonton', 'Pr. Rupert', 'Resolute')
fig1.11Temp=CanadianWeather$dailyAv[
,
fig1.11Stns,
'Temperature.C'
]
Temp.fourier= create.fourier.basis(c(0, 365), 13)
fig1.11Temp.fd= Data2fd(day.5, fig1.11Temp, Temp.fourier)
class(fig1.11Temp.fd)
#> [1] "fd"# Compute the first derivative
deriv(fig1.11Temp.fd, 1) # fails#> Error in deriv.default(fig1.11Temp.fd, 1): invalid variable names# I need to explicitly call the S3 method:
deriv.fd(fig1.11Temp.fd, 1) |> plot()
Basically, according to the discussion in the SO post, it looks like there is a problem in the registration of the S3 method for the generic deriv since, currently, there is also an (unexported) deriv function defined inside the package,
is erroneously assigned to the (unexported) fda:::deriv function. Therefore, based on my understanding, when we call deriv on a fd object, R internally calls the S3 generic stats::deriv and that function has no idea about the existence of fda::deriv.fd since that was registered to fda:::deriv. IMO, the easiest approach to solve the problem (and permit the automatic S3 dispatch on fd objects) is to delete the definition of the (generic) deriv function defined in this package. Happy to create a PR if you want.
btw: if you want to test these changes, I made a fork of this repo and commented out the definition of deriv. After that and after reinstalling the package, everything works fine with the S3 dispatch.
Just for (also mine) future reference, I see exactly the same problem with mean.fd which is not registered as an S3 method of base::mean since there is a clash with the unexported fda:::mean:
Moreover, I noticed the warning that you added on top of the (re)definition of mean(), but I tried running R CMD check on the package without that line of code (see here) and everything runs smoothly (and I can also execute mean(...) on fd objects without the .fd suffix).
Dear package maintainers, I created this issue since I would like to highlight a small problem within the package (which is discussed in greater detail here) but, first of all, I would like to thank you for your work since I've recently started learning about FDA and this package (with the companion book) is extremely useful.
Reprex of the problem (using the CRAN version of
fda
) taken from the scripts within this package:Created on 2024-08-29 with reprex v2.0.2
Basically, according to the discussion in the SO post, it looks like there is a problem in the registration of the S3 method for the generic
deriv
since, currently, there is also an (unexported)deriv
function defined inside the package,fda/R/deriv.fd.R
Lines 1 to 2 in 04f5616
and, currently, the S3 method defined here
fda/R/deriv.fd.R
Lines 3 to 4 in 04f5616
and registered here
fda/NAMESPACE
Line 205 in 04f5616
is erroneously assigned to the (unexported)
fda:::deriv
function. Therefore, based on my understanding, when we callderiv
on afd
object, R internally calls the S3 genericstats::deriv
and that function has no idea about the existence offda::deriv.fd
since that was registered tofda:::deriv
. IMO, the easiest approach to solve the problem (and permit the automatic S3 dispatch onfd
objects) is to delete the definition of the (generic)deriv
function defined in this package. Happy to create a PR if you want.btw: if you want to test these changes, I made a fork of this repo and commented out the definition of
deriv
. After that and after reinstalling the package, everything works fine with the S3 dispatch.Session info
The text was updated successfully, but these errors were encountered: