Dear R-Users,

I want to ask a question for a colleague of mine. He wants to put a
character vector and a numeric vector into one matrix and still have the old
character and numeric type for the respective columns.
Unfortunately, I am just starting using R and I could not help him.
Is there an easy and straightforward way to do this in R?
        
Maybe a little example facilitates understanding our problem:
names <- c("Marge", "Lisa", "Homer", "Bart", "Maggie")
ages <- c(38,10,41,8,1)
Now he wants to have 2 columns in a matrix which should look like this:
"Marge"     38
"Lisa"      10
"Homer"     41
"Bart"       8
"Maggie"     1

I thought about using either:
family1 <- matrix(c(names, ages), ncol=2, byrow=FALSE)
or
family2 <- data.frame(names,ages)
but this simply transformed either the numeric into character values
(family1) or the character values into factor levels (family2)
Anyone here who can give us some advice on this?

We are using R 1.7.0 on Windows NT.

Thanks,
Roland

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to