Skip to main content
added 222 characters in body
Source Link
Bakaburg
  • 2.9k
  • 3
  • 28
  • 35

I need some help here.

I have some data in which every entry can take one or more levels of a categorical variable. for example, I have a category with 3 levels:

entry   category
1       A, B, C
2       B
3       C, A, B

How should I organized it into a file in order to easily let R discriminate among levels in order to do my analysis. Something like this:

Categories     entries    other_results
A              2          ~
B              3          ~
C              2          ~ 

I thought about doing a comma separated list, as shown in the example 1. But then what should I do in R in order to transform those string into categories?

CLARIFICATION: I'd like to avoid creating a column for every level. This variable has many levels and many other variables are already present. This would make the file uselessly big and not readable easily by humans.

thanks!

I need some help here.

I have some data in which every entry can take one or more levels of a categorical variable. for example, I have a category with 3 levels:

entry   category
1       A, B, C
2       B
3       C, A, B

How should I organized it into a file in order to easily let R discriminate among levels in order to do my analysis. Something like this:

Categories     entries    other_results
A              2          ~
B              3          ~
C              2          ~ 

I thought about doing a comma separated list, as shown in the example 1. But then what should I do in R in order to transform those string into categories?

thanks!

I need some help here.

I have some data in which every entry can take one or more levels of a categorical variable. for example, I have a category with 3 levels:

entry   category
1       A, B, C
2       B
3       C, A, B

How should I organized it into a file in order to easily let R discriminate among levels in order to do my analysis. Something like this:

Categories     entries    other_results
A              2          ~
B              3          ~
C              2          ~ 

I thought about doing a comma separated list, as shown in the example 1. But then what should I do in R in order to transform those string into categories?

CLARIFICATION: I'd like to avoid creating a column for every level. This variable has many levels and many other variables are already present. This would make the file uselessly big and not readable easily by humans.

thanks!

Source Link
Bakaburg
  • 2.9k
  • 3
  • 28
  • 35

Organize data with multiple levels of a categorical variable per entry, for easy R analysis

I need some help here.

I have some data in which every entry can take one or more levels of a categorical variable. for example, I have a category with 3 levels:

entry   category
1       A, B, C
2       B
3       C, A, B

How should I organized it into a file in order to easily let R discriminate among levels in order to do my analysis. Something like this:

Categories     entries    other_results
A              2          ~
B              3          ~
C              2          ~ 

I thought about doing a comma separated list, as shown in the example 1. But then what should I do in R in order to transform those string into categories?

thanks!