names
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
Access and preserve list names in lapply function
I believe that lapply by default keeps the names attribute of whatever you are iterating over. When you store the names of myList in n, that vector no longer has any “names”. So if you add that back in via, names(n) <- names(myList) and the use lapply as before, you should get the desired result. … Read more
Is there away to generate Variables’ names dynamically in Java?
If you really want to do something like that, you can do it through bytecode generation using ASM or some other library. Here is code that will generate a class named “foo.bar.ClassWithFields” that contains fields “var0” to “var99”. Of course there is no way other than reflection to access those fields, because they don’t exist … Read more
Specifying column names in a data.frame changes spaces to “.”
You may set check.names = FALSE in data.frame (as well as in read.table): df <- data.frame(“Label 1” = 1:3, “Label 2” = rnorm(3), check.names = FALSE) returns: Label 1 Label 2 1 1 0.2013347 2 2 1.8823111 3 3 -0.5233811 From ?data.frame: check.names logical. If TRUE then the names of the variables in the data … 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