Dear Listers,

I try to change the structure of my data. i have an indicator-matrix and
want to end up with a factor.

i have

v1 v2 v3
1   0   0
0   1   0
0   0   1

and want

v1 v2 v3  v4
1   0   0   1
0   1   0   2
0   0   1   3

amongst other things i tried the following

d <- data.frame(d1=c(1,0,0), d2=c(0,1,0), d3=c(0,0,1))
d$nr <- NA
sapply(1:3, function(x) ifelse(get(paste0("d$d",x))==1,x,d$nr))

>From R i get the message "Object 'd$d1' not found".
But why, it's there?

Thanks a lot.
Winfried

	[[alternative HTML version deleted]]

