Does a long variable name have slow performance in r?

For example, the next two will run at different speeds if they were in a function that runs millions of tests.

the.name.of.a.random.variable.in.r <- some.value

variable <- some.value

It then expands on this, as it relates to function names.

+4
source share
2 answers

My simple benchmarking experiment indicates that it does not matter:

the.name.of.a.random.variable.in.r <- 1:1000
the.name.of.a.random.variable.in.r.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <- 1:1000

variable <- 1:1000

microbenchmark::microbenchmark(long=sum(the.name.of.a.random.variable.in.r), 
                               short=sum(variable), 
                               verylong=sum(the.name.of.a.random.variable.in.r.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa))

# Unit: nanoseconds
# expr     min  lq    mean median     uq   max neval cld
# long     970 987 1147.48 1036.5 1057.5 10468   100   a
# short    969 985 1038.82 1030.5 1053.5  1841   100   a
# verylong 968 988 1070.16 1036.0 1062.5  3961   100   a
+4
source

R . , " ", (. R ). , , , , ( ) . , R , , .

R , , , , , , , .

+4

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


All Articles