-1

I used this is the code to add the percenatage row at the end:

adde_percent <- lapply(added_total, function(x){
last_row <- nrow(x)
pct <- Total / sum(Total)
x[last_row+1,] <- c("percentage", pct)
x
})

I have a list of data frames and want to add the percentage at the end of each data frame in a list. I already added the total. This is a screenshot of a data frame: enter image description here

Kian
  • 110
  • 7

1 Answers1

-1

You could try a simple subset:

df[df$PERSNUM == df$RELAT, ]

  PROVINCE PERSNUM RELAT
2       11       1     1
3       11       1     1
4       11       1     1
6       11       1     1
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360