[R] R as a non-functional language

Bill.Venables at csiro.au Bill.Venables at csiro.au
Sun Mar 20 06:08:52 CET 2011


The idiom I prefer is

pH <- structure(c(4.5,7,7.3,8.2,6.3), 
                names = c('area1','area2','mud','dam','middle')) 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Gabor Grothendieck
Sent: Sunday, 20 March 2011 2:33 PM
To: Russ.Abbott at gmail.com
Cc: r-help at r-project.org
Subject: Re: [R] R as a non-functional language

On Sun, Mar 20, 2011 at 12:20 AM, Russ Abbott <russ.abbott at gmail.com> wrote:
> I'm reading Torgo (2010) *Data Mining with
> R*<http://www.liaad.up.pt/~ltorgo/DataMiningWithR/code.html>in
> preparation for a class I'll be teaching next quarter.  Here's an
> example
> that is very non-functional.
>
>> pH <- c(4.5,7,7.3,8.2,6.3)
>> names(pH) <- c('area1','area2','mud','dam','middle')
>> pH
>  area1  area2    mud    dam middle
>   4.5    7.0    7.3    8.2    6.3
>
>
> This sort of thing seems to be quite common in R.

Try this:

pH <- setNames(c(4.5,7,7.3,8.2,6.3), c('area1','area2','mud','dam','middle'))




-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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



More information about the R-help mailing list