I am trying to read data from a column and then concatenate my desired information into a string.
So far I wrote R script successful for a single string input, but I can't mange to do it for
reprows <- strsplit("Day1_XExp2B3_500x_Y_Z", "_", fixed = T)
lenreprows <- length(reprows[])
temprepnamelisttopaste <- c(2:(lenreprows-2))
temprepname <- paste(sapply(reprows[temprepnamelisttopaste]),collapse='.')
## a function for re-concatenation rc <- function (u) paste0(u[2:(length(u)-2L)], collapse = ".") ## main code unlist(lapply(strsplit(x, "_", fixed = T), rc))
x is your character column with many elements. I made a simple test with
x <- rep("Day1_XExp2B3_500x_Y_Z", 2)
and the codes gives
# "XExp2B3.500x" "XExp2B3.500x"
Looks like working fine.