[R] Help in getting info from a DataFrame

David Winsemius
Sun, 30 Jan 2011 23:05:47 -0000

On Jan 30, 2011, at 5:27 PM, ADias wrote:

> dados<-
> data
> .frame
> (Store
> =
> c
> ("Setubal
> ","lx
> ","Aveiro
> ","Coimbra
>
","Aveiro","Evora","Aveiro","Coimbra","Setubal"),Prod=c("Bloco
> Desenho","Bloco
> Desenho
> ","Tinteiro
> ","R?gua
> ","Lapiseira
> ","Regua
>
","Tinteiro","Lapiseira","Lapiseira"),qtd=c(2,1,2,1,3,1,1,1,1))


See if this is a more useful approach:

 > lapsales <- dados[dados$Prod=="Lapiseira",  ]
 > lapsales[which.max(lapsales[ , "qtd" ]), "Store"]
[1] Aveiro
Levels: Aveiro Coimbra Evora lx Setubal

--
David Winsemius, MD
West Hartford, CT