[R] Binding one column of characters into a dataframe factors other numeric columns
Ken Termiso
jerk_alert at hotmail.com
Thu Mar 17 19:30:15 CET 2005
Hi all,
I searched through the archives, but couldn't find a fix...
Basically, I've got a bunch of numeric vectors and one character vector that
I want to bind into a data frame. When I include the character vector as a
column in the data frame, all the numeric columns get factored in the data
frame, which makes it tough to call those columns for calculations later on.
I've tried using AsIs to prevent this, but without luck...in the examples
below, the object named "c" is the one that is the character column. The
others are numeric.
df_without_char <- data.frame(cbind(rl, gl, cp), row.names = rownames(r))
#without char vector
df_without_char <- data.frame(cbind(rl, gl, c, cp), row.names =
rownames(r))#with char vector
df <- data.frame(cbind(rl, gl, I(c), cp), row.names = rownames(r)) #try to
keep char vector AsIs
df <- data.frame(cbind(rl, gl, c=I(c), cp), row.names = rownames(r)) #try to
keep char vector AsIs
df <- data.frame(cbind(rl, gl, c, I(cp)), row.names = rownames(r)) #try to
keep num vector AsIs
df <- data.frame(cbind(rl, gl, c, cp=I(cp)), row.names = rownames(r)) #try
to keep num vector AsIs
Thanks in advance,
Ken
More information about the R-help
mailing list