I\'m trying to initialize a data.frame without any rows. Basically, I want to specify the data types for each column and name them, but not have any rows created as a result
You could use read.table
with an empty string for the input text
as follows:
colClasses = c("Date", "character", "character")
col.names = c("Date", "File", "User")
df <- read.table(text = "",
colClasses = colClasses,
col.names = col.names)
Alternatively specifying the col.names
as a string:
df <- read.csv(text="Date,File,User", colClasses = colClasses)
Thanks to Richard Scriven for the improvement