0

I have this data frame.

enter image description here

Subjects include 1-5 with a count of 30 for each. Intervals 1-30 and X and Y coordinates for each interval and subject. I want to have the intervals binned into groups of 6 in order to get the means of X and Y per bin for each subject.

subset <- mydata %>% group_by(Subject) %>% summarise_at(vars(X:Y), mean, na.rm = TRUE)

When I do this, I get the overall means of X and Y for all intervals. How would I go about doing this correctly?

Pradeep Kumar
  • 1,193
  • 1
  • 9
  • 21
  • 1
    Welcome to SO. You maximise your chance of getting a useful answer if you provide a minimal reproducible example. This [post](https://stackoverflow.com/help/minimal-reproducible-example)  may help. – yuliaUU Oct 21 '22 at 15:26
  • 1
    you can use `dput(your_dataframe)` in order to print a reproducible example of your dataframe in R in the form of code. – Sandwichnick Oct 25 '22 at 11:02
  • Please also see [how to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – medium-dimensional Oct 25 '22 at 11:03

0 Answers0