insert character into string r
# Define the original string
original_string <- "Hello World"
# Define the character to insert
char_to_insert <- "!"
# Define the position to insert the character
position <- 6
# Use the paste0 function to insert the character into the original string
modified_string <- paste0(substr(original_string, 1, position - 1), char_to_insert, substr(original_string, position, nchar(original_string)))
# Print the modified string
print(modified_string)