fread() से तेज़ डेटा रीडिंग

R में data.table के साथ Data Manipulation

Matt Dowle, Arun Srinivasan

Instructors, DataCamp

बेहद तेज़!

  • तेज़ और पैरेलल फाइल रीडर
  • nThread आर्ग्युमेंट थ्रेड्स की संख्या नियंत्रित करता है
R में data.table के साथ Data Manipulation

यूज़र-फ्रेंडली

  • लोकल फाइल, वेब से फाइलें, और स्ट्रिंग्स इम्पोर्ट कर सकता है
  • स्मार्ट डिफॉल्ट्स - colClasses, sep, nrows आदि
  • नोट: Dates और Datetimes कैरेक्टर कॉलम के रूप में पढ़े जाते हैं, पर बाद में बेहतरीन fasttime या anytime पैकेज से बदले जा सकते हैं
R में data.table के साथ Data Manipulation

तेज़ और फ्रेंडली फाइल रीडर

# File from URL
DT1<-fread("https://bit.ly/2RkBXhV")
DT1
a b
1 2
3 4
# Local file
DT2 <- fread("data.csv")
DT2
a b
1 2
3 4
# String
DT3 <- fread("a,b\n1,2\n3,4")
DT3
a b
1 2
3 4
# String without col names
DT4 <- fread("1,2\n3,4")
DT4
V1 V2
1  2
3  4
R में data.table के साथ Data Manipulation

nrows और skip आर्ग्युमेंट्स

# Read only first line (after header)
fread("a,b\n1,2\n3,4", nrows = 1)
a b
1 2
# Skip first two lines containing metadata
str <- "# Metadata\nTimestamp: 2018-05-01 19:44:28 GMT\na,b\n1,2\n3,4"
fread(str, skip = 2)
a b
1 2
3 4
R में data.table के साथ Data Manipulation

nrows और skip पर और बातें

str <- "# Metadata\nTimestamp: 2018-05-01 19:44:28 GMT\na,b\n1,2\n3,4"
fread(str, skip = "a,b")
a b
1 2
3 4
fread(str, skip = "a,b", nrows = 1)
a b
1 2
R में data.table के साथ Data Manipulation

select और drop आर्ग्युमेंट्स

str <- "a,b,c\n1,2,x\n3,4,y"
fread(str, select = c("a", "c"))

# Same as
fread(str, drop = "b")
a c
1 x
3 y
str <- "1,2,x\n3,4,y"
fread(str, select = c(1, 3))

# Same as 
fread(str, drop = 2)
V1 V3
 1  x
 3  y
R में data.table के साथ Data Manipulation

अभ्यास करते हैं!

R में data.table के साथ Data Manipulation

Preparing Video For Download...