I have the following data (a list of R packages parsed from a Rmarkdown file), that I want to turn into a list I can pass to R to install:
d3heatmap data.table ggplot2 htmltools htmlwidgets metricsgraphics networkD3 plotly reshape2 scales stringr
I want to turn the list into a list of the form:
'd3heatmap', 'data.table', 'ggplot2', 'htmltools', 'htmlwidgets', 'metricsgraphics', 'networkD3', 'plotly', 'reshape2', 'scales', 'stringr'
I currently have a bash pipeline that goes from the raw file to the list above:
grep 'library(' Presentation.Rmd \ | grep -v '#' \ | cut -f2 -d\( \ | tr -d ')' \ | sort | uniq
I want to add a step on to turn the new lines into the comma separated list. I've tried adding
tr '\n' '","', which fails. I've also tried a number of the following Stack Overflow answers, which also fail:
library(stringr)))phics) as the result.
,% as the result.
This answer (with the
-i flag removed), produces output identical to the input.