saveData: Convenience function for saving data.

Description Usage Arguments See Also Examples

Description

The function saves the desired data in the "./input/*" directory. The name of data file will adhere the following naming convention: prefix and a suffix seperated by an underscore. Use dashes to seperate terms in the prefix and suffix. For example, "train-stage1_tfidf-sublinear.csv".

Usage

1
2
3
saveData(dt, prefix, suffix = NULL, folder = NULL, subfolder = NULL,
  file_ext = "csv", overwrite = TRUE, verbose = TRUE,
  data_path = "./input", writer = fwrite, ...)

Arguments

prefix

Either the full name of the file to save (e.g., "train_features.csv" or the prefix of the file to save. If the full name is used then the suffix parameter should be NULL and the file extension should be included.

suffix

Suffix of the data file to save This parameter could be useful when interating through features; e.g., in a for loop. (default is NULL)

folder

Folder within "./input/" to save the file in. (default is NULL)

subfolder

Subfolder with in folder to save the file in. (default is NULL)

file_ext

Determines the file extension of the file to save saveData() calls the appropriate function to save the data. Accepted values are "csv", "rds", "rda", "xgb". If file_ext = "xgb" then the file to save is expected to be an xgb model. (default is "csv")

overwrite

Whether or not an existing file with the same name should be overwritten. If overwrite=NA then the user is asked whether the file should be overwritten. (default is TRUE)

verbose

Whether or not to print details about the file being saved (default is TRUE)

writer

Function to write the data to disk. (default is NULL, the writer function is inferred from file_ext)

...

Additional parameters to pass the save function.

See Also

loadData The complimentary function to saveData.

Examples

1
2
3
4
5
6
7
8
# save "./input/clusters/skmeans/train_features.csv"
saveData("train_features", folder="clusters", subfolder="skmeans")

# save "./input/train_features.csv"
saveData("train", suffix="features")

# save "./input/train_features.rds"
saveData("train", suffix="features", file_ext="rds")

mattmotoki/kaggleUtils documentation built on May 8, 2019, 11:57 p.m.