Hi r-help-boun...@r-project.org napsal dne 02.02.2011 11:14:18:
> Hi > > r-help-boun...@r-project.org napsal dne 31.01.2011 15:51:16: > > > > > > > <snip> > > > > > > > > > > > > Hi > > > > thanks. I am not sure if I have understood 100% but at least I know now > that > > there's a diference. > > > > About this: > > > > lapsales > > Store Prod qtd > > 5 Aveiro Lapiseira 3 > > 8 Coimbra Lapiseira 1 > > 9 Setubal Lapiseira 1 > > > lapsales[max(lapsales$qtd),"Store"] > > [1] Setubal > > Levels: Aveiro Coimbra Evora lx Setubal > > > > why Setubal and not Aveiro? > > > > > > Can you explain me the result? Sorry I did not look to your code and used the code I sent you as a solution What do you expect max(lapsales$qtg) give you as a result? If you changed the number qtd to 4 instead of 3 you will get > lapsales[max(lapsales$qtd),"Store"] [1] <NA> Levels: Aveiro Coimbra Evora lx Setubal So R give you what you ask for. You asked for third line and you got it. If you asked for which position is the maximum number lapsales[which.max(lapsales$qtd),"Store"] [1] Aveiro Levels: Aveiro Coimbra Evora lx Setubal You will get desired result. Regards Petr > > Probably qtd is not what you think it is. I get > > > dados<- data.frame(Store = c > ("Setubal","lx","Aveiro","Coimbra","Aveiro","Evora","Aveiro","Coimbra","Setubal"),Prod=c > ("BlocoDesenho","BlocoDesenho","Tinteiro","Régua","Lapiseira","Regua","Tinteiro","Lapiseira","Lapiseira"),qtd=c > (2,1,2,1,3,1,1,1,1)) > > lapsales <- dados[dados$Prod=="Lapiseira", ] > > lapsales[which.max(lapsales[ , "qtd" ]), "Store"] > [1] Aveiro > Levels: Aveiro Coimbra Evora lx Setubal > > > > and > > > str(lapsales) > 'data.frame': 3 obs. of 3 variables: > $ Store: Factor w/ 5 levels "Aveiro","Coimbra",..: 1 2 5 > $ Prod : Factor w/ 5 levels "BlocoDesenho",..: 2 2 2 > $ qtd : num 3 1 1 > > Maybe you get something different. > > Regards > Petr > > > > > > > > > thanks > > AD > > -- > > View this message in context: > http://r.789695.n4.nabble.com/Help-in-getting- > > info-from-a-DataFrame-tp3247740p3248883.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. > > ______________________________________________ > 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. ______________________________________________ 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.