Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205372

Print separated by comma, remove quotes and add special quotes in R

$
0
0

I have a table which contains the names of data frames in TSV format, like so:

df1 <- t(c('18-1829.tsv', '19-0193.tsv', '14-381.tsv', '19-940.tsv'))
df1

  V1          V2          V3         V4
1 18-1829.tsv 19-0193.tsv 14-381.tsv 19-940.tsv

These .tsv files I have them in the R environment. What I want to do is rbind them, and regarding this function, the inside should look like:

df2 <- rbind(`18-1829.tsv`, `19-0193.tsv`, `14-381.tsv`, `19-940.tsv`)

Note that I need the special quotes `` in order for this to function.

So what I want to do is print out a text where the output looks like:

dfX <- `18-1829.tsv`, `19-0193.tsv`, `14-381.tsv`, `19-940.tsv`

So I could simply do rbind(dfX) and bind them all.

So far I tried:

> paste(as.character(noquote(df1)), collapse="`, `")
[1] "18-1829.tsv`, `19-0193.tsv`, `14-381.tsv`, `19-940.tsv"

But this is rather wrong since it doesn't output `` at the beggining nor at the end, plus there's the [1] at the beggining which can mess up the thing going inside rbind. Also, the "" quotes at the beggining and end may mess it up aswell.

Maybe there is a better way to do this?


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>