I need to read the ''wdbc.data' in the following data folder: http://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/
Doing this in R is easy using command read.csv but as the header is missing how can I add it? I have the information but don't know how to do this and I'd prefer do not edit the data file.
in case you are interested in reading some data from a
.txt
file and only extract few columns of that file into a new.txt
file with a customized header, the following code might be useful:Of course, you should modify this sample script based on your own application.
You can do the following:
Load the data:
Note that the default value of the
header
argument forread.csv
isTRUE
so in order to get all lines you need to set it toFALSE
.Add names to the different columns in the data.frame
or alternative and faster as I understand (not reloading the entire dataset):
You can also use
colnames
instead of names if you havedata.frame
ormatrix