This is a research associate’s blog about R and anything related to Data Science. The code for some of the analyses and some of my work can be found on my Github account.

I’m currently working at the University of Applied Sciences Bielefeld for the ReAD-StuD project which tries to identify and analyze factors that influence the quality of clinical trials. Previously, I was working at the University of Applied Sciences in Osnabrück, where I taught Introductory Statistics and authored the cutpointr R package.

What’s a Subsettable Closure?

Well, actually, there’s no such thing as a “subsettable closure”. It’s a reference to the notorious error object of type 'closure' is not subsettable that has probably confused every R user at least once.

Usually, the error occurs because the user has (or has tried to) given a data frame the name of an existing function, e.g. sort. Then, for some reason, the data frame was removed, never created, has a typo in its name or is out of scope and the user tries to subset it using [. Since the data frame called sort is not found but there’s a function of the same name, R will try to subset the function and throws the error.

Additionally – what’s a closure anyway? Advanced R tells us that

An object is data with functions. A closure is a function with data.

John D. Cook