I am trying to create a new dataframe by pulling the count in a few of my columns and repeating that column variable the number of times in the count and it's corresponding values.
Here is an example of what I want to do.
dfex=data.frame(group=c(1,2,3),white=c(5,2,1),black=c(1,3,2),num=c(1,5,10))
head(dfex)
group white black num
1 1 5 1 1
2 2 2 3 5
3 3 1 2 10
What I want to get is a data frame with three columns, bg, color (either black or white), and then conc. Basically something like this
group color num
1 1 white 1
2 1 white 1
3 1 white 1
4 1 white 1
5 1 white 1
6 1 black 1
7 2 white 5
8 2 white 5
9 2 black 5
10 2 black 5
11 2 black 5
12 3 white 10
13 3 black 10
14 3 black 10
I'm not sure if I explained it well with words, but I hope the example is descriptive enough to explain what I hope to do.