Closed alequech closed 3 years ago
Hi. The following will work... use the data frame interface instead... and calling npudens() will invoke npudensbw() with default (options can be passed through npudens())...
library(datasets)
library(np)
## Turn off I/O
options(np.messages=FALSE)
data(iris)
myfunction <- function(df_cat, f){
npudens(tdat = df_cat)
}
kernel_iris <- myfunction(df_cat = iris, f = formula_d)
Hi,
I'm trying to write a custom function that includes
npudens
, butnpudens
is giving me the following errorError in is.data.frame(data) : object 'df_cat' not found
The following is a reproduction of the error using the iris dataset
on the other hand, if I try the same thing outside of myfunction the calculation is completed properly.
My final goal is to be able to calculate in parallel a Kernel Density for each factor of the Species column, for this I plan to use myfuntion inside a foreach() or parLapply().
I almost forgot my sessionInfo()