I'm trying to understand this peice of code in R:
thing <- low_temp %>% filter(room_type == "bedroom" & score == "6") %>% .[, "n"] %>% sum()
the meaning of the code .[, "n"]
is not clear, and since it is completely written in shorthand, it is impossible to search for it in Google.
Obviously [, x]
is just base R. But the use of the dot bracket notation is not something I've seen anywhere in my admittedly limited foray into R through udemy and hadley & wickem's book. And I'm guessing that the use of "n" is also not consistent with recent R coding standards. The data frame in question comtains a column n.
My take on it is that R has been around for a long time, and like most open languages has undergone a lot of expansion without strict enough editing, which results in a huge amount of grammatical redundancy. That being the case, I feel very strongly that notation like the one here that stumped me should be systematically phased out of usage as they are unclear; impossible to search and difficult to read.
All that said, my question is quite simply, what does the dot bracket mean in the %>% .[, "N"]
. And secondly, what is the reason for the use of double commas around n?