What is a nested name specifier?

::S is a qualified-id. In the qualified-id ::S::f, S:: is a nested-name-specifier. In informal terms1, a nested-name-specifier is the part of the id that begins either at the very beginning of a qualified-id or after the initial scope resolution operator (::) if one appears at the very beginning of the id and ends with the … Read more

Is there a way to get a vector with the name of all functions that one could use in R?

I’d use lsf.str() as a start. eg : x <- as.character(lsf.str(“package:base”)) gives you a list of all functions in the base package. You could do add all packages you want to check against. stats and utils come to mind first. EDIT : Regarding your question about currently loaded packages : x <- unlist(sapply(search()[-1],function(x)as.character(lsf.str(x)))) see comments … Read more

Why the “mutable default argument fix” syntax is so ugly, asks python newbie

This is called the ‘mutable defaults trap’. See: http://www.ferg.org/projects/python_gotchas.html#contents_item_6 Basically, a_list is initialized when the program is first interpreted, not each time you call the function (as you might expect from other languages). So you’re not getting a new list each time you call the function, but you’re reusing the same one. I guess the … Read more

How to pass dynamic column names in dplyr into custom function?

Using the latest version of dplyr (>=0.7), you can use the rlang !! (bang-bang) operator. library(tidyverse) from <- “Stand1971” to <- “Stand1987” data %>% mutate(diff=(!!as.name(from))-(!!as.name(to))) You just need to convert the strings to names with as.name and then insert them into the expression. Unfortunately I seem to have to use a few more parenthesis than … Read more

What are all of the allowable characters for people’s names? [closed]

There’s good article by the W3C called Personal names around the world that explains the problems (and possible solutions) pretty well (it was originally a two-part blog post by Richard Ishida: part 1 and part 2) Personally I’d say: support every printable Unicode-Character and to be safe provide just a single field “name” that contains … Read more

Concatenating Variable Names in C?

When you find yourself adding an integer suffix to variable names, think I should have used an array. struct mystruct { int class[6]; }; int main(void) { struct mystruct s; int i; for (i = 0; i < 6; ++i) { s.class[i] = 1000 + i; } return 0; } Note: A C++ compiler will … Read more