Calculate a mean by groups with "circular"

which is why I never use df, data, c, D, t, among others, as the name of objects that I create. :wink:

I see, I have to learn really much... Sorry @all for my confused approach.
Now, I have created a reprex from the original data and it's strange. I created a dataset with 6 cases (mydata) and all is fine. But if I waive the case selection, I get the same error as always. The next problem is, that when I create the reprex, I get more error messages...

``` r
data.frame(
      degree = c(313.922112119583,340.090834916981,
                 275.479983711446,205.458659115787,3.96963691809708,325.187911117228),
         dir = as.factor(c("GWTL", "GWTL", "ING", "ING", "BP", "BP"))
)
#>       degree  dir
#> 1 313.922112 GWTL
#> 2 340.090835 GWTL
#> 3 275.479984  ING
#> 4 205.458659  ING
#> 5   3.969637   BP
#> 6 325.187911   BP

Created on 2022-02-01 by the reprex package (v2.0.1)

library(dplyr)
#> Warning: Paket 'dplyr' wurde unter R Version 4.0.5 erstellt
#> 
#> Attache Paket: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(magrittr)
#> Warning: Paket 'magrittr' wurde unter R Version 4.0.5 erstellt
library(circular)
#> Warning: Paket 'circular' wurde unter R Version 4.0.5 erstellt
#> 
#> Attache Paket: 'circular'
#> The following objects are masked from 'package:stats':
#> 
#>     sd, var
mydata %>%
  dplyr::group_by(dir) %>%
  summarise(
    circ_mean =
      circular::circular(degree, units = "degrees", rotation = "counter", zero=0, modulo="2pi")%>%#data to circular format
      circular::mean.circular())
#> Error in dplyr::group_by(., dir): Objekt 'mydata' nicht gefunden

Created on 2022-02-01 by the reprex package (v2.0.1)

I'm afraid I don't know what this means but I can explain your reprex issue.

The purpose of a reprex is to reproduce your issue on someone else's machine. Example data is needed , therefore the reprex script will need to be responsible for guaranteeing the loading or artificial construction of some data for the code shared to operate on. I.e. in your reprex you have omitted a stand in for mydata.
Or in other words, your failing reprex assumes the presence of mydata , but this is a false assumption.

Thank you very much for your kind support! I have found the problem. There was one case with some NaNs. Without this case, respectively an imputation, it works :slight_smile:
Thank you for your patience!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.