search for: misspelledstrings

Displaying 3 results from an estimated 3 matches for "misspelledstrings".

2019 Aug 26
2
Conventions: Use of globals and main functions
...s. E.g., collectStrings <- function(list) { strings <- character() # to be populated by .collect .collect <- function(x) { if (is.list(x)) { lapply(x, .collect) } else if (is.character(x)) { strings <<- c(strings, x) } misspelledStrings <<- c(strings, names(x)) # oops, would like to be told about this error NULL } .collect(list) strings } This gives the incorrect: > collectStrings(list(i="One", ii=list(a=1, b="Two"))) [1] "One" "Two" > misspelledStrings [1] &...
2019 Aug 26
0
Conventions: Use of globals and main functions
...> ? ? strings <- character() # to be populated by .collect > ? ? .collect <- function(x) { > ? ? ? ? if (is.list(x)) { > ? ? ? ? ? ? lapply(x, .collect) > ? ? ? ? } else if (is.character(x)) { > ? ? ? ? ? ? strings <<- c(strings, x) > ? ? ? ? } > ? ? ? ? misspelledStrings <<- c(strings, names(x)) # oops, would like > to be told about this error > ? ? ? ? NULL > ? ? } > ? ? .collect(list) > ? ? strings > } > > This gives the incorrect: > > collectStrings(list(i="One", ii=list(a=1, b="Two"))) > [1] &quo...
2019 Aug 25
2
Conventions: Use of globals and main functions
This is a fair point; structuring functions into packages is probably ultimately the gold standard for code organization in R. However, lexical scoping in R is really not much different than in other languages, such as Python, in which use of main functions and defining other named functions outside of main are encouraged. For example, in Scheme, from which R derives its scoping rules, the