Does R ignore variable name extensions starting at a point in the data frame?

I have a data frame in which some variable names include "." expansion. It seems that R will ignore this extension and give me a variable anyway if I try to access it without the full name of the variable. What causes it / why does it happen? Below is a mini example of my problem.

y <- rnorm(100)
x <- rlnorm(100)

data <- cbind.data.frame(y,x)

colnames(data) <- c("y.rnorm","x.rlnorm")

# these both return the same thing
data$y
data$y.rnorm
+4
source share
2 answers

R is tuned to provide results for partial design matches.

Read sections 3.4 and 4.3 of the R language definition.

3.4.1 . i x . [[ $ , , x$aa x$aabb, x "aa", "aabb" - "". [[ , NA, , , . TRUE , FALSE . , [ . "" : " ( , ). , , .

4.3.2 . , , . , . . , f <- function(fumble, fooey) fbody, f(f = 1, fo = 2) , fooey. f(f = 1, fooey = 2) , . "... .

Uwe, R, [[ . R News 3.1.0:

$ . , foo$bar foo[["bar", exact = FALSE]]

+7

$ . . Advanced R by Hadley Wickham, Ctrl + F " ":

$ [[. $ :

x <- list(abc = 1)

x$a

## [1] 1

x[["a"]]

## NULL

, warnPartialMatchDollar TRUE. : (, ).

+3

Source: https://habr.com/ru/post/1690100/


All Articles