-2

I have (in R) a log of unique keys and time entries in a dataset, which I want to extract using a hash search by the corresponding keys (there is for example the session j2i312 and all associated with it timepoints, at which one has changed the page). When I make a hashmap, the keys are aggregated (there are no repeating ones), but I see only one time entry per bucket. Is there a way to see all entries and if yes, how? Would you suggest some other procedure in this case?

Many thanks in advance!

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
  • 2
    Please read [How to make a great reproducible example in R?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to ask a clear question in r. Also you may want to take the [tour](https://stackoverflow.com/tour) and read [how to ask?](https://stackoverflow.com/help/how-to-ask). – M-- Jul 28 '17 at 17:29
  • What do you want the output to look like? You could have a dataframe with one key on each row and a list column with all of the time entries for each key – Alex P Jul 28 '17 at 17:30
  • Welcome to Stack Overflow! Please do not vandalize your posts. Once you've posted a question, you have licensed the content to the Stack Overflow community at large (under the CC-by-SA license). If you would like to disassociate this post from your account, see [What is the proper route for a disassociation request?](http://meta.stackoverflow.com/questions/323395/what-is-the-proper-route-for-a-dissociation-request). – FelixSFD Jul 30 '17 at 09:01

1 Answers1

0
df <- data.frame(key=c(1,1,1,2,2,3,3,3,3), time=c(1,2,3,1,3,1,2,3,4))
df_nested <- dplr::group_by(df, key) %>% dplyr::summarise(times=list(time))

df_listed[1,]$times
# [1] 1 2 3
Alex P
  • 1,574
  • 13
  • 28
  • when you are ready, accept my answer to give me some reputation points. – Alex P Jul 28 '17 at 17:49
  • OK, so it works. Now, how do I access the contents of the tibble inside the nest? It says `data 1 ` – user8363722 Jul 28 '17 at 18:19
  • good question, clearly I should have thought at least that far ahead. It is definitely possible, but maybe we don't really need to `nest()`. It created a tbl, as you've discovered, and all we really need is a list, or maybe a vector would work. Anyway, I've revised my answer to provide a list-column, and I've provided an example on how to access the list. – Alex P Jul 28 '17 at 19:05
  • That's fine. I've already figured out all details around that! Thanks again! – user8363722 Jul 29 '17 at 19:19