How to load and save a dataset with R:
To load a dataset you can use the function read.table
myData <- read.table(file='/pathToMyFile/myDataset.txt', sep=';')We used 2 parameters in this example, file is the path to the dataset to be load and sep is the character used to separate the fields in the dataset.
To save our dataset we can use the function write.table
write.table(x=myData, file='myData.txt', sep=';', row.names=FALSE, col.names=FALSE)This time we used 5 parameters, the first one is x, it indicates the R object we want to save. Secondly, file is the name we want to give to the file and then sep is the character that will be used to separate each field. Finally, row.names and col.names let us chose if we want to include the row names or the headers (col.names) in the saved file.
No comments:
Post a Comment