[R] NADA Package: Referencing Data Frame Columns

Petr PIKAL petr.pikal at precheza.cz
Thu Aug 9 10:15:11 CEST 2012


Hi

> 
> > Specifically, since it has only a single detection indicator column
> > (ceneq1), it implies that within any single sample either all the 
analytes
> > were detected, or all were not. Not what I would expect.
> 
> Don,
> 
>    I have been thinking about this and wondered whether the cast format 
was
> appropriate just for the reason there's only a single censored 
indicator.
> I'm glad you confirmed this as the/one problem.
> 
> > As to your larger question of which layout is appropriate for use with
> > NADA functions, the answer is that either can be used. The "trick" is 
to
> > use the appropriate syntax to extract the values needed to pass the 
data
> > to a NADA function.
> 
>    And I've not discovered this in the time I spent trying different 
syntax.
> 
> > For the long format you subset the rows, then pass the appropriate
> > columns. Here's one way:
> >
> >   with(subset(chem, param=='AgDis') , ros(quant,ceneq1))
> 
>    This makes a lot of sense. I was thinking that I needed to create 
separate
> data frames for each parameter but subsetting on the fly is much more
> efficient and elegant.
> 
> > Hope this helps.
> 
>    It certainly does! Thanks.
> 
> > (p.s., I still think you'll be better off in the long run if you store
> > site, param, and maybe era, as character objects, not factors.)
> 
>    I need to research this because I thought that factors were character
> objects used to partition quantities into groups.

It is partly a matter of opinion. I personally prefer factors as they 
seems to me handier.

> a<-sample(letters[1:5], 20, replace=T)
> a
 [1] "c" "e" "c" "d" "c" "d" "b" "d" "d" "d" "b" "a" "d" "b" "c" "e" "e" 
"c" "c"
[20] "c"

Suppose I want to change all "c" and "b" to "f"

> a.f<-as.factor(a)
> a.f
 [1] c e c d c d b d d d b a d b c e e c c c
Levels: a b c d e
> levels(a.f)
[1] "a" "b" "c" "d" "e"

 In factors I can only change appropriate levels.

> levels(a.f)[2:3]<-"f"
> a.f
 [1] f e f d f d f d d d f a d f f e e f f f
Levels: a f d e

Regards
Petr




> 
> Regards,
> 
> Rich
> 
> ______________________________________________
> 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