-
Notifications
You must be signed in to change notification settings - Fork 1
/
.Rhistory
301 lines (301 loc) · 33.3 KB
/
.Rhistory
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# load database
load('./R/SDG_keys.RData')
View(SDG_keys)
load("~/Documents/Projects/findSDGs/R/SDG_keys.RData")
# load database
load('./R/SDG_keys.RData')
load("~/Documents/Projects/findSDGs/R/SDG_keys.RData")
# load database
load('./R/SDG_keys.RData')
sdg_detector <- function(dataframe, company_name) {
code <- dataframe %>%
dplyr::mutate(#match = 0,
sdgs = '', ## for later use, to append data to this column
n_total = 0,
sdgs_n = '')
for (i in 1:nrow(SDG_keys)){ ## all SDG indicators
sdg_i_str <- SDG_keys$SDG_id[i] ## the SDG id name
sdg_i_obj <- SDG_keys$SDG_keywords[i] ## the corresponding SDG search term list
print(sdg_i_str)
# print(sdg_i_obj)
code <- code %>% as.data.frame() %>%
## at the sentence level - count once ----------------------
dplyr::mutate(
match = ifelse(
grepl(pattern = sdg_i_obj, x = statement, ignore.case = T, perl = T), 1, 0)) %>% ## yes-1 or no-0 if they match
dplyr::mutate(sdgs = ifelse(match > 0, paste0(sdgs, ',', sdg_i_str), sdgs)) %>%
## at the sentence level - count all matches ---------------
dplyr::mutate(
n = str_count(string = statement, regex(pattern = sdg_i_obj, ignore_case = T)),
n_total = n_total + n,
sdgs_n = ifelse(n > 0, paste0(sdgs_n, ',', sdg_i_str, '-', n), sdgs_n)) %>%
as.data.frame()
}
### sort from most SDG hits to least (or, none)
coded <- code %>% arrange(desc(nchar(sdgs)), id)
### save all the hits to xlsx for easier inspection.
# fname <- paste0(dirpath, 'DF_coded/', company_name, '_coded.xlsx'); fname
# writexl::write_xlsx(x = coded, path = fname)
fname <- paste0('./data/output/', company_name, '_coded.csv'); fname
readr::write_csv(x = coded, file = fname)
fname <- paste0('./data/output/', company_name, '_coded.RData'); fname
save(coded, file = fname)
return(coded)
}
# load database
load('./R/SDG_keys.RData')
# load database
load('./R/SDG_keys.RData')
View(SDG_keys)
# identify 17 Sustainable Development Goals and associated targets in text
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character))
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
match <- ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match == 1, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
}
test_df <- data.frame(boo = c("and conference calls Quarterly financial updates and guidance Annual integrated report, annual reports, and mandatory filings Ongoing website updates and press releases Annual CEMEX Day investor event Understanding of CEMEXs financial position, performance, business perspectives, and risks Understanding of management and corporate ESG practices ACADEMIC INSTITUTIONS & NGOs Development of communities and regions Collaboration in applied research projects Engaging students Develop employees talent and awareness of global trends Innovation efforts Yearly collaborative research portfolio Bi-weekly Lighthouses talks Quarterly whitepapers Yearly best practices and methodologies playbooks Annual event to share the projects outcomes Hackathons co-organized with Universities Impact through collaborative projects to develop knowledge and solutions Build strategic partnerships with top universities Employee awareness of global trends Attract new talent for CEMEX COMMUNITIES Education and capability development Sustainable and resilient infrastructure and mobility Social and environmental innovation and entrepreneurship Health and safety, environment protection culture Human Rights Accountability and transparent communication Contribution to community quality of life and wellbeing Local employment opportunities Economic empowerment for women in communities Ongoing dialogues with community stakeholders Quarterly community panels, sessions, and meetings Annual open house days at operating sites Ongoing educational programs and training Participation in local career events Development of community infrastructure, volunteering, and social investment initiatives Development of inclusive business programs Creation of social and inclusive businesses Generation of empowerment and capacity-building Improvement to community infrastructure and wellbeing Development of learning opportunities Open communication and feedback Community transformation SUPPLIERS Health and safety Companys economic performance in mid and long term Fair business conditions Sustainability management practices Daily procurement interactions Ongoing capacity building programs Supplier sustainability guidance CEMEX Supplier Sustainability Program Inclusion of human rights, labor, antitrust, and sustainability clauses in our contracts and purchase orders Promotion of local suppliers GOVERNMENTS AND POLICY MAKERS Environmental impact mitigation and management Companys economic performance in mid and long term Health and safety Climate change and CO2 emissions policy Infrastructure and housing solutions Local employment opportunities Annual integrated report and conservation books Ongoing public policy discussions Long-term partnerships Working groups Periodic plant visits Events and conferences Collaboration and communication with governments and regulatory bodies Successful adaptations to new local, national, and regional regulations BUSINESS ASSOCIATIONS Active engagement and guidance Periodic meetings Annual conferences Ongoing working groups Ongoing research studies Development of coordinated initiatives with trade associations Best practices sharing COMMUNICATION MECHANISMS WITH OUR STAKEHOLDERS We outline the key concerns brought up by our materiality assessment and how we engage with our key stakeholders in the table below", "200 1 Company Overview 2 How We Create Value 3 Our Performance 4 Governance 5 Results in Detail 6 About this ReportContents ENVIRONMENTAL AND QUALITY MANAGEMENT 2016 2017 2018 Sites with ISO 9001 Certification (%) 45 46 47 Cement 79 82 84 Ready-mix 44 45 46 Aggregates 41 43 41 Environmental investment (US million) 80 83 83 Environmental incidents (No.) Category 1 (Major) 0 0 1 Category 2 (Moderate) 64 37 37 Category 3 (Minor) 224 216 238 Complaints 77 81 114 Social incidents (No.)10 80 Environmental fines above US$10,000 (No.) 1 2 2 Total Environmental fines (No.)11 51 56 37 Environmental fines above US$10,000 (US million) 0.02 0.08 0.44 Total Environmental fines (US million) 0.15 0.39 0.58 AIR QUALITY MANAGEMENT 2016 2017 2018 Clinker produced with continuous monitoring of major emissions (dust, NOX and SOX) (%) 84 92 98 Clinker produced with monitoring of major and minor emissions (dust, NOX, SOX, Hg, Cd, TI, VOC, PCDD/F) (%) 80 80 80 Absolute dust emissions (ton/year) 2,703 2,214 1,911 Specific dust emissions (g/ton clinker) 67 47 39 Absolute NOX emissions (ton/year) 76,552 57,973 56,228 Specific NOX emissions (g/ton clinker) 1,533 1,177 1,141 Absolute SOX emissions (ton/year) 13,089 10,399 11,543 Specific SOX emissions (g/ton clinker) 253 216 233 Annual reduction in dust emissions per ton of clinker from 2005 baseline (%) 78 84 87 Annual reduction in NOX emissions per ton of clinker from 2005 baseline (%) 26 43 45 Annual reduction in SOX emissions per ton of clinker from 2005 baseline (%) 61 67 64 WATER MANAGEMENT 2016 2017 2018 Total water withdrawals by source (million m3) 62.1 61.4 65.6 Surface water 22.5 22.3 18.9 Ground water 24.3 24.7 30.6 Municipal water 11.5 10.4 12.0 Rain water 0.4 0.4 0.3 Sea water 0.0 0.0 0.0 Other 3.4 3.7 3.8 WATER MANAGEMENT 2016 2017 2018 Total water discharge by destination (million m3) 18.6 22.6 24.7 Surface water 11.0 11.8 12.3 Ground water 6.8 10.2 11.1 Municipal water 0.8 0.5 1.0 Sea water 0.0 0.0 0.0 Other 0.0 0.2 0.2 Total water consumption (million m3) 43.5 38.7 40.9 Cement 15.5 14.3 14.6 Ready-mix 11.5 11.2 13.6 Aggregates 16.5 13.2 12.7 Specific water consumption Cement (l/ton) 247 235 232 Ready-mix (l/m3) 222 219 258 Aggregates (l/ton) 131 107 102 Sites with water recycling systems (%) 79 85 83 BIODIVERSITY MANAGEMENT 2016 2017 2018 Active sites with quarry rehabilitation plans (%) 94 97 96 Cement 90 94 92 Aggregates 96 98 97 Active quarries located within or adjacent to high biodiversity value areas (No.) 63 64 58 Cement 9 11 10 Aggregates 54 53 48 Active quarries located within or adjacent to high biodiversity value areas where Biodiversity Action Plans (BAPs) are implemented (%) 63 69 91 Cement 89 73 90 Aggregates 59 68 92 Quarry rehabilitation plans, Biodiversity Action Plans (BAPs), and third party certification (% from target quarries)5 65 CUSTOMERS AND SUPPLIERS 2016 2017 2018 Purchases sourced from locally-based suppliers (%) 95 89 90 Sustainability assessment executed by an independent party for our critical suppliers (% spend evaluated)12 44 Countries that conduct regular customer satisfaction surveys (%) 100 100 100 Net Promoter Score (NPS) (%)13 44 ETHICS AND COMPLIANCE 2016 2017 2018 Executives and employees actively aware of our Code of Ethics (%)14 77 77 77 Reports of alleged breaches to the Code of Ethics received by Local Ethics Committees (No.) 453 568 630 Ethics and compliance cases reported during the year that were investigated and closed (%) 68 73 77 Disciplinary actions taken as a result of reports of non-compliance with the Code of Ethics, other policies or the law (No.) 115 185 166 Target countries that participated on the Global Compliance Program (antitrust, antri-bribery and insider trading) (%) 100 100 100 Countries with local mechanisms to promote employee awareness of procedures to identify and report incidences of internal fraud, kickbacks, among others (%) 100 100 100 Investigated incidents reported and found to be true related to fraud, kick-backs among others corruption incidents to government officials (No.) 0 0 0 Implementation of Ethics and Compliance Continuous Improvement Program (%)5 50 GRI 102-48, GRI 102-49 Footnotes"))
test_df <- data.frame(boo = c('and conference calls Quarterly financial updates and guidance Annual integrated report, annual reports, and mandatory filings Ongoing website updates and press releases Annual CEMEX Day investor event Understanding of CEMEXs financial position, performance, business perspectives, and risks Understanding of management and corporate ESG practices ACADEMIC INSTITUTIONS & NGOs Development of communities and regions Collaboration in applied research projects Engaging students Develop employees talent and awareness of global trends Innovation efforts Yearly collaborative research portfolio Bi-weekly Lighthouses talks Quarterly whitepapers Yearly best practices and methodologies playbooks Annual event to share the projects outcomes Hackathons co-organized with Universities Impact through collaborative projects to develop knowledge and solutions Build strategic partnerships with top universities Employee awareness of global trends Attract new talent for CEMEX COMMUNITIES Education and capability development Sustainable and resilient infrastructure and mobility Social and environmental innovation and entrepreneurship Health and safety, environment protection culture Human Rights Accountability and transparent communication Contribution to community quality of life and wellbeing Local employment opportunities Economic empowerment for women in communities Ongoing dialogues with community stakeholders Quarterly community panels, sessions, and meetings Annual open house days at operating sites Ongoing educational programs and training Participation in local career events Development of community infrastructure, volunteering, and social investment initiatives Development of inclusive business programs Creation of social and inclusive businesses Generation of empowerment and capacity-building Improvement to community infrastructure and wellbeing Development of learning opportunities Open communication and feedback Community transformation SUPPLIERS Health and safety Companys economic performance in mid and long term Fair business conditions Sustainability management practices Daily procurement interactions Ongoing capacity building programs Supplier sustainability guidance CEMEX Supplier Sustainability Program Inclusion of human rights, labor, antitrust, and sustainability clauses in our contracts and purchase orders Promotion of local suppliers GOVERNMENTS AND POLICY MAKERS Environmental impact mitigation and management Companys economic performance in mid and long term Health and safety Climate change and CO2 emissions policy Infrastructure and housing solutions Local employment opportunities Annual integrated report and conservation books Ongoing public policy discussions Long-term partnerships Working groups Periodic plant visits Events and conferences Collaboration and communication with governments and regulatory bodies Successful adaptations to new local, national, and regional regulations BUSINESS ASSOCIATIONS Active engagement and guidance Periodic meetings Annual conferences Ongoing working groups Ongoing research studies Development of coordinated initiatives with trade associations Best practices sharing COMMUNICATION MECHANISMS WITH OUR STAKEHOLDERS We outline the key concerns brought up by our materiality assessment and how we engage with our key stakeholders in the table below', '200 1 Company Overview 2 How We Create Value 3 Our Performance 4 Governance 5 Results in Detail 6 About this ReportContents ENVIRONMENTAL AND QUALITY MANAGEMENT 2016 2017 2018 Sites with ISO 9001 Certification (%) 45 46 47 Cement 79 82 84 Ready-mix 44 45 46 Aggregates 41 43 41 Environmental investment (US million) 80 83 83 Environmental incidents (No.) Category 1 (Major) 0 0 1 Category 2 (Moderate) 64 37 37 Category 3 (Minor) 224 216 238 Complaints 77 81 114 Social incidents (No.)10 80 Environmental fines above US$10,000 (No.) 1 2 2 Total Environmental fines (No.)11 51 56 37 Environmental fines above US$10,000 (US million) 0.02 0.08 0.44 Total Environmental fines (US million) 0.15 0.39 0.58 AIR QUALITY MANAGEMENT 2016 2017 2018 Clinker produced with continuous monitoring of major emissions (dust, NOX and SOX) (%) 84 92 98 Clinker produced with monitoring of major and minor emissions (dust, NOX, SOX, Hg, Cd, TI, VOC, PCDD/F) (%) 80 80 80 Absolute dust emissions (ton/year) 2,703 2,214 1,911 Specific dust emissions (g/ton clinker) 67 47 39 Absolute NOX emissions (ton/year) 76,552 57,973 56,228 Specific NOX emissions (g/ton clinker) 1,533 1,177 1,141 Absolute SOX emissions (ton/year) 13,089 10,399 11,543 Specific SOX emissions (g/ton clinker) 253 216 233 Annual reduction in dust emissions per ton of clinker from 2005 baseline (%) 78 84 87 Annual reduction in NOX emissions per ton of clinker from 2005 baseline (%) 26 43 45 Annual reduction in SOX emissions per ton of clinker from 2005 baseline (%) 61 67 64 WATER MANAGEMENT 2016 2017 2018 Total water withdrawals by source (million m3) 62.1 61.4 65.6 Surface water 22.5 22.3 18.9 Ground water 24.3 24.7 30.6 Municipal water 11.5 10.4 12.0 Rain water 0.4 0.4 0.3 Sea water 0.0 0.0 0.0 Other 3.4 3.7 3.8 WATER MANAGEMENT 2016 2017 2018 Total water discharge by destination (million m3) 18.6 22.6 24.7 Surface water 11.0 11.8 12.3 Ground water 6.8 10.2 11.1 Municipal water 0.8 0.5 1.0 Sea water 0.0 0.0 0.0 Other 0.0 0.2 0.2 Total water consumption (million m3) 43.5 38.7 40.9 Cement 15.5 14.3 14.6 Ready-mix 11.5 11.2 13.6 Aggregates 16.5 13.2 12.7 Specific water consumption Cement (l/ton) 247 235 232 Ready-mix (l/m3) 222 219 258 Aggregates (l/ton) 131 107 102 Sites with water recycling systems (%) 79 85 83 BIODIVERSITY MANAGEMENT 2016 2017 2018 Active sites with quarry rehabilitation plans (%) 94 97 96 Cement 90 94 92 Aggregates 96 98 97 Active quarries located within or adjacent to high biodiversity value areas (No.) 63 64 58 Cement 9 11 10 Aggregates 54 53 48 Active quarries located within or adjacent to high biodiversity value areas where Biodiversity Action Plans (BAPs) are implemented (%) 63 69 91 Cement 89 73 90 Aggregates 59 68 92 Quarry rehabilitation plans, Biodiversity Action Plans (BAPs), and third party certification (% from target quarries)5 65 CUSTOMERS AND SUPPLIERS 2016 2017 2018 Purchases sourced from locally-based suppliers (%) 95 89 90 Sustainability assessment executed by an independent party for our critical suppliers (% spend evaluated)12 44 Countries that conduct regular customer satisfaction surveys (%) 100 100 100 Net Promoter Score (NPS) (%)13 44 ETHICS AND COMPLIANCE 2016 2017 2018 Executives and employees actively aware of our Code of Ethics (%)14 77 77 77 Reports of alleged breaches to the Code of Ethics received by Local Ethics Committees (No.) 453 568 630 Ethics and compliance cases reported during the year that were investigated and closed (%) 68 73 77 Disciplinary actions taken as a result of reports of non-compliance with the Code of Ethics, other policies or the law (No.) 115 185 166 Target countries that participated on the Global Compliance Program (antitrust, antri-bribery and insider trading) (%) 100 100 100 Countries with local mechanisms to promote employee awareness of procedures to identify and report incidences of internal fraud, kickbacks, among others (%) 100 100 100 Investigated incidents reported and found to be true related to fraud, kick-backs among others corruption incidents to government officials (No.) 0 0 0 Implementation of Ethics and Compliance Continuous Improvement Program (%)5 50 GRI 102-48, GRI 102-49 Footnotes'))
test_df <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'environmental and ecosystem conservation (SDG 15)',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
test_df <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
View(test_df)
findSDGs(test_df)
library(dplyr)
# identify 17 Sustainable Development Goals and associated targets in text
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character))
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
match <- ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match == 1, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
}
test_df <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
findSDGs(test_df)
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match == 1, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match == 1, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
}
# identify 17 Sustainable Development Goals and associated targets in text
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character))
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match == 1, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
}
test_df <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
findSDGs(test_df)
coded_test <- findSDGs(test)
# load database
load('./R/SDG_keys.RData')
library(dplyr)
# identify 17 Sustainable Development Goals and associated targets in text
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character))
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match == 1, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
}
test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
coded_test <- findSDGs(test)
View(coded_test)
# identify 17 Sustainable Development Goals and associated targets in text
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character))
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match > 0, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
}
test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
coded_test <- findSDGs(test)
View(coded_test)
test <- data.frame(boo=c("Our adherence to values evaluation invites direct supervisors, direct reports, and other employee stakeholders to share their perception of specific behaviors aligned with each one of our core values"))
#test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
test <- data.frame(boo=c("Our adherence to values evaluation invites direct supervisors, direct reports, and other employee stakeholders to share their perception of specific behaviors aligned with each one of our core values"))
coded_test <- findSDGs(test)
View(coded_test)
# identify 17 Sustainable Development Goals and associated targets in text
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character)) # locate the column of text
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
print(target_id)
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match > 0, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
return(coded_df)
}
test <- data.frame(boo=c("Our adherence to values evaluation invites direct supervisors, direct reports, and other employee stakeholders to share their perception of specific behaviors aligned with each one of our core values"))
coded_test <- findSDGs(test)
nrow(SDG_keys)
# identify 17 Sustainable Development Goals and associated targets in text
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character)) # locate the column of text
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
print(target_id)
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match > 0, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
}
return(coded_df)
}
test <- data.frame(boo=c("Our adherence to values evaluation invites direct supervisors, direct reports, and other employee stakeholders to share their perception of specific behaviors aligned with each one of our core values"))
coded_test <- findSDGs(test)
View(coded_test)
#test <- data.frame(boo=c("Our adherence to values evaluation invites direct supervisors, direct reports, and other employee stakeholders to share their perception of specific behaviors aligned with each one of our core values"))
test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
coded_test <- findSDGs(test)
View(coded_test)
# identify 17 Sustainable Development Goals and associated targets in text
# input: a dataframe
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character)) # locate the column of text
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_target = ifelse(match > 0, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
}
coded_df <- subset(coded_df, select = -match)
return(coded_df)
}
test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
coded_test <- findSDGs(test)
View(coded_test)
coded_df <- subset(coded_df, select = -match)
# load database
load('./R/SDG_keys.RData')
library(dplyr)
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character)) # locate the column of text
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i] # to add later
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_sdg = ifelse(match > 0, paste0(matched_sdg, sdg_id, ', '), matched_sdg),
matched_target = ifelse(match > 0, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
}
coded_df <- subset(coded_df, select = -match)
return(coded_df)
}
test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate'))
coded_test <- findSDGs(test)
View(coded_test)
test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate',
'We are further leading the UN Global compact in Mexico, encouraging more companies to partner to contribute and explore business opportunities while reducing negative impact, and creating shared value to society'))
coded_test <- findSDGs(test)
View(coded_test)
View(SDG_keys)
library(dplyr)
findSDGs <- function(df) {
text_df <- df %>% dplyr::select(where(is.character)) # locate the column of text
colnames(text_df) <- "statement"
coded_df <- text_df %>% dplyr::mutate(matched_sdg = '', matched_target = '')
#sdg_count = '', target_count = '' # to add later
for (i in 1:nrow(SDG_keys)) {
sdg_id <- SDG_keys$SDG_id[i]
target_id <- SDG_keys$target_id[i]
target_key <- SDG_keys$SDG_keywords[i]
coded_df <- coded_df %>%
dplyr::mutate(match = ifelse(grepl(pattern = target_key, x = statement, ignore.case = T, perl = T), 1, 0)) %>%
dplyr::mutate(matched_sdg = ifelse(match > 0, paste0(matched_sdg, sdg_id, ', '), matched_sdg),
matched_target = ifelse(match > 0, paste0(matched_target, target_id, ', '), matched_target)) %>%
as.data.frame()
}
coded_df <- subset(coded_df, select = -match)
return(coded_df)
}
test <- data.frame(boo=c('To this end, we tailor our products and services to suit our customers specific needsfrom home construction, improvement, and renovation to agricultural, industrial, and marine/hydraulic applications',
'define and carry out a worldwide survey across Working with a diverse group of stakeholderslistening to their concerns and managing our relations in a proactive and fruitful wayis crucial to understanding our ecosystem and maximizing our positive impact in the places where we operate',
'We are further leading the UN Global compact in Mexico, encouraging more companies to partner to contribute and explore business opportunities while reducing negative impact, and creating shared value to society'))
coded_test <- findSDGs(test)
View(coded_test)
library(findSDGs)
my_text <- data.frame(my_col=c('our goal is to end poverty globally', 'this product contributes to slowing down climate change'))
findSDGs(my_text, my_col)
findSDGs(df = my_text, col = my_col)