Skip to content

Commit 925b0bf

Browse files
committed
Re-encode column names as UTF8
1 parent 35de85a commit 925b0bf

File tree

7 files changed

+8
-5
lines changed

7 files changed

+8
-5
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646

4747
* Made compatible with both dplyr 0.4 and 0.5.
4848

49+
* tidyr functions that create new columns are more aggresive about re-encoding
50+
the column names as UTF-8.
51+
4952
# tidyr 0.4.1
5053

5154
* Fixed bug in `nest()` where nested data was ending up in the wrong row (#158).

R/extract.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extract_.data.frame <- function(data, col, into, regex = "([[:alnum:]]+)",
5757
matches <- stringi::stri_match_first_regex(value, regex)[, -1, drop = FALSE]
5858
# Use as_data_frame post https://github.com/hadley/dplyr/issues/876
5959
l <- lapply(seq_len(ncol(matches)), function(i) matches[, i])
60-
names(l) <- into
60+
names(l) <- enc2utf8(into)
6161

6262
if (convert) {
6363
l[] <- lapply(l, type.convert, as.is = TRUE)

R/nest.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ nest_impl <- function(data, key_col, group_cols, nest_cols) {
7171

7272
if (length(group_cols) == 0) {
7373
df <- data_frame(list(data))
74-
names(df) <- key_col
74+
names(df) <- enc2utf8(key_col)
7575

7676
return(df)
7777
}

R/separate.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ separate_.data.frame <- function(data, col, into, sep = "[^[:alnum:]]+",
9898
stop("'sep' must be either numeric or character", .call = FALSE)
9999
}
100100

101-
names(l) <- into
101+
names(l) <- enc2utf8(into)
102102
if (convert) {
103103
l[] <- lapply(l, type.convert, as.is = TRUE)
104104
}

R/spread.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ spread_.data.frame <- function(data, key_col, value_col, fill = NA,
125125
ordered <- as.character(ordered)
126126
}
127127
dim(ordered) <- c(attr(row_id, "n"), attr(col_id, "n"))
128-
colnames(ordered) <- col_names(col_labels, sep = sep)
128+
colnames(ordered) <- enc2utf8(col_names(col_labels, sep = sep))
129129

130130
ordered <- as_data_frame_matrix(ordered)
131131

R/unite.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ unite_.data.frame <- function(data, col, from, sep = "_", remove = TRUE) {
5252
data2 <- data2[setdiff(names(data2), from)]
5353
}
5454

55-
5655
append_col(data2, united, col, after = first_col - 1)
5756
}
5857

R/utils.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ append_df <- function(x, values, after = length(x)) {
1616
}
1717

1818
append_col <- function(x, col, name, after = length(x)) {
19+
name <- enc2utf8(name)
1920
append_df(x, setNames(list(col), name), after = after)
2021
}
2122

0 commit comments

Comments
 (0)