0

So I have a table and instead of having 12 rows of frequencies, I would like to expand the table to have include all 3303 observations (total of all frequencies).

I tried using pivot_longer but all I am getting is the same table with an added column. I could make a data frame for each observation with the total frequency for that observation minus 1 and rbind it to the dataset but that is 12 lines of code! Is there a simpler way?? Let us say the dataset = prostateca

dataset

Richard
  • 1
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 31 '22 at 07:12
  • Figured it out. I wanted to expand the observations as rows instead of frequencies. installed splitstackshape and coded in r as follows: prostateca_mod <- expandRows(prostateca, "freq") – Richard Apr 05 '22 at 21:36

0 Answers0