为列表值R添加前缀和后缀

Vas*_*sim 1 r

我的R代码

data <- read.csv('filename.csv')
typof(data)
[1] "list"

str(data)
    'data frame' : 9 obs. of 10 variables
    $Name: Factor w/9 levels "Name 1", "Name 2",....
    $Column2: chr "","Text1","","Text2"
    $Column3: chr "Text2","Text3","","Text1"
    $Column4: chr "","","","Text1"
#and so on
Run Code Online (Sandbox Code Playgroud)

需求:

我要的是$Column2,$Column3,$Column4,...等.无论有一个非空值,添加前缀(Here this is)和后缀(completed).所以考虑到上面data Column2,目前有价值的第二行"Text1"应该成为"Here this is Text1 completed."

同样在Column3: 1st, 2nd and 4th cell需要添加前缀和后缀值.

不想使用循环,除非直到需要/必要.

我的尝试:

我曾尝试一些尝试,例如interaction,mget,append多几个,但似乎没有任何工作.

Dav*_*urg 5

我会按如下方式对此进行矢量化

indx <- which(data[, -1] != "", arr.ind = TRUE) # Find all non-empty incidences 
data[, -1][indx] <- paste("Here this is", data[, -1][indx], "completed.")
Run Code Online (Sandbox Code Playgroud)