What is the difference of occurrence and density for different types with in 4 different populations

statistics
#1

Can I calculate the difference of occurrence and density for different types with in 4 different populations using R? If I can will this also tell me the significance of this difference?

I would like to know which of these groups has the highest density and occurrence of types.

Sample data set provided below

group,type,dens
1,6,21
1,24,83
1,30,49
1,42,63
1,48,14
1,66,42
1,72,14
1,84,21
1,90,7
1,102,35
1,108,42
1,114,1674
1,120,35
1,132,14
1,150,7
1,156,111
1,162,14
1,192,201
1,198,7
1,210,21
1,240,49
1,264,76
1,270,14
1,276,7
1,324,7
1,330,243
1,336,28
1,348,7
1,378,14
1,384,7
1,414,7
1,432,7
1,444,42
1,486,7
1,510,21
1,528,667
1,540,21
1,552,7
2,6,7
2,12,7
2,24,7
2,30,7
2,42,146
2,48,49
2,66,28
2,72,7
2,78,7
2,84,21
2,102,21
2,114,70
2,120,7
2,132,7
2,156,21
2,162,7
2,192,63
2,210,7
2,216,14
2,222,7
2,228,21
2,264,28
2,282,14
2,300,14
2,312,7
2,318,7
2,330,389
2,336,7
2,342,21
2,348,21
2,384,7
2,396,21
2,402,7
2,420,14
2,432,7
2,444,111
2,510,7
2,528,910
2,540,7
2,552,21
3,6,21
3,24,83
3,30,21
3,42,688
3,48,14
3,60,14
3,66,160
3,72,21
3,78,7
3,96,42
3,108,21
3,120,14
3,126,7
3,132,21
3,138,14
3,144,7
3,150,90
3,156,49
3,162,7
3,192,76
3,198,14
3,210,14
3,222,7
3,252,7
3,264,7
3,324,97
3,336,125
3,342,28
3,354,7
3,360,7
3,390,28
3,396,7
3,408,14
3,414,7
3,438,21
3,444,528
3,480,14
3,510,76
3,528,125
3,534,56
3,552,42
4,6,21
4,18,7
4,24,14
4,30,21
4,36,7
4,42,549
4,48,35
4,60,7
4,66,111
4,72,21
4,108,21
4,114,7
4,120,35
4,138,7
4,156,56
4,162,7
4,192,97
4,204,7
4,210,21
4,222,14
4,252,7
4,288,7
4,294,7
4,324,35
4,336,97
4,342,63
4,366,7
4,384,21
4,390,7
4,408,14
4,414,14
4,432,7
4,444,104
4,510,21
4,528,181

0 Likes

#2

Hi Flora, welcome!

What have you tried so far? what is your specific problem? could you please turn this into a self-contained REPRoducible EXample (reprex)?A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

0 Likes

#3

Hello, thanks for your response.

I haven't tried anything yet. I am still investigating the best platform for me to do it in first.

Using the data provided, the scenario is; 4 populations of mice (group); Each of those populations has mice with different categories of genetic makeup (type); The frequency of mice with these types is (dens).

Which of these populations has the highest diversity of genetic categories and the highest population? I would like to somehow measure the significance of this result and rank the populations based on this query, Also it would be great to know which genetic categories are influencing the results the most.

Regards, F

0 Likes

#4

Hi Flora and welcome to RStudio community.

Answering questions like these are very straightforward in R. I'd personally approach it with the tidyverse tool dplyr's group_by and summarize functions.

For example,

library(dplyr)

set.seed(1)
df <- tibble(
  group = c(1,1,2,2,2,3,3,4,4,4),
  type  = sample(LETTERS[1:3],10, replace = TRUE),
  value = runif(10)
)
df
#> # A tibble: 10 x 3
#>    group type  value
#>    <dbl> <chr> <dbl>
#>  1     1 A     0.206
#>  2     1 B     0.177
#>  3     2 B     0.687
#>  4     2 C     0.384
#>  5     2 A     0.770
#>  6     3 C     0.498
#>  7     3 C     0.718
#>  8     4 B     0.992
#>  9     4 B     0.380
#> 10     4 A     0.777

df %>% 
  group_by(group) %>% 
  summarise(
    n = n(),
    mean_value = mean(value),
    median_value = median(value),
    type_n = n_distinct(type)
  )
#> # A tibble: 4 x 5
#>   group     n mean_value median_value type_n
#>   <dbl> <int>      <dbl>        <dbl>  <int>
#> 1     1     2      0.191        0.191      2
#> 2     2     3      0.614        0.687      3
#> 3     3     2      0.608        0.608      1
#> 4     4     3      0.716        0.777      2

Created on 2019-02-08 by the reprex package (v0.2.1)

If all this is super new to you, here's a nice introduction to the dplyr package. Are you looking for pointers to get started with R?

https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html


And this question sounds a lot like a homework question, so just in case, I wanted to point out this forum's homework policy; FAQ: Homework Policy

TL:DR How to Ask a Homework Related Question:

  1. Do not ask verbatim copy-paste questions
  2. Explicitly mention the course you are taking.
  3. Be sure to ask your question as close to a reproducible example (reprex) as you can. Preferably using the reprex-package
1 Like

closed #5

This topic was automatically closed 21 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.

0 Likes