r - error with interpSpline function -
i have list of data frames, xyz, , in every data frame there 2 numeric vectors (x , y). want apply interpspline function package splines x , y, when :
lapply(xyz, function (x){ x%>% interpspline(x,y) })
i following error:
error in data.frame(x = as.numeric(obj1), y = as.numeric(obj2)) :
(list) object cannot coerced type 'double'
it doesn't work because interpspline
doesn't take data frame first argument.
xyz <- list(data.frame(x=rnorm(10),y=rnorm(10)), data.frame(x=rnorm(10),y=rnorm(10))) library(splines) sf <- function(d) with(d,interpspline(x,y))) s <- lapply(xyz,sf)
you use interpspline(d$x,d$y)
. might possible enough contortions interpspline
work pipes, hardly seems worth trouble ...
Comments
Post a Comment