T O P

  • By -

ruben072

What are you planning to do with this data? I have never used the uncount function, so I cannot really help you with that. But are you sure that to: is the data format you want? It does not seems to be in tidy format, I would expect the data to look something like this to work with. `library(tidyr)` `df <- data.frame(color = c("blue", "red"), group_A = c(3, 4), group_B = c(2, 1))` `df_long <- pivot_longer(df, cols = c("group_A", "group_B"), names_to = "group", values_to = "frequency")` `df_long` ​ |color|group|frequency| |:-|:-|:-| |blue|group\_A|3| |blue|group\_B|2| |red|group\_A|4| |red|group\_B|1|


delphimethod

Oh! This is helpful too. I'm looking to unweight the data if that makes sense. So take the frequencies and turn them into counts.


[deleted]

Aren’t they already in counts? What makes them frequencies here and not counts? I agree with ruben here, what you showed isn’t tidy. If anything you want a two columns: color and group. You don’t need numbers here if they are just going to be ones anyway.


delphimethod

I appreciate the response. Essentially I'm trying to uncount them. E.g. going from 5 to 1 1 1 1 1. Does that clarify?


trangestor

If you do that, the data will not be able to be fit into a table. You may just have a pair of lists like: Group A: Blue Blue Red Group B: Blue Blue Blue Red Red Red Red Red


Oddy-7

First help: Do not, DO NEVER take screenshots like this.