R/S Difference - split

Andreas Weingessel Andreas.Weingessel@ci.tuwien.ac.at
Wed, 7 Jan 1998 19:43:05 +0100


In S it is possible to "split" a matrix into its rows, using
split(matrix, 1:number_of_rows). This is not possible in R.

Example:

R:
R> split(matrix(rnorm(1:20),4, 5), 1:4)
Error in split(x, as.factor(f)) : argument lengths differ


S:
> split(matrix(rnorm(1:20),4, 5), 1:4)
$"1":
[1] -0.1804794  0.5269439  0.6248224 -0.3243427 -1.2987407

$"2":
[1]  0.9384254 -1.7596400  1.1210493 -0.2711708  0.7039623

$"3":
[1] -0.02645670  0.81864215  0.58816596 -0.42465974 -0.02682458

$"4":
[1] -0.5523629 -0.7176803  0.3159648  0.7787409  1.6325061



************************************************************************
*                          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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._