Re: [R] Help! What does this R command mean?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [R] Help! What does this R command mean?

Gabor Grothendieck
I think that a pointer to ?formula needs to be added to ?":"


On 1/31/06, Liaw, Andy <[hidden email]> wrote:

> ":" in a formula is not the same as ":" otherwise!
>
> Andy
>
> From: Ionut Florescu
> >
> > a:b means - all the element in the vector from a to b
> > a[,-1] means for the matrix a keep all the rows but not the last or
> > first -can't remember column.
> > When in doubt do what I do make a small matrix and apply the
> > command see
> > what it does.
> > After this:
> >  > a=matrix(c(1:9),3,3)
> >  > a[,-1]
> >      [,1] [,2]
> > [1,]    4    7
> > [2,]    5    8
> > [3,]    6    9
> >
> > you see that -1 eliminates the first column.
> > I found the R manual useless myself.
> > The only thing useful is the search function in the html
> > help. That has
> > examples.
> >
> > Ionut Florescu
> >
> > Michael wrote:
> > > Hi all,
> > >
> > > R is so difficult. I am so desperate.
> > >
> > > What does the ":" mean in the following statement?
> > >
> > > What does the "[, -1]" mean?
> > >
> > >
> > >> # Leaps takes a design matrix as argument: throw away the intercept
> > >> # column or leaps will complain
> > >>
> > >> X <- model.matrix(lm(V ~ I + D + W +G:I + P + N,
> > election.table))[,-1]
> > >>
> > >
> > > Thanks a lot!
> > >
> > >     [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> > >
> > >
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
> >
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] Help! What does this R command mean?

Duncan Murdoch
On 1/31/2006 4:55 PM, Gabor Grothendieck wrote:
> I think that a pointer to ?formula needs to be added to ?":"

Good suggestion; I'll do it.

Duncan Murdoch

>
>
> On 1/31/06, Liaw, Andy <[hidden email]> wrote:
>> ":" in a formula is not the same as ":" otherwise!
>>
>> Andy
>>
>> From: Ionut Florescu
>>> a:b means - all the element in the vector from a to b
>>> a[,-1] means for the matrix a keep all the rows but not the last or
>>> first -can't remember column.
>>> When in doubt do what I do make a small matrix and apply the
>>> command see
>>> what it does.
>>> After this:
>>>  > a=matrix(c(1:9),3,3)
>>>  > a[,-1]
>>>      [,1] [,2]
>>> [1,]    4    7
>>> [2,]    5    8
>>> [3,]    6    9
>>>
>>> you see that -1 eliminates the first column.
>>> I found the R manual useless myself.
>>> The only thing useful is the search function in the html
>>> help. That has
>>> examples.
>>>
>>> Ionut Florescu
>>>
>>> Michael wrote:
>>>> Hi all,
>>>>
>>>> R is so difficult. I am so desperate.
>>>>
>>>> What does the ":" mean in the following statement?
>>>>
>>>> What does the "[, -1]" mean?
>>>>
>>>>
>>>>> # Leaps takes a design matrix as argument: throw away the intercept
>>>>> # column or leaps will complain
>>>>>
>>>>> X <- model.matrix(lm(V ~ I + D + W +G:I + P + N,
>>> election.table))[,-1]
>>>> Thanks a lot!
>>>>
>>>>     [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide!
>>> http://www.R-project.org/posting-guide.html
>>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide!
>>> http://www.R-project.org/posting-guide.html
>>>
>>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel