mardi 5 novembre 2019

How to create a random sample from .csv in r

I need to pull a random sample of 100,000 - 200,000 rows from a csv dataset of 2.8mil rows. How do I effectively do this so that the random sample can be cleaned and processed?

Under the DMwR2 library, I have used the sampleCSV function, but the output data messes up the 22 variables that I need to use.

library(caret)

library(DMwR2)

dataset source: https://www.kaggle.com/pschale/mlb-pitch-data-20152018#pitches.csv

pitchData <- sampleCSV(file.choose(), 200000, 2867154 , header = TRUE , mxPerc = 0.5)

summary(pitchData)

I expect the output of summary(pitchData) to have the same variable names as the csv file, but it renames them using random numbers, and some of the variables are lost.




Aucun commentaire:

Enregistrer un commentaire