0

I have a data frame that look something like this:

  Col1 Col2 Col3 Col4 Col5 Count
1    1    A    8   20   30     2
2    2    A    9   21   31     2
3    3    B   10   22   32     1
4    4    C   11   23   33     1

I want it to count how many times col2 appears and append it to the data frame (the last column of the data frame). I tried using the count function and creating a new data frame, but I get the error that the lengths are not the same. I tried looking around the forums and I saw a quite a few people recommend transform, but I wasn't sure how to use it when I am only considering one column and I want all of the other 4 columns to stay in my data frame.

Elle
  • 11
  • 1
  • 2

0 Answers0