You can use the data frame edit() function to manually enter / edit data in R.
Start by creating a data frame.
Note I am initializing each of the columns to datatype(0). This tells R that I while I want the name column to be a character and the age column to be numeric, I am leaving the size dynamic. You can set size limits during the initialization phase if you so choose.
dfe <- data.frame(name=character(0), age = numeric(0), jobTitle = character(0))
Now, let’s use the edit() function to add some data to our data frame
dfe<- edit(dfe)
When the new window pops up, fill in the data and simply click the X when you are done
You may get warning messages when you close out your edit window. These particular messages I got simply informed me that name and jobTitle were set as factors by R. Remember in R, warnings just want you to be aware of something, they are not errors.
Now if you run dfe, you can see your data frame
By running the edit() function again, you can edit the values that currently exist in the data frame. In this example I am going to change Philip’s age from 28 to 29
If you want to add a column to the data frame, just add data to the next empty column
You can just close out now and rename the column in R, or just click on the column header and you will be able to rename it there.
Now we have a new column listing pets
name age jobTitle pet 1 Ben 42 Data Sc cat 2 Philip 29 Data Ana dog 3 Julia 36 Manager frog
You can use the edit() function to manually edit existing data sets or data imported from other sources.
Below, I am editing the ChickWeight data set