Skip to content

how to handle 'multiresponse' variable?

2 messages · Kosenkov Kirill, Fan

#
Hello!

I have dataset where one variable is 'multiresponse', like this:
[1] "1 2" "1 2 3" "4" "1 4" "4 3" etc.
'responses' separated by space. observations in different 'rows' 
of data.frame.
I can do strsplit(data$var,' ') and make a list, where multiple 
responses are elements of character vectors, like this:
  $ P124               :List of 2956
   ..$ : chr  "2" "4"
   ..$ : chr  "1" "2"
   ..$ : chr "NA"
   ..$ : chr  "3" "4"
   ..$ : chr "3"

I need to compute crosstabulation on this variable, to make 
crosstabulation where this variable is a factor variable 
(responses of this variable are categories, in which i need to 
compute distributions of other variables). And i need to do 
crosstabulation with 'weights', like in xtabs(w~f1+f2).

Is any way exists to do such things with 'multiresponse' variables 
in R or i need to write my own functions to handle it?

Thanks!
Fan
#
There were some discussions in the past on this subject.
AFAK, there're actually useful functions in Frank Harell's package
"hmisc", like mChoice() and summarize(). For the detail
go to the R search page

http://finzi.psych.upenn.edu/search.html

and search

"Frank Harrell type multi-valued variable".

--
Fan
Kosenkov Kirill wrote: