[R] Question on apply()

Petr Pikal petr.pikal at precheza.cz
Mon Sep 18 08:43:19 CEST 2006


not much information about what can be wrong. As nobody knows your 
Xarray and SmoothList it is hard to guess. You even omitted to show 
what "does not work"
So here are few guesses.

predict usually expects comparable data
apply(Xarray, 2, NewValues,LIST=SmoothList)


On 18 Sep 2006 at 8:05, Gunther Höning wrote:

From:           	Gunther Höning <gunther.hoening at ukmainz.de>
To:             	<r-help at stat.math.ethz.ch>
Date sent:      	Mon, 18 Sep 2006 08:05:28 +0200
Subject:        	[R] Question on apply()

>  Dear list,
> I try to do the following:
> I have an list of length n, with elements done by smooth.spline
> (SmoothList).
> Now I have a matrix with n rows and m columns with x-values(Xarray)
> Now I want ot predict the y-values. Therefor I want to take the first
> element of SmoothList and the first row of Xarray and predict for each
> element in Xarray the y value. And then take the second element of
> SmoothList and second row of Xarray, third row of SmoothList and third
> row of Xarray and so on....
> I tried following:
> NewValues <- function(x,LIST){predict(LIST,x)}
> apply(Xarray, 2, NewValues,SmoothList)
> But it don't work.
> Could anybody help please ?
> Gunther
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.

Petr Pikal
petr.pikal at precheza.cz

More information about the R-help mailing list