Like all capabilities in the information.desk R offer, fread is fast. Quite fast. But there’s more to fread than pace. It has various helpful functions and solutions when importing external information into R. Right here are 5 of the most beneficial.

Take note: If you’d like to observe together, down load the New York Occasions CSV file of everyday Covid-19 circumstances by U.S. county at https://github.com/nytimes/covid-19-information/uncooked/learn/us-counties.csv.

Use fread’s nrows selection

Is your file huge? Would you like to take a look at its composition prior to importing the full thing – with no getting to open it in a textual content editor or Excel? Use fread’s nrows selection to import only a part of a file for exploration.

The code underneath imports just the initially ten rows of the CSV.

mydt10 <- fread("us-counties.csv", nrows = 10)

If you just want to see column names with no any information at all, you can use nrows =

Use fread’s decide on selection

The moment you know the file composition, you can pick out which columns to import. fread’s decide on selection lets you pick columns you want to keep. decide on can take a vector of possibly column names or column-position figures. If names, they have to have to be in quotation marks, like most vectors of character strings:

Copyright © 2020 IDG Communications, Inc.