0

I have a database that holds hold data of animals counted with location and date, for every unique combination of location and date 1 or more animals may have been counted. I want to find the amount of unique combinations of location and date. After this, I want to find the amount of duplications of only location (so i know how many times each location has been measured in total)

i used locations <- table(STOWA$locality) to get a list of each location and the amount of times it occured, but i first need to get a list of every unique combination of location and date and then use table() on it.

pseudocode below of what i want to achieve

newList <- (where STOWA$locality + STOWA$date = unique)
locations <- table(newList(only on location,not date))

How do i do this?

Mapijs
  • 45
  • 7

2 Answers2

0

You can do this with simple dplyr code:

unique_combination <- df %>% 
    count(animal, location, time)

Location:

count_location <- df %>%
        count(location)
José
  • 921
  • 14
  • 21
0

why not this?

library(dplyr)

newlist <- df %>% group_by(locality, date) %>% slice_head()

this will give you one unique combination for each, basically the first row.

AnilGoyal
  • 25,297
  • 4
  • 27
  • 45