Hello,
I'm trying to calculate the mean of degree values. My data set is composed of three groups (dir), which I want to compare. First, I tried to calculate this with the circular package, but there I got "values", which I can't split into groups.
With the following attempt, I got an error. I hope, anybody here can help me. Thank you!
``` r
dat<-tibble::tribble(
~dir, ~degree,
"A", 2L,
"A", 12L,
"B", 78L,
"B", 257L,
"C", 57L,
"C", 198L
)
head(dat)
#> # A tibble: 6 x 2
#> dir degree
#> <chr> <int>
#> 1 A 2
#> 2 A 12
#> 3 B 78
#> 4 B 257
#> 5 C 57
#> 6 C 198
Created on 2022-01-27 by the reprex package (v2.0.1)
``` r
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
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
dat %>%
group_by(dir) %>%
summarise(
circ_mean <-
degree %>%
circular(degree, units = "degrees", rotation = "counter", zero=0, modulo="2pi") %>%#data to circular format
mean.circular()) %>% #mean
ungroup()
#> Error in group_by(., dir): Objekt 'dat' nicht gefunden
Created on 2022-01-27 by the reprex package (v2.0.1)