There are several replies to the question below, but I think there
must
> > exist a better way of doing so.
> > I just want to check whether all the elements of a vector are same. My
> > vector has one million elements and it is highly likely that there are
> > distinct
000))
> >
> > I want the answer as FALSE, which is clear from the first two
> > observations itself and we don't need to check for the rest.
> >
> > Does anybody know the most efficient way of doing this?
> >
> > Regards
> &
tor has one million elements and it is highly likely that there are
> > distinct elements in the first few itself. For example:
> >
> > > x = c(1,2,rep(1,10))
> >
> > I want the answer as FALSE, which is clear from the first two
> > observations itself and we
gt; Does anybody know the most efficient way of doing this?
>
> Regards
> Utkarsh
>
>
>
> From: Francisco J. Zagmutt <mailto:gerifalte28_at_hotmail.com
>
?Subject=Re:%20%5BR%5D%20Testing%20if%20all%20elements%20are%20equal%20in%20a%
> 20vector/matrix>>
>
>
t;> I just want to check whether all the elements of a vector are
>>>>> same. My
>>>>> vector has one million elements and it is highly likely that there
>>>>> are
>>>>> distinct elements in the first few itself. For example:
>>>>
>-Original Message- /
/>From: r-help-boun...@stat.math.ethz.ch /
/>[mailto:r-help-boun...@stat.math.ethz.ch] On Behalf Of Vincent Goulet /
/>Sent: Monday, August 29, 2005 3:35 PM /
/>To: r-h...@stat.math.ethz.ch /
/>Subject: [R] Testing if all elements are equal in a vector/matr
7; is an abbreviation of
'identical(TRUE,x)' so actually Vincent's solutions is "cleaner" than
using identical :)
Cheers
Francisco
/>From: "Doran, Harold" /
/>To: , /
/>Subject: Re: [R] Testing if all elements are equal in a vector/matrix /
/>Date:
7;t need to check for the rest.
>>>
>>> Does anybody know the most efficient way of doing this?
>>>
>>> Regards
>>> Utkarsh
>>>
>>>
>>>
>>> From: Francisco J. Zagmutt >> <http://gerifalte28
[correcting a stupid error in my previous post]
testTwoStages <- function(x, y, head.stop = 100){
if(!isTRUE(all(head(x, head.stop) == head(y, head.stop
{
print(paste("quick test returned FALSE"))
return(FALSE)
} else {
full.test = isTRUE(all(tail(x, length(x) - head.stop) == tail(
ue 30 Aug 2005 - 06:05:20 EST
> >
> >
> > Hi Doran
> >
> > The documentation for isTRUE reads 'isTRUE(x)' is an abbreviation
of
> > 'identical(TRUE,x)' so actually Vincent's solutions is "cleaner"
than
> > using
cumentation for isTRUE reads 'isTRUE(x)' is an abbreviation of
'identical(TRUE,x)' so actually Vincent's solutions is "cleaner" than
using identical :)
Cheers
Francisco
/>From: "Doran, Harold" mailto:hdo...@air.org>> /
/
%20in%20a%20vector/matrix>>
>>
>> Date: Tue 30 Aug 2005 - 06:05:20 EST
>>
>>
>> Hi Doran
>>
>> The documentation for isTRUE reads 'isTRUE(x)' is an abbreviation of
>> 'identical(TRUE,x)' so actually Vincent's solutions
lly Vincent's solutions is "cleaner" than
> using identical :)
>
> Cheers
>
> Francisco
>
> />From: "Doran, Harold" mailto:hdo...@air.org>> /
> />To: <mailto:vincent.gou...@act.ulaval.ca>>,
ate: Tue 30 Aug 2005 - 06:05:20 EST
>
>
> Hi Doran
>
> The documentation for isTRUE reads 'isTRUE(x)' is an abbreviation of
> 'identical(TRUE,x)' so actually Vincent's solutions is "cleaner" than
> using identical :)
>
> Cheers
>
&
cent's solutions is "cleaner" than
using identical :)
Cheers
Francisco
/>From: "Doran, Harold" /
/>To: , /
/>Subject: Re: [R] Testing if all elements are equal in a vector/matrix /
/>Date: Mon, 29 Aug 2005 15:49:20 -0400 /
/> /
>See ?id
15 matches
Mail list logo