[R] Creating a dataframe from several numeric and character vectors

Sven Garbade garbade at psy.uni-muenchen.de
Tue Nov 6 18:57:14 CET 2001


Hi all,

I want to combine some numeric vectors and one character vector to a
dataframe and did this:

    dat <- cbind(type, key,response, st)
    dimnames(dat) <- list(NULL, labels)
    dat <- data.frame(as.numeric(dat$"type"),
as.numeric(dat$"key"),                                            
as.numeric(dat$"response"), dat$"st")

where st is the character vector. I got this error:

Error in "names<-.default"(*tmp*, value = vnames) : 
	names attribute must be the same length as the vector

If I only type

    dat <- data.frame(dat)

then all variables are factors. I need all variables as numeric except
st. How can I do it?

Thanks, Sven
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list