Was it helpful?

Question

How to create an empty data frame in R?

R ProgrammingServer Side ProgrammingProgramming

We can create an empty data frame as follows −

> df <- data.frame(Income=double(),
   Age=integer(),
   EducationLevel=factor(),
   MaritalStatus=logical(),
   StateLiving=character(),
   stringsAsFactors=FALSE)
> str(df)
'data.frame': 0 obs. of 5 variables:
$ Income : num
$ Age : int
$ EducationLevel: Factor w/ 0 levels:
$ MaritalStatus : logi
$ StateLiving : chr

We can edit this data frame by using −

> edit(df)

This edit command will open a spreadsheet and we can enter the data in the data frame.

raja
Published on 06-Jul-2020 16:23:15
Advertisements
Was it helpful?
Not affiliated with Tutorialspoint
scroll top