owned this note
owned this note
Published
Linked with GitHub
# INBO CODING CLUB
21 January, 2019
Welcome!
## Share your code snippet
If you want to share your code snippet, copy paste your snippet within a section of three backticks (```):
As an **example**:
```
libraryG(tidyverse)
```
(*you can copy paste this example and add your code further down*)
```
Joepi
````
```
Check
```
```
ola
```
### Deelnemers
* Damiano
* Patrik
* Loïc
* Sander
* Jan
* David
* Kristof
* Bart
* Koen
### challenge 1
oplossing van Sander (= ipv <-)
```
test = read_excel("./data/20200121_urban_gaia_policy.xlsx")
head(test)
str(test)
summary(test)
nrow(test)
ncol(test)
```
### Tips of the day
Type:
```
sessionInfo()
```
to know packages and version of your Windows/Mac, R and packages.
### Challenge 1
Anik: lijntje om een , delimited txt file in te lezen. de comma is een .
```
# import your dataset
df <- read_delim("./data/20200121_meff_lu_soorten.txt", delim = ",",locale = locale(decimal_mark = "."))
```
``
Oplossing van Dirk:
```
read_excel()
```
```Test David```
Dank u Annik
Wouters poging (met gebruik tabtoets)
```
Corine <- read_csv2(file = "./data/20200121_ecosysteem_areaal_clc.txt")
```
poging Niko
```
tabel_wouter <- read_csv2(file = "./data/20200121_ecosysteem_areaal_clc.txt")
`''``
'probeer'
```
```
```
testje
```
``` Geert test``
Helen
```
data<-read_excel('./data/20200121_191007_WUP_SGBP_Bio_2018.xlsx', sheet = "Bio", skip = 1)
head(data)
str(data)
summary(data)
ncol(data)
nrow(data)
```
Nico
```
# import your dataset
myframe <- read_tsv('./data/20200121_occurrence_iNaturalist_researchgrade_obs.txt')
# What is the `head()` of your data.frame?
head(myframe)
# What is the `str()`ucture of your data.frame?
str(myframe)
# Did you know you can inspect some `summary()` statistics?
summary(myframe)
# Did you know you can get `nrows()` and `ncols()`?
nrow(myframe)
ncol(myframe)
```
library(tidyverse)
´´´
```
test code
```
```
ik heb nog geen oplossing
```
### Challenge 2
Nico
```
# - Did you know you can know how many `distinct()` values you have?
# Show the countries countries
distinct(myframe, countryCode)
# Count the different scientific names:
nrow(distinct(myframe, scientificName))
# - Did you know you can `filter()` rows?
# 1. `count()` how many NAs you have in a column. Tip: use `is.na()`
count(myframe, is.na(myframe$coordinateUncertaintyInMeters))
Oplossing Patrik
```
sum(is.na(Abio))
```
# 2. Filter rows with NAs in a specific column out and assign (`<-`) the result as a new data.frame
filteredframe <- filter(myframe, is.na(myframe$coordinateUncertaintyInMeters))
Oplossing Patrik (filteren van NAs in kolom Gebied of kolom VEGID)
```
filter(Abio, is.na(Gebied) | is.na(VEGID))
```
Oplossing David (filteren rijen zonder species_name)
```
obitable_speciesNA <- filter(obitable,is.na(species_name))
```
# - Did you know you can `select()` columns?
select(filteredframe, scientificName, countryCode)
# - Did you know you can `rename()` a column?
renamedframe <- rename(myframe, COUNTRY_CODE=countryCode)
renamedframe$COUNTRY_CODE
# - Calculate `min()`, `max()` and `mean()` of a column
min(myframe$decimalLatitude)
max(myframe$decimalLatitude)
mean(myframe$decimalLatitude)
```
```
##import
data<-read_excel('./data/20200121_191007_WUP_SGBP_Bio_2018.xlsx', sheet = "Bio", skip = 1)
head(data)
str(data)
summary(data)
ncol(data)
nrow(data)
data <- data %>%
rename(L=`L1/VL`)
##explore
distinct(data, Waterlichaamcode)
count(is.na(data$FB_EQR)== TRUE)
data_plot<-data %>%
filter(Categorie=='rivier') %>%
count(FB_Beoordeling)
```
### Challenge 3
Nico
```
library(ggplot2)
myframe %>%
count(scientificName) %>%
ggplot(aes(x=scientificName, y=n)) + geom_point()
```
Helen= beoordeling fytoplankton
```
ggplot(data,aes(x=FB_Beoordeling))+
geom_bar()+
facet_wrap(~Categorie)
```