-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtil_Output_Functions.R
127 lines (77 loc) · 3.22 KB
/
Util_Output_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#Functions for outputs
#Updating not consumed items.
func_update_notcons<-function(df){
if (Donation_End_Week == FALSE){
df$Location[df$Location=="Not Shared"]<-"Discarded"
df$Location[df$Location=="Not Consumed"]<-"Discarded"
if(k==Food_Days && j==Service_No){
df$Location[df$Location=="Selection Table"]<-"Discarded"
df$Location[df$Location=="Shared"]<-"Discarded"
df$Location[df$Location=="SharedAside"]<-"Discarded"
}
}else if (Donation_End_Week == TRUE){
df$Location[df$Location=="Not Shared"]<-"Discarded"
df$Location[df$Location=="Not Consumed"]<-"Discarded"
if(k==Food_Days && j==Service_No){
df$Location[df$Location=="Selection Table"]<-"Donated"
df$Location[df$Location=="Shared"]<-"Donated"
df$Location[df$Location=="SharedAside"]<-"Donated"
}
}
return(df)
}
# Code To add Services to Total
func_Add_Services<-function(DF){
for(i in 1:nrow(DF)){
DF[i,colnames(DF)=="TotServices"]<-Func_Index_DF(DF,i,"TotServices")+1
}
return(DF)
}
###Function for Output Days:
#Function to get leftover ST food.
Func_Left_ST<-function(df, ST_Aside){
#Fruit that stayed in share table.
Left_ST<-df[which(df$Location == "Shared"),]
if(ST_Aside==1){
Left_ST_Aside<-df[which(df$Location == "SharedAside"),]
Left_ST<-bind_rows(Left_ST, Left_ST_Aside)
}
return (Left_ST)
}
Func_Left_Sel<-function(df){
#Fruit that stayed in Selection table
Left_Selection<-df[which(df$Location == "Selection Table"),]
No_Left_ST_Fr<-nrow(Left_ST_Fr)
No_Left_Selection_Fr<-nrow(Left_Selection_Fr)
}
##Removed:
# #Updated items from not consumed, not shared, etc to wasted.
# Fr_Data.Frame$Location[Fr_Data.Frame$Location=="Not Shared"]<-"Discarded"
# Fr_Data.Frame$Location[Fr_Data.Frame$Location=="Not Consumed"]<-"Discarded"
# ##### Discard Items from the final service.
# if(k==Food_Days && j==Service_No){
# Fr_Data.Frame$Location[Fr_Data.Frame$Location=="Selection Table"]<-"Discarded"
# Fr_Data.Frame$Location[Fr_Data.Frame$Location=="Shared"]<-"Discarded"
# Fr_Data.Frame$Location[Fr_Data.Frame$Location=="SharedAside"]<-"Discarded"
# }
#
# #Updated items from not consumed, not shared, etc to wasted.
# Pss_Data.Frame$Location[Pss_Data.Frame$Location=="Not Shared"]<-"Discarded"
# Pss_Data.Frame$Location[Pss_Data.Frame$Location=="Not Consumed"]<-"Discarded"
# ##### Discard Items from the final service.
# if(k==Food_Days && j==Service_No ){
# Pss_Data.Frame$Location[Pss_Data.Frame$Location=="Selection Table"]<-"Discarded"
# Pss_Data.Frame$Location[Pss_Data.Frame$Location=="Shared"]<-"Discarded"
# Pss_Data.Frame$Location[Pss_Data.Frame$Location=="SharedAside"]<-"Discarded"
# }
#
# #Updated items from not consumed, not shared, etc to wasted.
# Pre_Data.Frame$Location[Pre_Data.Frame$Location=="Not Shared"]<-"Discarded"
# Pre_Data.Frame$Location[Pre_Data.Frame$Location=="Not Consumed"]<-"Discarded"
# ##### Discard Items from the final service.
# if(k==Food_Days && j==Service_No ){
# Pre_Data.Frame$Location[Pre_Data.Frame$Location=="Selection Table"]<-"Discarded"
# Pre_Data.Frame$Location[Pre_Data.Frame$Location=="Shared"]<-"Discarded"
# Pre_Data.Frame$Location[Pre_Data.Frame$Location=="SharedAside"]<-"Discarded"
#
# }