Consider the following minimal working example:
df <- tibble::tibble(
x=c(1, 10)
)
mwe <- function(row) {
return(paste0(row[["x"]]))
}
df$mwe1 = apply(df, 1, mwe)
df$mwe2 = apply(df, 1, mwe)
The final value of df
is
# A tibble: 2 × 3
x mwe1 mwe2
<dbl> <chr> <chr>
1 1 1 " 1"
2 10 10 "10"
I expect it to be
# A tibble: 2 × 3
x mwe1 mwe2
<dbl> <chr> <chr>
1 1 1 1
2 10 10 10
Can I get an explanation of why column mwe2
has the extra whitespace?
R.version
info
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 1.2
year 2021
month 11
day 01
svn rev 81115
language R
version.string R version 4.1.2 (2021-11-01)
nickname Bird Hippie