search for: colok

Displaying 1 result from an estimated 1 matches for "colok".

Did you mean: colon
2011 Nov 03
1
Select columns of a data.frame by name OR index in a function
...itional argument describing come columns. For greater flexibility I want to allow for either column names or column indices. What I usually do then is something like the following: -------------8<------------- f <- function(datf, cols) { nc <- seq_along(datf) cn <- colnames(datf) colOK <- (cols %in% nc) | (cols %in% cn) if (!all(colOK)) { badc <- paste(sQuote(cols[!colOK]), collapse = ", ") msg <- sprintf(ngettext(sum(!colOK), "%s is not a valid column selector", "%s are not valid...