How to add a same substring across multiple columns in R

2

I have a base with 2 rows and 68 observations called "varnomes" and would like to add the word "PF" at the end of each observation. With this, I tried to use the paste function:

varnomes<-paste(varnomes,"PF")

But I did not succeed.

The first three columns of my database are like this, for example:

a b c
g r v

And I want you to stay:

aPF bPF cPF
gPF rPF vPF

Any suggestion with apply or another function?

    
asked by anonymous 13.03.2017 / 21:34

2 answers

3

Using the same base df created by @ José:

df[] <- lapply(df, paste0, "PF")
    
14.03.2017 / 02:55
3

Try this:

df<-data.frame(var1=c("a","b","c"),var2=c("g","r","v"),stringsAsFactors=F)
df[]<-paste0(unlist(df[]),"PF")
    
14.03.2017 / 02:01