Skip to content
Back to formatted view

Raw Message

Message-ID: <C0A48075-C887-45C5-9208-A857D4259BDC@comcast.net>
Date: 2011-01-26T19:57:36Z
From: David Winsemius
Subject: how could I choose subvector of a vector?
In-Reply-To: <347FA4FD-1C4F-4721-A381-2DF1040E9996@comcast.net>

On Jan 26, 2011, at 2:48 PM, David Winsemius wrote:

>
> On Jan 26, 2011, at 2:42 PM, Akram Khaleghei Ghosheh balagh wrote:
>
>> Hello ;
>> How could I choose subvector of a vctor. for example if  
>> v=c(1,2,5,0,1), how
>> could I chose the (1,2) or (1,2,5).
>
> ?"["
>
> v[ c(1,2,5) ]

I didn't notice at first that you wanted the values 1,2,5 ...(thought  
you wanted the 1st 2nd and 5th (obviously not correct with only a 4  
element vector)... so your values would be accessed with

v[1:3]


>
>> thanks;
>>
>> 	[[alternative HTML version deleted]]

David Winsemius, MD
West Hartford, CT