-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.R
63 lines (39 loc) · 1.25 KB
/
functions.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#Functions
# Data transformation - #Issue #40
## Variables recalculation
# Energy calculation (kcal, kj) ----
# source(here::here("functions","Energy_Standardisation.R"))
# Summary table functions: ----
# Beta-carotene functions are now in NutritionTools package
# Sum of proximate
# RETOL - Issue #46
# Vitamin A, retinol activity eq.
# Vitamin A, retinol eq.
# Thiamin
# Niacin (From niacin eq.)
source(here::here("functions","summary_table_functions.R"))
#SOP_std_creator()
#CHOAVLDFg_std_creator()
#VITA_RAEmcg_std_creator()
#VITAmcg_std_creator()
#This function combine three Tagnames ----
source(here::here("functions","nutri_combiner.R"))
#Formatting - Nutritools
# source(here::here("functions","Group_Summariser.R"))
# source(here::here("functions", "Summarised_Row_Recalculator.R"))
#Remove "*" to avoid conversion to NA
RemoveStar <- function(x){
x <- gsub("\\*", "", x)
return(x)
}
# Function that replace "trace" values to zero
## zero can be substituted to a different value
source(here::here("functions", "TraceToZero.R"))
#UNDER DEVELOPMENT ----
#Function to remove brackets
#The following f(x) removes []
no_brackets <- function(i){
case_when(
str_detect(i, '\\[.*?\\]') ~ str_extract(i, '(?<=\\[).*?(?=\\])'),
TRUE ~ i)
}