Message-ID: <CAM_vju=p-EAAj6=NY0OfudbUixrAUnQtit+=2cEYJQeV_q6kmA@mail.gmail.com>
Date: 2011-12-12T13:38:43Z
From: Sarah Goslee
Subject: shorter way of coding
In-Reply-To: <4B46FB7EED800046A5952FCFA92D3BA0347DF578DB@HGUMAIL6.hgu.gu.se>
This isn't a reproducible example, so I can't provide code,
but I would put all the y variables in a list and use lapply().
Sarah
On Mon, Dec 12, 2011 at 8:16 AM, Mintewab Bezabih
<Mintewab.Bezabih at economics.gu.se> wrote:
> Dear R users,
>
> I am using the code below to generate a fitted value of b. I have about 300 different values for for y (y1, y2, ...y300) which means I will have to write the code below 300 times to generate the 300 different fitted values for y. Is there a short way of doing that ?
>
> Many thanks in advance
> Mintewab
>
> library(mgcv)
> dat <- read.table("e:/minti's laptop/C/GBG/allround_survey/rainfallGPS.csv", header=T, sep=",")
> b<-gam(y1~s(x1, x2, k=100),data=dat)
> vis.gam(b)
> fitted(b)
--
Sarah Goslee
http://www.functionaldiversity.org