1
Does anyone know what a slot extraction
? I’m trying to follow a script and a part of it is:
data <- data.frame
names(data)
unique <- unique(data@data$binomial)
binomial is the column I need to use in the case that they are species names. A species in this case may have more than one row in the data.frame
, therefore the application of the function unique
. But I don’t understand the function of @. I saw that it is related to an Extraction slot, but I didn’t understand what it means in practice.
data.frame
is the function that creates, good, data frames. So the first line of that code is creating another function the same but with a different name. The second instruction,names(data)
must giveNULL
.– Rui Barradas
And then the third instruction makes no sense. As for the operator
@
is actually related to an Extraction slot, that is, it is used in object-oriented programming. In R there is the S3 system (most used) and the S4 system, in the packagemethods
, where this operator is used to extract components (slots) from objects. See Advanced R by Hadley Wickham.– Rui Barradas
I expressed myself badly using data.frame in the first line, I meant that in my script the object "data" is a data.frame, I put so to contextualize
– Myrla Rocha
Okay, so you can post the output of
dput(data)
or, if the df is too large,dput(head(data, 20))
question? So we get an exact copy of the data structure and we can see what is happening.– Rui Barradas