Let's say I have an existing list called myList
.
myList <- list(list1=c("item1", "item2"), list2=c("item3", "item4"))
myList
thus contains:
$list1
[1] "item1" "item2"
$list2
[1] "item3" "item4"
I want to append .t0
to each element of list1
and list2
within myList
so I end up with:
$list1
[1] "item1.t0" "item2.t0"
$list2
[1] "item3.t0" "item4.t0"
I do not want to go back to the list(list1=c("item1", "item2"), list2=c("item3", "item4"))
step and add .t0
there. I want to manipulate myList
to add .t0
.
When the Prefix and Suffix window opens, add one or the other, or both, in the Prefix and Suffix boxes. Check the box for Apply to Entire List and click “OK.” As an example, we’ll use “Step” as the prefix and a greater than symbol (>) instead of a period as the suffix.
After adding the suffix (PHD.) to the first cell, you can quickly add this common Suffix to all the other Cells by dragging the formula down to all the Cells in column C (See image below). Another way to Add Prefix or Suffix to a group of Cells in Excel is to make use of the “Concatenate” function as available in Microsoft Excel.
Suffix: is an affix that is placed at the end of an entity in order to alter its meaning. For example in the word “ strongest ” est is a suffix and strong is an original entity.
Prefix: is an affix that is placed at the beginning of an entity in order to alter its meaning. For example in the word “ rematch ” re is a prefix and match is an original entity.
Use lapply
and paste0
> lapply(myList, paste0, ".t0")
$list1
[1] "item1.t0" "item2.t0"
$list2
[1] "item3.t0" "item4.t0"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With