0

What I am looking to do is something similar to a pivot table in excel but using R to determine the median. I have 3 data frames. The first being whether someone moved or not. I want to determine the median number of knocks this person received as well as the months they had lived there to see if either of them had anything to do with the move. Ideally I would end up with 4 medians (2 for knocks based on whether they moved or not and 2 for months lived).

Any ideas?

data

camille
  • 16,432
  • 18
  • 38
  • 60
kksweene
  • 9
  • 1
  • Use `dplyr` with `group_by` and `summarize` – Grzegorz Sapijaszko Jan 27 '22 at 17:31
  • 1
    [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. That includes a workable sample of data (not a picture of it) and what you've tried – camille Jan 27 '22 at 17:50
  • @GrzegorzSapijaszko what would that code look like? – kksweene Jan 27 '22 at 17:57
  • 1
    @kksweene, I would ask you to edit your post and provide a sample of your data, ex. running `dput(head(myDataFrame, 10))`. However it would look like: `df |> group_by(move) |> summarize(mean(knocks))` – Grzegorz Sapijaszko Jan 27 '22 at 18:04

0 Answers0