.RData 0 → 100644
File added
.Rbuildignore 0 → 100644
^.*\.Rproj$
^\.Rproj\.user$
.Rhistory 0 → 100644
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
figure(new_lst$NED)
figure <- function(df){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = 32)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
figure(new_lst$NED)
figure <- function(df){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = 35)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
figure(new_lst$NED)
for (i in 1:28){
p <- figure(new_lst[[i]])
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 12, height = 8)
}
figure <- function(df){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = 20)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
new_lst[[1]]
names(new_lst[[1]])
figure <- function(df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(new_lst[[i]], 35)
}
else{
p <- figure(new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 12, height = 8)
}
NED <- figure(new_lst$NED, 35)
NED <- figure(new_lst$NED, 35)
NED
ggsave(plot = NED,
filename = paste0(get.data.dir(),"/plots/","NED_" ,"_plot.png"),
width = 12, height = 8)
ggsave(plot = NED,
filename = paste0(get.data.dir(),"/plots/","NED_" ,"_plot.png"),
width = 15, height = 8)
ggsave(plot = NED,
filename = paste0(get.data.dir(),"/plots/","NED_" ,"_plot.png"),
width = 18, height = 8)
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(new_lst[[i]], 35)
}
else{
p <- figure(new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = paste0("Plot of the Number of common ID for country:", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Plot of the number of common ID for country: ", country )) +
ggeasy::easy_center_title() +
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Plot of the number of common ID for country: ", country )) +
theme_update(plot.title = element_text(hjust = 0.5)) +
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Plot of the number of common ID for country: ", country )) +
theme(plot.title = element_text(hjust = 0.5)) +
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
getwd()
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0("D:/public/data/fadn/lieferung_20210414/common_id_plots","/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0("D:/public/data/fadn/lieferung_20210414/common_id_plots",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0("D:/public/data/fadn/lieferung_20210414/common_id_plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
guides(fill=FALSE) +
ggtitle(paste0("Plot of the number of common ID for country: ", country )) +
theme(plot.title = element_text(hjust = 0.5)) +
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0("D:/public/data/fadn/lieferung_20210414/common_id_plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
new_lst$BEL
figure("BEL",new_lst$BEL, 35)
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity", position = position_dodge(width = 0.8),width=0.5, fill = rainbow(n=length(df$Num_id)) ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Plot of the number of common ID for country: ", country )) +
theme(plot.title = element_text(hjust = 0.5)) +
theme_bw()
p
}
figure("BEL",new_lst$BEL, 35)
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity", position = position_dodge(width = 0.8),width=0.5, fill = rainbow(n=length(df$Num_id)) ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Number of common ID for country: ", country )) +
theme(plot.title = element_text(hjust = 0.5)) +
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0("D:/public/data/fadn/lieferung_20210414/common_id_plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity", position = position_dodge(width = 0.8),width=0.5, fill = rainbow(n=length(df$Num_id)) ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Number of common ID for country: ", country )) +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5))
p
}
figure("BEL",new_lst$BEL, 35)
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity", position = position_dodge(width = 0.8),width=0.5, fill = rainbow(n=length(df$Num_id)) ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Number of common ID for country: ", country )) +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5))
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0("D:/public/data/fadn/lieferung_20210414/common_id_plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
knitr::opts_chunk$set(echo = TRUE)
summary(cars)
plot(pressure)
View(pressure)
knitr::opts_chunk$set(echo = TRUE)
file_names <- list.files("D:/public/data/fadn/lieferung_20210414/csv",include.dirs = TRUE)
file_names_gpg <- file_names[grepl(".gpg",file_names)]
length(file_names_gpg)
file_names <- file_names[!grepl(".gpg",file_names)]
library(tidyverse)
file_names <- file_names %>% tibble(name=.) %>% mutate(country=str_sub(name,1,3),year=str_sub(name,4,7))
file_names %>% print(n=30)
file_names %>% group_by(year) %>% count()
file_names %>% filter(country=="POL")
file_names <- file_names %>% mutate(provided="y")
data_requested_general <- read_xlsx(path = "D:/public/data/fadn/lieferung_20210414/FADN data request forms_March2021_MM210326.xlsx",sheet = 2,range = "A365:P393")
library(tidyverse)
library(readxl)
library(data.table)
data_requested_general <- read_xlsx(path = "D:/public/data/fadn/lieferung_20210414/FADN data request forms_March2021_MM210326.xlsx",sheet = 2,range = "A365:P393")
colnames(data_requested_general)[1] <- "country"
data_requested_general <- data_requested_general %>% mutate(country=str_sub(country,2,4))
data_requested_general_long <- data_requested_general %>% pivot_longer(-country)
data_requested_general_long <- data_requested_general_long %>% filter(value=="y") %>% rename(year=name,requested=value)
requested_and_provided <- data_requested_general_long %>% full_join(file_names %>% select(-name),by=c("country","year")) %>% filter(is.na(requested ) | is.na(provided))
## if empty, than everything is fine
requested_and_provided
# writexl::write_xlsx(x=requested_and_provided,path="D:/public/data/fadn/lieferung_20210414/missing_countries_years.xlsx")
files_list <- list()
folder_csv <- "D:/public/data/fadn/lieferung_20210414/csv/"
system.time({
files_list <- lapply(file_names %>% pull(name) %>% unique(),function(x)fread(input = paste0(folder_csv,x)))
}) ## 41.16 ~ 76 sec
files <- rbindlist(files_list)
files %>% select(YEAR,COUNTRY,countryyear)
## Number of sum of sample farms - observation - not unique
files %>% select(YEAR,COUNTRY) %>% group_by(COUNTRY) %>% count() %>% print(n=28)
## Combination of country and year in data set
files %>% select(YEAR,COUNTRY) %>% group_by(COUNTRY) %>% distinct()
library(fadnUtils)
library(fadnUtils)
library(fadnUtils)
library(fadnUtils)
library(fadnUtils)
library(fadnUtils)
devtools::load_all(".")
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(readxl)
library(data.table)
library(skimr)
file_names <- list.files("D:/public/data/fadn/lieferung_20210414/csv",include.dirs = TRUE)
file_names_gpg <- file_names[grepl(".gpg",file_names)]
length(file_names_gpg)
file_names <- file_names[!grepl(".gpg",file_names)]
library(tidyverse)
file_names <- file_names %>% tibble(name=.) %>% mutate(country=str_sub(name,1,3),year=str_sub(name,4,7))
file_names %>% print(n=30)
file_names %>% group_by(year) %>% count()
file_names %>% filter(country=="POL")
file_names <- file_names %>% mutate(provided="y")
data_requested_general <- read_xlsx(path = "D:/public/data/fadn/lieferung_20210414/FADN data request forms_March2021_MM210326.xlsx",sheet = 2,range = "A365:P393")
colnames(data_requested_general)[1] <- "country"
data_requested_general <- data_requested_general %>% mutate(country=str_sub(country,2,4))
data_requested_general_long <- data_requested_general %>% pivot_longer(-country)
data_requested_general_long <- data_requested_general_long %>% filter(value=="y") %>% rename(year=name,requested=value)
requested_and_provided <- data_requested_general_long %>% full_join(file_names %>% select(-name),by=c("country","year")) %>% filter(is.na(requested ) | is.na(provided))
## if empty, than everything is fine
requested_and_provided
# writexl::write_xlsx(x=requested_and_provided,path="D:/public/data/fadn/lieferung_20210414/missing_countries_years.xlsx")
auto_roxygenize_for_build_and_reload="0"
auto_roxygenize_for_build_package="1"
auto_roxygenize_for_check="1"
live_preview_website="1"
makefile_args=""
preview_website="1"
website_output_format="all"
]0;:/c/Users/yang_x/Desktop/new-Version[?25l
yang_x@HPCBW01-BS  ~/Desktop/new-Version[?25h[?25l
]0;:/c/Users/yang_x/Desktop/new-Version[?25l
yang_x@HPCBW01-BS  ~/Desktop/new-Version
$[?25h
\ No newline at end of file
[{"allow_restart":true,"alt_buffer":false,"autoclose":1,"buffered_output":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","caption":"Terminal 1","channel_id":"3536","channel_mode":1,"child_procs":false,"cols":146,"cwd":"","exit_code":15,"handle":"D6E734FE","interaction_mode":2,"max_output_lines":1000,"restarted":true,"rows":22,"shell_type":1,"show_on_output":false,"terminal_sequence":1,"title":":/c/Users/yang_x/Desktop/new-Version","track_env":false,"zombie":false}]
\ No newline at end of file
[
]
\ No newline at end of file
{
"debugBreakpointsState" : {
"breakpoints" : [
]
}
}
\ No newline at end of file
{
"path" : "C:/Users/yang_x/Desktop/new-Version",
"sortOrder" : [
{
"ascending" : false,
"columnIndex" : 2
}
]
}
\ No newline at end of file
{
"installOptions" : {
"installDependencies" : true,
"installFromRepository" : true,
"libraryPath" : "C:/Users/yang_x/Documents/R/R-3.6.3/library"
}
}
\ No newline at end of file
{
"activeTab" : 0,
"activeTabSourceWindow1" : 0,
"activeTabSourceWindow2" : 0,
"activeTabSourceWindow3" : 0,
"activeTabSourceWindow4" : 0,
"activeTabSourceWindow5" : 0,
"activeTabSourceWindow6" : 0
}
\ No newline at end of file
{
"sourceWindowGeometry" : {
"w5y6pjlj2xznu" : {
"height" : 582,
"ordinal" : 6,
"width" : 553,
"x" : 17,
"y" : 93
}
}
}
\ No newline at end of file
{
"left" : {
"panelheight" : 784,
"splitterpos" : 399,
"topwindowstate" : "NORMAL",
"windowheight" : 823
},
"right" : {
"panelheight" : 784,
"splitterpos" : 458,
"topwindowstate" : "NORMAL",
"windowheight" : 823
}
}
\ No newline at end of file
{
"TabSet1" : 3,
"TabSet2" : 1,
"TabZoom" : {
}
}
\ No newline at end of file
build-last-errors="[]"
build-last-errors-base-dir="C:/Users/yang_x/Desktop/new-Version/"
build-last-outputs="[{\"output\":\"==> Rcmd.exe INSTALL --no-multiarch --with-keep.source new-Version\\n\\n\",\"type\":0},{\"output\":\"* installing to library 'C:/Users/yang_x/Documents/R/R-3.6.3/library'\\r\\n\",\"type\":1},{\"output\":\"* installing *source* package 'fadnUtils' ...\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** using staged installation\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** R\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** inst\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** byte-compile and prepare package for lazy loading\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** help\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"*** installing help indices\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\" converting help for package 'fadnUtils'\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\" finding HTML links ...\",\"type\":1},{\"output\":\" analyzeFormula html \",\"type\":1},{\"output\":\" fertig\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"\\r\\n\",\"type\":1},{\"output\":\" check.column html \\r\\n\",\"type\":1},{\"output\":\" check.data.dir.structure html \\r\\n\",\"type\":1},{\"output\":\" check.raw_str_map html \\r\\n\",\"type\":1},{\"output\":\" check_file_type html \\r\\n\",\"type\":1},{\"output\":\" collect.common.id html \",\"type\":1},{\"output\":\"\\r\\n\",\"type\":1},{\"output\":\" convert.to.fadn.raw.rds html \\r\\n\",\"type\":1},{\"output\":\" convert.to.fadn.str.rds html \",\"type\":1},{\"output\":\"\\r\\n\",\"type\":1},{\"output\":\" create.data.dir html \\r\\n\",\"type\":1},{\"output\":\" delete.fadn.raw html \\r\\n\",\"type\":1},{\"output\":\" delete.fadn.str html \\r\\n\",\"type\":1},{\"output\":\" get.available.fadn.raw.rds html \\r\\n\",\"type\":1},{\"output\":\" get.available.fadn.str.rds html \",\"type\":1},{\"output\":\"\\r\\n\",\"type\":1},{\"output\":\" get.data.dir html \\r\\n\",\"type\":1},{\"output\":\" getFormulaResult html \\r\\n\",\"type\":1},{\"output\":\" grep.columns.in.raw.rds html \\r\\n\",\"type\":1},{\"output\":\" import.fadn.csv html \\r\\n\",\"type\":1},{\"output\":\" load.fadn.raw.rds html \",\"type\":1},{\"output\":\"\\r\\n\",\"type\":1},{\"output\":\" load.fadn.str.rds html \\r\\n\",\"type\":1},{\"output\":\" nested_var html \\r\\n\",\"type\":1},{\"output\":\" raw_str_map.merge html \",\"type\":1},{\"output\":\"\\r\\n\",\"type\":1},{\"output\":\" set.data.dir html \\r\\n\",\"type\":1},{\"output\":\" show.data.dir.contents html \\r\\n\",\"type\":1},{\"output\":\" take.raw_str_map.columns html \\r\\n\",\"type\":1},{\"output\":\" update_elements.DT html \",\"type\":1},{\"output\":\"\\r\\n\",\"type\":1},{\"output\":\" write.excel html \\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** building package indices\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** installing vignettes\\r\\n\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from temporary location\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from final location\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package keeps a record of temporary installation path\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"* DONE (fadnUtils)\\r\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:\\n\\nhttps://cran.rstudio.com/bin/windows/Rtools/\\n\\n\",\"type\":2}]"
compile_pdf_state="{\"errors\":[],\"output\":\"\",\"running\":false,\"tab_visible\":false,\"target_file\":\"\"}"
files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOff\":[],\"matchOn\":[]},\"running\":false}"
imageDirtyState="1"
saveActionState="-1"
{"active_set":"","sets":[]}
\ No newline at end of file
{
"collab_server" : "",
"contents" : "",
"created" : 1618920948104.000,
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "38|35|59|0|\n",
"hash" : "3385672932",
"id" : "2EBE2EFC",
"lastKnownWriteTime" : 1618930088,
"last_content_update" : 1618930096578,
"path" : "D:/public/yang/MIND_STEP/plots.R",
"project_path" : null,
"properties" : {
"cursorPosition" : "21,0",
"scrollLine" : "15",
"tempName" : "Untitled1"
},
"relative_order" : 4,
"source_on_save" : false,
"source_window" : "",
"type" : "r_source"
}
\ No newline at end of file
# plot the common id over the years
path <- "D:/public/yang/MIND_STEP/new_sample/fadn_data_common_id.xlsx"
sheetsnames <- excel_sheets(path)
length(sheetsnames)
lst <- lapply(1:28, function(i) read_excel(path, sheet = i))
lst_test <- Map(function(x, y) {names(x)[1] <- y; x},
lst, sheetsnames)
names(lst_test) <- sheetsnames
new_colnames <- c("Years","Num_id")
new_lst_ = lapply(lst_test, setNames, new_colnames)
###
new_lst = new_lst_
for (i in 1:28){
new_lst[[i]]$Length <- str_count(new_lst[[i]]$Years)
new_lst[[i]]$group <- cut(new_lst[[i]]$Length, breaks=c(1,10,14,18,25,30,35,40,48,55,58,70,Inf))
#new_lst[[i]]$group <- cut(new_lst[[i]]$Length, breaks=c(1,10,14,18,25,30,35,40,48,55,58,70,Inf))
}
label_facet <- function(original_var, custom_name){
lev <- levels(as.factor(original_var))
#lev <- c()
lab <- paste0(custom_name, ": ", lev)
names(lab) <- lev
return(lab)
}
names <- as_labeller(
c(`(1,10]` = "2 years", `(14,18]` = "3 years",`(18,25]` = "4 years",
`(25,30]` = "5 years",`(30,35]` = "6 years", `(35,40]` = "7 years",
`(40,48]` = "8 years", `(48,55]`= "9 years", `(55,58]` = "10 years",
`(58,70]`="11 and 12 years", `(70,Inf]` = "more than 12"))
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity", position = position_dodge(width = 0.8),width=0.5, fill = rainbow(n=length(df$Num_id)) ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Number of common ID for country: ", country )) +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5))
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0("D:/public/data/fadn/lieferung_20210414/common_id_plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure("BEL",new_lst$BEL, 35)
{
"collab_server" : "",
"contents" : "",
"created" : 1618920953371.000,
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "4084318790",
"id" : "826115CA",
"lastKnownWriteTime" : 1618576754,
"last_content_update" : 1618576754,
"path" : "D:/public/yang/MIND_STEP/FADN_DATA_14042021.R",
"project_path" : null,
"properties" : {
"cursorPosition" : "11,8",
"scrollLine" : "0"
},
"relative_order" : 5,
"source_on_save" : false,
"source_window" : "",
"type" : "r_source"
}
\ No newline at end of file