Replacing spaces with periods

Hello!

I have a data frame with the variable "weight_lb_oz" and the observations are recorded as 10 11, 12 13, 16 15 etc.) There is a space between lb and oz and I was wondering if there is any way to replace the space with a period instead.

Help appreciated!
Thanks!

xbechtel

Hello,

Something like this?

library(stringr)

df <- c("weight_lb_oz")
str_replace_all(df, "_", ".")
#> [1] "weight.lb.oz"

Created on 2020-10-18 by the reprex package (v0.3.0)

1 Like