0

I am working on a Shiny application, in this app i have an init JSON file which determines metadatas as columns name for example. I have a field which is used to select the columns that we want among these. What I want to do is to read a csv file by reading only the selected columns.

I hope someone can help me on this point ! Thanks you :)

Q. Eude
  • 841
  • 11
  • 24

1 Answers1

1

Use the select argument to fread from the data.table package:

library(data.table)
fread("thefile.csv", select = c("columns", "you", "want"))

for example

fread("https://www.everycrsreport.com/reports.csv", select = c("number", "url"))
Hugh
  • 15,521
  • 12
  • 57
  • 100