'Removing tab space from a column in R [duplicate]

Can you please help me to remove a space from the ID column in my data? I have data frame like this:

df<-data.frame(
  "ID" = c("G 249485", "L 938495", "N 234987"), type=c("a","b","c"))
r


Solution 1:[1]

library(stringr)
df$ID <- str_replace(df$ID, " ", "")
df

Solution 2:[2]

library(dplyr)
df <- df %>% mutate(ID = gsub(" ","",ID))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bloxx
Solution 2 ekolima