0

There's a dot in a script that refers to something, but I can't figure out what on earth it is.

Here's the line that contains the dot I'm talking about:

filter_target <- . %>%
  inner_join(target_student_ids) %>%
  filter(
    school_year_id == SCHOOL_YEAR,
    date >= START_WINDOW,
    date <= END_WINDOW
  )

I found this other code block that references filter_target:

referrals <- tbl(db, "data_table") %>% 
  mutate(
    date = as.Date(timestamp_create)
  ) %>%
  filter(is_com) %>%
  filter_target() %>%
  group_by(a, b) %>%
  summarise(Refs = n())

Any idea what the dot is doing? What's it called? filter_target gets evaluated and stored as a function, which I'm not sure if that's the expected output.

simplycoding
  • 2,770
  • 9
  • 46
  • 91
  • Not clear without a reproducible example. The `.` would be the data, but here you are starting with `.`, so it is. not clear – akrun Mar 16 '20 at 18:26
  • 1
    It's the magrittr dot placeholder: https://stackoverflow.com/questions/36716710/combining-pipes-and-the-magrittr-dot-placeholder – Stefan Mar 16 '20 at 18:29
  • Found a reference to the variable/function elsewhere in the code and added it to the original post. Hope that helps clarify the quesiton – simplycoding Mar 16 '20 at 18:48
  • My mistake - I believe Stefan is correct. This is creating a function called `filter_target`, that takes a single argument (where the `.` goes). I think if you read Stefan's [answer here](https://stackoverflow.com/a/36762559/903061), that should help clear things up. – Gregor Thomas Mar 16 '20 at 18:50

0 Answers0