Formation tops to Petra, reshaped with R

To import formation tops to Petra, your input file needs to be set up as one row per well, one column per formation top, and each value being the depth measurement.  In the example below, I am trying to rough out the depths of formations in Wyoming using only the TD (total depth) and BOTFORM (formation at total depth).  Not the most precise method of building structural maps, but it will work on a large scale.

Input file has one row per well, columns api_full, TD, and BOTFORM (at least). 

Caution: I tried to run this on the full WY well dataset (111,000 rows) and R used all 36 GB of my RAM and then crashed.  It’s advisable to subset first.

#Read data in
#Simple sample
#Remember column names
names (ws);
#Required libraries
#Example: reshape the sample, because the whole dataset is over 100,000 rows.
#Melt according to API and formation at TD
#Cast into a new data frame
wsc<-cast(wsr, api_full ~ BOTFORM);
Output will be one row per well, one column for each formation name in BOTFORM, and TD as the value.
I can add more information if there are questions.  Reshape steps are from