So, with R you use object[int,int] to select the rows and columns you want
to highlight. ([rows,columns]); what you've done here is asked it to apply
to rows 1 to 2 (1:2), across all columns. You'll want [,3:4] to specify two
particular columns. I'm not familiar enough with glm itself to provide any
further guidance (I'll leave that to other readers) but when it comes to
automation, you might want to look at the mapply function (type ?mapply) or
the plyr package, particularly ddply (?ddply). With ddply you can (for
example) split by year and week, execute a function within ddply on
specified variables, and then recombine into one dataset consisting of
Year, Week and Relationship.

Assuming it works - like I said, not particularly familiar with glm :)

On Mon, Jan 14, 2013 at 12:08 AM, bhatmb <mansi.bhatnagar@alumni.utoronto.ca
> wrote:

> Hi Everyone,
>
> I am new to R and am figuring my way around it. I am trying to determine
> the
> relationship between A &B, for each week of the year.
>
> My dataset looks like:
> Year    Week    A                      B
> 1982    1       11.3           198.53
> 1982    2       14.4    309.00
> 1982    3       23.2    325.49
>
> When i tried to run glm on just the first entry using [1,] i got the error:
> Error in nmod2$R4.2w[1, ] : incorrect number of dimensions
>
> My edited  code for glm is: abundmod1<-glm(R4.2w~N_4,data=nmod1[1:2,])
>
> Does this code still just use the information from the first week? Also
> since I have to run it for more than 10 years worth of data for 15 weeks,
> is
> there a faster way?
>
> Thank you so much in advance!
>
> Mansi
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/GLM-Modelling-help-needed-tp4655438.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org 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.
>

	[[alternative HTML version deleted]]

