R/S differences
Andreas Weingessel
Andreas.Weingessel@ci.tuwien.ac.at
Fri, 13 Feb 1998 15:18:26 +0100
I noted the following R/S differences:
*) read.table behaves differently when determining the rownames. If
row.names is not given, S+ uses the first nonnumeric field with no
duplicates as the row names, whereas R uses 1:n as rownames in this case.
*) In S+ it is possible to sum over the lines of a data.frame. The
behavior of R might be more accurate in that situation, since a
data.frame is a list, but this causes problems, if one wants to use
code written for S+ in R.
S> aa<-data.frame(matrix(1:4,nrow=3D1))
S> sum(aa)
[1] 10
R> aa<-data.frame(matrix(1:4,nrow=3D1))
R> sum(aa)
Error in sum(..., na.rm =3D na.rm) : invalid argument type
*) The as.vector argument removes the vector names in S+. I do not
think that this difference can cause any problems, but I report it
just for completeness.
R> aa<-1:3
R> names(aa)<-letters[1:3]
R> as.vector(aa)
a b c=20
1 2 3=20
R> names(as.vector(aa))
[1] "a" "b" "c"
S> aa<-1:3
S> names(aa)<-letters[1:3]
S> as.vector(aa)
[1] 1 2 3
S> names(as.vector(aa))
NULL
As a final question. Does anyone know whether there is code for
nnls.fit (Linear least-squares fit with coefficients constrained to be
nonnegative.) available for R?
Thanks,
Andreas
************************************************************************
* Andreas Weingessel *
************************************************************************
* Institut f=FCr Statistik * Tel: (+43 1) 58801 4541 =
*
* Technische Universit=E4t Wien * Fax: (+43 1) 504 14 98 =
*
* Wiedner Hauptstr. 8-10/1071 * Andreas.Weingessel@ci.tuwien.ac.at *
* A-1040 Wien, Austria * http://www.ci.tuwien.ac.at/~weingessel *
************************************************************************
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._