Timeline for Organize data with multiple levels of a categorical variable per entry, for easy R analysis
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 17, 2017 at 12:17 | vote | accept | Bakaburg | ||
May 28, 2014 at 17:32 | comment | added | Bakaburg | If anything comes up I'll have to do that. | |
May 28, 2014 at 15:57 | history | edited | Sycorax♦ | CC BY-SA 3.0 |
added 176 characters in body
|
May 28, 2014 at 15:53 | comment | added | Sycorax♦ | @Bakaburg To each his own, but it truly seems to be inordinately complex to write such a loop than to add additional columns. It seems that you could retain your columns with the free-text categories and also have the additional binary columns. Though redundant, both representations are useful for different ends. | |
May 28, 2014 at 15:45 | comment | added | Bakaburg | I hoped in a more native solution. | |
May 28, 2014 at 15:45 | comment | added | Bakaburg | No, I need to analyze each level separately. One solution I was thinking of was keeping the levels as a string in the dataframe, transforming it in a vector with the levels of every entry, creating another unique vector with all the levels and then analyze the data by looping through the all levels vector and selecting the entries which contains the level searched. | |
May 28, 2014 at 15:30 | comment | added | Sycorax♦ | Well, factors might be able to avoid this problem. If you want to represent all 15 of your categories in a single column, you could code A={A}, B={B}, AB={A and B}, ABC={A,B, and C}, etc. But doing this for all 15 categories doesn't really seem like a huge improvement over creating 15 individual columns. Also, it will destroy, from R's POV, the association between, e.g., A and AB and ABC. That's why people tend to prefer the one-column-per-category approach. | |
May 28, 2014 at 15:24 | comment | added | Bakaburg | I justed hoped to be able to avoid this solution... I have 15 categories, in addition to many other variables and wanted to avoid adding more columns, also to make the data more understandable visually. Sure there is a R solution to avoid multicolumning? | |
May 28, 2014 at 15:00 | history | answered | Sycorax♦ | CC BY-SA 3.0 |