简体   繁体   中英

Circular plots and circular statistics

I have the following data sets ( year, month, frequencies of species records). I would like to produce a circular plot in R and check ( statistically) whether there is a significant variation across months and years.

I have tried with ggplot to produce a circular plot showing my frequencies by month and years, but it does not work

Any help? Here below are my datasets.

year    month   frequencies
2013    Jan 0.214285714
2014    Jan 0.073170732
2015    Jan 0.073170732
2016    Jan 0
2017    Jan 0
2018    Jan 0
2013    Feb 0
2014    Feb 0.101694915
2015    Feb 0
2016    Feb 0
2017    Feb 0
2018    Feb 0.168539326
2013    Mar 0.044117647
2014    Mar 0.666666667
2015    Mar 0
2017    Mar 0.051724138
2018    Mar 1.244680851
2014    Apr 0.406779661
2015    Apr 0
2017    Apr 0.1
2018    Apr 0.923076923
2013    May 1
2014    May 0.047619048
2015    May 0.233333333
2017    May 0.066298343
2018    May 0.512195122
2013    Jun 0.260869565
2014    Jun 0.033519553
2015    Jun 0.085714286
2016    Jun 0.025641026
2017    Jun 0.137755102
2018    Jun 0.093023256
2013    Jul 0.154639175
2014    Jul 0.0703125
2015    Jul 0.18404908
2016    Jul 0
2017    Jul 0
2018    Jul 0.048648649
2013    Aug 0.068965517
2014    Aug 0.02
2015    Aug 0.060402685
2016    Aug 0
2017    Aug 0
2018    Aug 0.052631579
2013    Sep 0.090909091
2014    Sep 0.078431373
2015    Sep 0
2016    Sep 0
2017    Sep 0
2018    Sep 0
2013    Oct 0.151898734
2014    Oct 0.035714286
2015    Oct 0.023622047
2016    Oct 0
2017    Oct 0
2018    Oct 0
2013    Nov 0.092307692
2014    Nov 0
2015    Nov 0
2016    Nov 0.094488189
2017    Nov 0
2018    Nov 0.049180328
2013    Dec 0
2013    Dec 0
2014    Dec 0
2015    Dec 0
2016    Dec 0.047244094
2017    Dec 0
2018    Dec 0

Here's an option.

library(ggplot2)
ggplot(dat, aes(monthnum, frequencies)) +
  geom_line(aes(group = as.factor(year), color = as.factor(year))) +
  coord_polar() +
  scale_x_continuous(limits = c(1, 13), breaks=0:12, labels=c(month.abb, ""))

ggplot2 极坐标图


Data

I integerized your month with

dat$monthnum <- match(dat$month, month.abb)

That can probably be generalized better for non-English locales using format .

Here is the actual data I used:

dat <- structure(list(year = c(2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2017L, 2018L, 2014L, 2015L, 2017L, 2018L, 2013L, 2014L, 2015L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2013L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L), month = c("Jan", "Jan", "Jan", "Jan", "Jan", "Jan", "Feb", "Feb", "Feb", "Feb", "Feb", "Feb", "Mar", "Mar", "Mar", "Mar", "Mar", "Apr", "Apr", "Apr", "Apr", "May", "May", "May", "May", "May", "Jun", "Jun", "Jun", "Jun", "Jun", "Jun", "Jul", "Jul", "Jul", "Jul", "Jul", "Jul", "Aug", "Aug", "Aug", "Aug", "Aug", "Aug", "Sep", "Sep", "Sep", "Sep", "Sep", "Sep", "Oct", "Oct", "Oct", "Oct", "Oct", "Oct", "Nov", "Nov", "Nov", "Nov", "Nov", "Nov", "Dec", "Dec", "Dec", "Dec", "Dec", "Dec", "Dec"), frequencies = c(0.214285714, 0.073170732, 0.073170732, 0, 0, 0, 0, 0.101694915, 0, 0, 0, 0.168539326, 0.044117647, 0.666666667, 0, 0.051724138, 1.244680851, 0.406779661, 0, 0.1, 0.923076923, 1, 0.047619048, 0.233333333, 0.066298343, 0.512195122, 0.260869565, 0.033519553, 0.085714286, 0.025641026, 0.137755102, 0.093023256, 0.154639175, 0.0703125, 0.18404908, 0, 0, 0.048648649, 0.068965517, 0.02, 0.060402685, 0, 0, 0.052631579, 0.090909091, 0.078431373, 0, 0, 0, 0, 0.151898734, 0.035714286, 0.023622047, 0, 0, 0, 0.092307692, 0, 0, 0.094488189, 0, 0.049180328, 0, 0, 0, 0, 0.047244094, 0, 0), monthnum = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L)), row.names = c(NA, -69L), class = "data.frame")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM