I have recently started using R and am still getting used to its data types etc. I am fetching data from a database, performing calculations on the data, and then storing some results back to the database.
The calculated data is to be stored in a specific table in the database. I want to create a data frame with columns matching that of the db table (i.e. same name and data type [near as]). In order to do that, I need to be able to do the following:
-
Programmatically create a data frame with specified ‘columns’
I know I can create this with data.frame() but its not clear how to create a data frame with only column headings, but no data (rows) yet. -
Programmatically add rows to the empty data frame created in step 1 above
Here it is in action: