search for: colidx

Displaying 3 results from an estimated 3 matches for "colidx".

Did you mean: colid
2004 Jul 08
2
Getting elements of a matrix by a vector of column indice s
See if the following helps: > m <- outer(letters[1:5], 1:4, paste, sep="") > m [,1] [,2] [,3] [,4] [1,] "a1" "a2" "a3" "a4" [2,] "b1" "b2" "b3" "b4" [3,] "c1" "c2" "c3" "c4" [4,] "d1" "d2" "d3" "d4" [5,]
2012 Dec 12
2
using 'apply' to apply princomp to an array of datasets
Hi everyone, Suppose I have a 3D array of datasets, where say dimension 1 corresponds to cases, dimension 2 to datasets, and dimension 3 to observations within a dataset. As an example, suppose I do the following: > x <- sample(1:20, 48, replace=TRUE) > datasets <- array(x, dim=c(4,3,2)) Here, for each j=1,2,3, I'd like to think of datasets[,j,] as a single data matrix with
2003 Oct 27
2
how to select random rows ?
How can I select random subsets (rows!) from a data set ? If I generate simple data set > a <- data.frame(x=1:2, y = NaN, z = 2:1) > a x y z 1 1 NaN 2 2 2 NaN 1 I can select random subsets (colums) very easily using sample function: > sample(a, 2) z y 1 2 NaN 2 1 NaN I expected that using transpose of a would do the same for rows, but I am getting rather unexpected