R | Variable Information

If you want to know a little bit more about the variables you are working with try out these R commands.

  • is.na(x), is.null(x), is.array(x), is.data.frame(x)is.numeric(x), is.complex(x), is.character(x),… test for type; for a complete list, use methods(is)
  • length(x) number of elements in x
  • dim(x) Retrieve or set the dimension of an object; dim(x) <- c(3,2)
  • dimnames(x) Retrieve or set the dimension names of an object
  • nrow(x) number of rows; NROW(x) is the same but treats a vector as a onerow matrix
  • ncol(x) and NCOL(x) id. for columns
  • class(x) get or set the class of x; class(x) <- “myclass”
  • unclass(x) remove the class attribute of x
  • attr(x,which) get or set the attribute which of x
  • attributes(obj) get or set the list of attributes of obj