This does what I was hoping it would: aggregate(tm[,-1],by=list(tm[,10]),FUN="mean") but I don't know what "tm[,-1]" means (well - the -1 bit anyway. Does it somehow means the whole matrix? Please don't tell me to check the manual - I tried and failed dismally... -- View this message in context: http://n4.nabble.com/tm-1-tp1588804p1588804.html Sent from the R help mailing list archive at Nabble.com.
Please do check the Intro to R manual. Hint: section 2.7.3 ** 1. *A vector of negative integral quantities*. Such an index vector specifies the values to be *excluded* rather than included. Thus > y <- x[-(1:5)] gives y all but the first five elements of x. On Thu, Mar 11, 2010 at 6:22 AM, ManInMoon <xmoon2000@googlemail.com> wrote:> > This does what I was hoping it would: > > aggregate(tm[,-1],by=list(tm[,10]),FUN="mean") > > but I don't know what "tm[,-1]" means (well - the -1 bit anyway. > > Does it somehow means the whole matrix? > > > > Please don't tell me to check the manual - I tried and failed dismally... > > > -- > View this message in context: > http://n4.nabble.com/tm-1-tp1588804p1588804.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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
-----Mensaje original----- De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] En nombre de ManInMoon Enviado el: jueves, 11 de marzo de 2010 12:22 Para: r-help at r-project.org Asunto: [R] tm[,-1] This does what I was hoping it would: aggregate(tm[,-1],by=list(tm[,10]),FUN="mean") but I don't know what "tm[,-1]" means (well - the -1 bit anyway. Does it somehow means the whole matrix? --- No, it means the matrix 'tm' minus the 1st column, (a <- matrix(rnorm(16,4,5),4,4)) a[,-1] ____________________________________________________________________________________ Dr. Rub?n Roa-Ureta AZTI - Tecnalia / Marine Research Unit Txatxarramendi Ugartea z/g 48395 Sukarrieta (Bizkaia) SPAIN
I think (but I didn't follow what you're trying to do and what is what) that it means the whole matrix (tm) except the first column (therefore the "-" sign) Ivan Le 3/11/2010 12:22, ManInMoon a ?crit :> This does what I was hoping it would: > > aggregate(tm[,-1],by=list(tm[,10]),FUN="mean") > > but I don't know what "tm[,-1]" means (well - the -1 bit anyway. > > Does it somehow means the whole matrix? > > > > Please don't tell me to check the manual - I tried and failed dismally... > > >-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. S?ugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php
On 11.03.2010 12:22, ManInMoon wrote:> > This does what I was hoping it would: > > aggregate(tm[,-1],by=list(tm[,10]),FUN="mean") > > but I don't know what "tm[,-1]" means (well - the -1 bit anyway. > > Does it somehow means the whole matrix? > > > > Please don't tell me to check the manual - I tried and failed dismally...But we tell you to do exactly that and ask you to read how indexing works, otherwise we will get dozens of even simpler questions (almost impossible, though). Maybe someone is voluntaring to answer if you do not hide yourself behind the moon any more, ManInMoon. Uwe Ligges>
On Thu, 11 Mar 2010 03:22:27 -0800 (PST) ManInMoon <xmoon2000 @googlemail.com> wrote:> but I don't know what "tm[,-1]" means (well - the -1 bit anyway. > > Does it somehow means the whole matrix?No, it means everything except the first column.> Please don't tell me to check the manual - I tried and failed dismally...Sorry. Please type: ?"[" -- Karl Ove Hufthammer
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of ManInMoon > Sent: Thursday, March 11, 2010 4:22 AM > To: r-help at r-project.org > Subject: [R] tm[,-1] >[snip]> > > Please don't tell me to check the manual - I tried and failed > dismally... >But often the best answer is to read the manual, or reread the manual, there is nothing wrong with asking for suggestions on which parts of the manual to read (there is a lot out there now), or for clarifications of parts that you do not understand. If you can tell why you failed, then that gives others information that can be used to improve the manuals, but what you said is very unhelpful. There seems to be more and more people that feel a quick answer on the list is preferable to trying to understand the manuals. What if someone asked about the best shape for a wheel and did not want to read the manual, they mention that they have a square wheel that doesn't work, and when they tried a triangle it was even worse. Someone else then replies that they have had better luck with pentagons and hexagons look promising. Someone else mentions that they tried and octagon and it worked even better. Then someone comes in with the theory that a decagon would be even better, provided you can create a regular decagon, but they unfortunately have only succeeded at creating irregular ones that don't work as well as the octagon. A side branch then develops discussing smooth shapes of constant radius that would work as rollers, but don't quite work as wheels. All this time the manual has a good description of circles used as wheels including a simple way to make them, but you won't look there, so you are doomed to a suboptimal solution. Let's look at the replies you received for the tm[,-1] query. They were of 2 general types: "go read the manual anyway" (which I would consider the best answer) and "it means the matrix without the 1st column" which is a dodecagon type answer, consider the following:> tm <- matrix(1:12, ncol=3) > tm[,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12> tm[,-1][,1] [,2] [1,] 5 9 [2,] 6 10 [3,] 7 11 [4,] 8 12 OK, tm is a matrix and tm[,-1] looks like the same matrix without the 1st column. But what if we change the example a little bit:> tm <- matrix(1:8, ncol=2) > tm[,1] [,2] [1,] 1 5 [2,] 2 6 [3,] 3 7 [4,] 4 8> tm[,-1][1] 5 6 7 8 This result looks different, what happened? And what should you do if you want results more like the first example? The answer is in the manual ?"[". -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111 -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111