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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -