[R] Help translating S-Plus command

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Nov 5 23:17:50 CET 2007


It would help if we knew what that command was supposed to do.  My guess 
is that you want the Tr$size with the smallest value of Tr$dev, in which 
case

Tr$size[which.min(Tr$dev)]

would seem to do it.  However, there are details like what is to happen if 
there are ties for the smallest value.

(There are simpler ways in S-PLUS to sort one variable by the values of 
another, for example Tr$size[sort.list(Tr$dev)] which works the same way 
as in R.)

On Mon, 5 Nov 2007, bernat at creaf.uab.es wrote:

> Dear all
> I have a small routine in S-Plus that I would like to use in R.  There are some small changes I've been able to adapt, but I don't know how to translate the line starting with "g1<-sort.col...." and the one "Size<- c(Size...")  (I also add some lines before)
> (...)
> Size<-NULL
> g<-cbind(Tr$dev,Tr$size)
> (...)
> g<-data.frame(g)
>
> # these next two lines are the ones I need help for
>
> g1 <- sort.col(target=g, columns.to.sort="@ALL", columns.to sort.by=list("g.1"), ascending=T)
> Size<-c(Size,g1[1,2])
>
> Thanks in advance
> Bernat
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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



More information about the R-help mailing list