When I look at the contents of [[.data.frame
on my PC, this is what I get:
> get("[[.data.frame")
function (x, ..., exact = TRUE)
{
na <- nargs() - (!missing(exact))
if (!all(names(sys.call()) %in% c("", "exact")))
warning("named arguments other than 'exact' are discouraged")
if (na < 3L)
(function(x, i, exact) if (is.matrix(i))
as.matrix(x)[[i]]
else .subset2(x, i, exact = exact))(x, ..., exact = exact)
else {
col <- .subset2(x, ..2, exact = exact)
i <- if (is.character(..1))
pmatch(..1, row.names(x), duplicates.ok = TRUE)
else ..1
.subset2(col, i, exact = exact)
}
}
<environment: namespace:base>
I've gotten used to ...
, but this is the first time I saw ..1
and ..2
. A quick search both in R help and Google returned mostly rubbish, since the dots are often interpreted as placeholders, so I'm hoping someone here can give me a pointer? Or am I missing something dreadfully obvious? Where do these come from and how can I use them?
A DataFrame is a data structure that organizes data into a 2-dimensional table of rows and columns, much like a spreadsheet. DataFrames are one of the most common data structures used in modern data analytics because they are a flexible and intuitive way of storing and working with data.
Explanation: A frame is an artificial intelligence data structure used to divide knowledge into substructures by representing “stereotyped situations.”.
The long answer is the size limit for pandas DataFrames is 100 gigabytes (GB) of memory instead of a set number of cells. In effect, this benchmark is so large that it would take an extraordinarily large data set to reach it.
You can use the following basic syntax to find the rows of a data frame in R in which a certain value appears in any of the columns: library(dplyr) df %>% filter_all(any_vars(. %in% c('value1', 'value2', ...)))
This is a way to reference the 1st, 2nd, ... elements of the special pairlist that is ...
. So ..1
is the way to refer to the first element of ...
, ..2
refers to the second element of ...
and so on.
This is mentioned in the R Internals manual in section 1.5.2 Dot-dot-dot arguments, the relevant bit of which is:
The value of
...
is a (special) pairlist whose elements are referred to by the special symbols..1
,..2
, ... which have theDDVAL
bit set: when one of these is encountered it is looked up (viaddfindVar
) in the value of the...
symbol in the evaluation frame.
To add to Gavin's answer:
They are also mentioned briefly in the help page for reserved words (?Reserved
).
A really simple example of usage is
f <- function(...) print(..1)
f(x = 99) #prints 99
f() #throws an error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With