R/rowsAndColumns.R

Defines functions rows columns

Documented in columns rows

columns <- function(z){
  ## returns a list of the columns in z
  x <- as.matrix(z)
  n <- ncol(x)
  xlist <- vector("list", n)
  for(i in 1:n)
    xlist[[i]] <- x[,i]
  if(length(cn <- colnames(x)) == n)
    names(xlist) <- cn
  xlist
}

rows <- function(z){
  ## returns a list of the rows in z
  x <- as.matrix(z)
  n <- nrow(x)
  xlist <- vector("list", n)
  for(i in 1:n)
    xlist[[i]] <- x[i,]
  if(length(rn <- rownames(x)) == n)
    names(xlist) <- rn
  xlist
}

Try the tis package in your browser

Any scripts or data that you put into this service are public.

tis documentation built on Sept. 29, 2021, 1:06 a.m.