Skip to content

Instantly share code, notes, and snippets.

@Ironholds
Created March 1, 2013 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Ironholds/5064758 to your computer and use it in GitHub Desktop.
Save Ironholds/5064758 to your computer and use it in GitHub Desktop.
entropy.df <- subset(
tickets.df[
1:nrow(
tickets.df
)
%in% which(
outer(
subset(
tickets.df,
period == "hadean"
)$user,
subset(
tickets.df,
period == "prehadean"
)$user,
"=="
),
arr.ind=TRUE
),
], period == "hadean"
)
#Ookay, this isn't working. It should be pulling out all tickets with period "hadean" with a userID matching a userID from the tickets with period "prehadean". It returns a null. I can /see/ userIDs present in both. The fuck?
@Protonk
Copy link

Protonk commented Mar 1, 2013

Why doesn't

hadean.ids <- tickets.df[tickets.df[, "period"] == "hadean", "user"]

entropy.df <- tickets.df[tickets.df[, "user"] %in% hadean.ids & tickets.df[, "period"] == "prehadean", "user"]

Work?

@Ironholds
Copy link
Author

That appears to pull out all matching userIDs rather than all rows with matching userIDs.

@Protonk
Copy link

Protonk commented Mar 1, 2013

That's just because the second line has a column selected.

entropy.df <- tickets.df[tickets.df[, "user"] %in% hadean.ids & tickets.df[, "period"] == "prehadean", ]

Will subset the df.

@Ironholds
Copy link
Author

Clever. Is 'I have a moral aversion to creating objectnames' a useful explanation to the implicit 'why is the gist written like lisp, you jerkhole' question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment