Description Usage Arguments Details Value Author(s) Examples
colclasses
returns the classes of each column. It's quite
useful for checking whether factor
s snuck into a data.frame
. All
columns in a matrix
have the same type, but data.frame
's may
have mixed column types.
1 2 3 | colclasses(x)
colclasses(x) <- value
|
x |
a |
value |
a character vector of new column classes. if |
colclasses<-
sets the column classes in x
. Remember that matrix
columns are all of the same class, data.frame
can have multiple classes.
colclasses
: a character vector
of column classes, with the same
length as the number of columns. Typical classes include numeric
,
character
, logical
, factor
, ...
colclasses<-
: return x
with different column classes.
Mark Cowley, 18 Nov 2004
1 2 3 4 5 6 7 8 9 10 | # colnames getter example
x <- as.data.frame(cbind(1:5, LETTERS[1:5], rep(TRUE, 5)), stringsAsFactors=FALSE)
colclasses(x)
y <- as.data.frame(cbind(1:5, LETTERS[1:5], rep(TRUE, 5)), stringsAsFactors=TRUE)
colclasses(y)
# colnames setter example
y <- as.data.frame(cbind(1:5, LETTERS[1:5], rep(TRUE, 5)), stringsAsFactors=TRUE)
colclasses(y)
colclasses(y) <- c("numeric", "character", "logical")
colclasses(y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.