修订版 | 1b8f8131ba0dc385fea00ebe92177b6143f274e7 (tree) |
---|---|
时间 | 2022-12-12 22:59:07 |
作者 | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
Code seld-contained.
@@ -14,7 +14,6 @@ | ||
14 | 14 | tidymodels_prefer() |
15 | 15 | |
16 | 16 | |
17 | -source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R") | |
18 | 17 | |
19 | 18 | |
20 | 19 | extract_ms_data <- function( ms, log_trans){ |
@@ -47,6 +46,43 @@ | ||
47 | 46 | } |
48 | 47 | |
49 | 48 | |
49 | +su <- function(x, decreasing=F, ...){ | |
50 | + | |
51 | + ## res <- x %>% unique %>% sort(decreasing=decreasing, ...) | |
52 | + | |
53 | + res <- x |> | |
54 | + unique() |> | |
55 | + sort(decreasing=decreasing, ...) | |
56 | + | |
57 | + | |
58 | + return(res) | |
59 | + | |
60 | + | |
61 | +} | |
62 | + | |
63 | + | |
64 | +save_excel <- function(output, fileName, sheetName="data", na_yes = TRUE,...){ | |
65 | +tryCatch({ | |
66 | + | |
67 | + wb <- loadWorkbook(fileName) | |
68 | + addWorksheet(wb = wb, sheet = sheetName) | |
69 | + writeData(wb = wb, sheet = sheetName, x = output, colNames = T, rowNames = F, | |
70 | + keepNA=na_yes ,...) | |
71 | + saveWorkbook(wb = wb, file = fileName, overwrite = T) | |
72 | +}, | |
73 | +error = function(err){ | |
74 | + | |
75 | + wb <- createWorkbook(fileName) | |
76 | + addWorksheet(wb = wb, sheet = sheetName) | |
77 | + writeData(wb = wb, sheet = sheetName, x = output, colNames = T, rowNames = F, keepNA=na_yes , ... ) | |
78 | + saveWorkbook(wb = wb, file = fileName, overwrite = T) | |
79 | +}) | |
80 | +} | |
81 | + | |
82 | + | |
83 | + | |
84 | + | |
85 | + | |
50 | 86 | ################################################################### |
51 | 87 | ################################################################### |
52 | 88 | ################################################################### |
@@ -65,6 +101,24 @@ | ||
65 | 101 | |
66 | 102 | choose_log <- 1 |
67 | 103 | |
104 | +iso_map_eu27 <- tibble(iso3=c("AUT", "BEL", "BGR", "CYP", "CZE", "DEU", "DNK", "ESP", "EST", "FIN", | |
105 | +"FRA", | |
106 | +"GRC", "HRV", "HUN", "IRL", "ITA", "LTU", "LUX", "LVA", "MLT", | |
107 | +"NLD", "POL", "PRT", | |
108 | +"ROM", "SVK", "SVN", "SWE"), | |
109 | +iso2 = c("AT", "BE", "BG", "CY", "CZ","DE", | |
110 | + "DK", "ES" ,"EE", "FI", "FR", "EL", "HR", "HU", "IE", | |
111 | + "IT" , "LT","LU", "LV", "MT", "NL", "PL", | |
112 | + "PT", "RO", "SK", "SI", "SE"), | |
113 | + | |
114 | +country=c("Austria", "Belgium", "Bulgaria", "Cyprus", "Czechia", "Germany", | |
115 | + "Denmark", "Spain", "Estonia", "Finland", "France", "Greece", | |
116 | + "Croatia", "Hungary", "Ireland","Italy", "Lithuania", "Luxembourg", | |
117 | + "Latvia", "Malta", "Netherlands", "Poland", "Portugal", | |
118 | + "Romania", "Slovakia", "Slovenia", "Sweden") | |
119 | +) | |
120 | + | |
121 | + | |
68 | 122 | |
69 | 123 | present_month <- month(today()) |
70 | 124 |