Column1

Tabla Observaciones

Especies Observaciones
Arbacia dufresnii 11
Acanthistius patachonicus 9
Doris fontainii 9
Pleurobranchaea maculata 9
Cliona 8
Corynactis carnea 8
Aplidium 7
Parabunodactis imperfecta 7
Undaria pinnatifida 7
Mytilus edulis 6
Nemadactylus bergi 6
Porifera 6
Ceriantheopsis 5
Cosmasterias lurida 5
Diaulula punctuolata 5
Pinguipes brasilianus 5
Allostichaster capensis 4
Anotrichium 4
Anthothoe chilensis 4
Odontaster penicillatus 4
Chrysaora plocamia 3
Cliona chilensis 3
Helcogrammoides cunninghami 3
Leucippa pentagona 3
Lissoclinum fragile 3
Pseudocerotidae 3
Pseudopercis semifasciata 3
Sebastes oculatus 3
Ascidiella aspersa 2
Carcinus maenas 2
Ciona robusta 2
Clathria 2
Fissurellidea patagonica 2
Halcurias 2
Metridium senile 2
Odontaster 2
Ovalipes trimaculatus 2
Paramolgula gregaria 2
Pseudechinus magellanicus 2
Tripalea clavaria 2
Tripylaster philippii 2
Actiniaria 1
Anasterias antarctica 1
Bryozoa 1
Bugulina 1
Cycethra verrucosa 1
Darwinella 1
Diplosoma 1
Diplosoma listerianum 1
Enteroctopus megalocyathus 1
Fissurella radiosa tixierae 1
Gastropoda 1
Geitodoris patagonica 1
Holothuroidea 1
Hymenena 1
Leiosolenus patagonicus 1
Leuckartiara octona 1
Leurocyclus tuberculosus 1
Magellania venosa 1
Membranipora 1
Metridium 1
Myriogloea major 1
Myxicola 1
Nacella flammea 1
Odontocymbiola magellanica 1
Paralichthys 1
Patagonotothen 1
Phrikoceros mopsus 1
Phycodrys 1
Polycera marplatensis 1
Stylatula 1
Sycozoa sigillinoides 1
Tegula patagonica 1

Column2

Mapa

Phylum

Observaciones por año

Column3

Números

---
title: "Biodiversidad Marina Bahía Pardelas"
output: 
  flexdashboard::flex_dashboard:
    theme: lumen
    social: menu
    source: embed
    logo: https://www.proyectosub.org.ar/wp-content/uploads/2020/04/logoinatproyectosub.png
---

```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
library(ggplot2)
library(plotly)
library(spocc)
library(rinat)
library(mapr)


library(RColorBrewer)
palette(brewer.pal(8, "Set2"))


```

```{r dataread, message=FALSE, warning=FALSE, include=FALSE}


#Extract data from the project "biodiversidad-marina-bahia-pardelas"
#projecy_info <- pardelas_obs <- get_inat_obs_project("biodiversidad-marina-bahia-pardelas", type = "info", raw = FALSE)

#extract observations
#pardelas_obs <- get_inat_obs_project(projecy_info$id, type = "observations")

#create data frame with reduced info
#pardelas_obs_dataframe <- data.frame(name = pardelas_obs$taxon.name,longitude = as.numeric(pardelas_obs$longitude),latitude = as.numeric(pardelas_obs$latitude),user=pardelas_obs$user_login,date= as.Date(pardelas_obs$observed_on), taxonrank=pardelas_obs$taxon.rank,taxonid=pardelas_obs$taxon.id,taxon= pardelas_obs$iconic_taxon.name, stringsAsFactors = FALSE)

#As some of the taxon information  (eg Phylum) is not included in the rinat package we proceed to import data from csv. the package "spocc" shoul be explored for download data.

#Read data downloaded from inat site 
pardelas_obs_web <- read.csv("observations-MAY27.csv")

#we create a dataframe with the variable of interest.
pardelas_obs_dataframe <- data.frame(
name = pardelas_obs_web$scientific_name,
longitude = pardelas_obs_web$longitude,
latitude = pardelas_obs_web$latitude,
user=pardelas_obs_web$user_login,
date= as.Date(pardelas_obs_web$observed_on),
taxonid=pardelas_obs_web$id,
taxon= pardelas_obs_web$iconic_taxon_name,
kindom= pardelas_obs_web$taxon_kingdom_name,
phylum=pardelas_obs_web$taxon_phylum_name,
class=pardelas_obs_web$taxon_class_name,
order=pardelas_obs_web$taxon_order_name,
genus=pardelas_obs_web$taxon_genus_name,
stringsAsFactors = FALSE)

#add year from date info
pardelas_obs_dataframe$year <- as.numeric(format(pardelas_obs_dataframe$date,"%Y"))

obs_byyear = as.data.frame(table(pardelas_obs_dataframe$year))
colnames(obs_byyear)=c("Año","Observaciones") 

```


Column1{data-width=250}
-------

### Tabla Observaciones {data-width=245}
```{r taxalist}
knitr::kable(as.data.frame(table(reorder(pardelas_obs_dataframe$name,rep(-1,length(pardelas_obs_dataframe$name)),sum))),col.names = c("Especies","Observaciones"))

```


Column2 {.tabset .tabset-fade}
-------

### Mapa
```{r map}
map_leaflet(pardelas_obs_dataframe,size=4) %>% 
  addMiniMap(toggleDisplay = T)
```


### Phylum 
```{r donut}
##numbers of observations by phylum 
taxranks = as.data.frame(table(pardelas_obs_dataframe$phylum))
##Donut plot
p = taxranks %>% plot_ly(labels = ~Var1, values=~Freq) %>% 
  add_pie(hole=0.6) %>% 
  layout(title = ~paste0("Numero total de Taxa: ", length(unique(pardelas_obs_dataframe$taxonid)))) 

plotly::config(p,displayModeBar = F) 
```

### Observaciones por año
```{r obsbyyear}
#plot number of observation by date 
ggplot(obs_byyear, aes(x=Año,y=Observaciones,group=1)) + geom_line() + geom_point()+ xlab("Año") + ylab("Observaciones") + theme_minimal()

```


Column3{data-width=150}
-------

### Números
```{r}
#spp 
nspp = length(unique(pardelas_obs_dataframe$name))
gauge(nspp, min=0, max=100,label="Species")

#algae
nPlants = length(unique(pardelas_obs_dataframe$taxon[pardelas_obs_dataframe$taxon=="Plantae"|pardelas_obs_dataframe$taxon=="Chromista"]))
gauge(nPlants, min=0, max=100,label="Algas",sectors = gaugeSectors(success = c(0, 40),
                             warning = c(40, 60),
                             danger = c(60, 100),
                             colors = c("green", rgb(0, 1, 0), "#CC664D")))

#fish
nfish = length(unique(pardelas_obs_dataframe$name[pardelas_obs_dataframe$taxon=="Actinopterygii"]))
gauge(nfish, min=0, max=100,label="Peces")

#invertebrates
ninvertebrates = length(unique(pardelas_obs_dataframe$name[pardelas_obs_dataframe$taxon=="Animalia"|pardelas_obs_dataframe$taxon=="Mollusca"]))
gauge(ninvertebrates, min=0, max=100,label="Invertebrados")
```