Skip to content

Commit

Permalink
replace ( and ) in strings with . to prevent column name erors
Browse files Browse the repository at this point in the history
ocurs with "Virgin Islands (British)" as country of incorporation
  • Loading branch information
stivalaa committed Oct 28, 2022
1 parent c73dcfc commit 2ab6430
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ if (get_giantcomponent) {
## prevent problems with header column names etc. (E.g. "Oil & gas" is
## changed to "Oil.and.Gas"
## Also replace '-' with '.' and '/' with '.' and ',' with '.'
## and also '(' and ')' with '.' (occurs in "Virgin Islands (British)")
##
print('replacing problematic characters in strings with "."...')
for (colname in names(dat)) {
Expand All @@ -381,6 +382,12 @@ for (colname in names(dat)) {
g <- set.vertex.attribute(g, colname,
value = sapply(get.vertex.attribute(g, colname),
function(s) gsub(",", ".", s)))
g <- set.vertex.attribute(g, colname,
value = sapply(get.vertex.attribute(g, colname),
function(s) gsub("(", ".", s)))
g <- set.vertex.attribute(g, colname,
value = sapply(get.vertex.attribute(g, colname),
function(s) gsub(")", ".", s)))
}


Expand Down

0 comments on commit 2ab6430

Please sign in to comment.