Re: [R] simple usage of "for"

From: Hans Ekbrand <hans_at_sociologi.cjb.net>
Date: Tue, 19 Feb 2008 16:07:53 +0100

On Tue, Feb 19, 2008 at 10:04:13AM -0500, Duncan Murdoch wrote:
> On 2/19/2008 9:24 AM, Hans Ekbrand wrote:

[...]

> > I tried the following small code snippet which I copied from the
> > "Introduction to R":
> >
> >> for (i in 2:length(meriter)) { table(meriter[[1]], meriter[[i]]) }
>
> Where did you find that? I don't see anything like it. (If there is
> something like that, it should be fixed.)
>
> If you are referring to this snippet:
>
> >for (i in 1:length(yc)){
> plot(xc [[i ]],yc [[i ]]);
> abline(lsfit(xc [[i ]],yc [[i ]]))
> }

Yes, I copied the for construct from that snippet.

> then it has the important difference that plot() and abline() both have
> side effects (they do plotting), whereas table() doesn't.

I see. Thanks for the explanation.

-- 
Hans Ekbrand

______________________________________________ R-help_at_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.

Received on Tue 19 Feb 2008 - 15:10:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Feb 2008 - 15:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive