[R] 2 samples KS-test...

Prof Brian Ripley
Mon, 16 Apr 2007 10:36:27 -0000

On Mon, 16 Apr 2007, St?phane CRUVEILLER wrote:

> Dear R-users,
>
> I have some trouble to perform a 2-samples KS test.
> Apparently my 2 samples are numerical (see below) but R

That says there are data frames, not numeric vectors. That would be easier
to see if you printed the value (rather than use str(), which is often
helpful but not so here to you at least).

You want

x = subset(mydata,Identified=="NO")$KD

etc, I think.

> complains that the "y" term is not....
>
>
-------------------------------------------------------------------------------------
> > str(subset(mydata,Identified=="NO",select=KD))
> 'data.frame':   2889 obs. of  1 variable:
> $ KD: num  -0.272 -0.080 -0.311 -0.222 -0.346 ...
> > str(subset(mydata,Identified=="YES",select=KD))
> 'data.frame':   443 obs. of  1 variable:
> $ KD: num  -0.0772 -0.6635 -0.1283 -0.0748 -0.3036 ...
> >
>
ks.test(x=subset(mydata,Identified=="NO",select=KD),y=subset(mydata,Identified=="YES",select=KD))
> Erreur dans ks.test(x = subset(mydata, Identified == "NO", select
= KD),  :
>        'y' doit ?tre num?rique ou bien une cha?ne de caract?res
donnant
> le nom de la fonction ad?quate
>
-----------------------------------------------------------------------------------------
>
> Thanks for any hint,
>
> St?phane.
>
> Conf: R-2.4.1 on win XP sp2.
>
>

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595