With my data collection stopped, I’ve been spending time working on my data processing code again. I spent the better part of two hours trying to add a column onto a data frame in R only to find a single-line solution that’s way too obvious. Such is the way of programming though.

The effort is… slow. I was able to hammer out the general sorting and consolidation in fairly short order, but what I’m working on now is more effort. The net result should be a list of all posted goods over the entire time period with no duplication. This should allow me to measure the elasticity over the entire period instead of daily.

A convenient side effect is that I can segregate the postings that disappear, presumed sold, and see if I can get an idea of what demand is that way. It’s a little backward but makes about as much sense as collecting sales data directly.

By and large, the biggest issue is just finding ways to make the data structures in R do what I want. When I stopped for the day I had separate lists of unsold goods and new listings, but the sold listings were missing. Partial sales for a single seller would also not work properly, I suspect.

I think I have a pretty good idea though. If I loop through the main list checking against the unsold and new listing, the sellers I can’t find can be stored in a list then retrieved. Should look something like this:

For (theThings in t1$Seller) {

duplicate = FALSE

For (unsoldThings in unsold$Seller) {

If (theThings == unsoldThings) {duplicate = TRUE}

For (newThings in newListings$Seller) {

If (theThings == newThings) {duplicate = TRUE}

If (!duplicate) {sold = rbind(sold, theThings)}


Once I’ve done that I can use data pipes to pull the values I’m looking for.

For (theThings in sold) {

finalSold = rbind(finalSold, t1 %>% filter(Seller=theThings))


Or something like that. No plan survives contact with the enemy. Or the data. I’m sure I’ll find some strange situation that manages to break this, assuming it even works to begin with. I’ve recorded it here mainly because I’ve spent the last few hours working out the general idea and I’d much rather not find myself saying “now, I had an idea on how to do this, what was it again?”

Y’all take care. Feel free to acquire anything of value.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s