Displaying 1 result from an estimated 1 matches for "elimnovar".
2002 May 11
1
deleting invariant rows and cols in a matrix
...of bounds for obvious reasons you'll see
shortly.
Start with some data
x <- read.table("myex.dat",header=T)
x
v1 v2 v3 v4 v5 id
1 1 0 1 2 4 1
2 1 1 1 1 1 2
3 1 2 3 1 4 3
4 1 3 4 2 4 4
5 2 2 2 2 2 5
Here's my function
---- begin R code ----
elimnovar <- function(x,first.item=NULL,nitems=NULL,responses=NULL){
# Data prep - store as matrix, strip off id's, get variable names
dat <- as.matrix(x)
item.dat <- dat[,first.item:(first.item + nitems - 1)]
inames <- dimnames(item.dat)[[2]]
# Eli...