letter[2]equivalent '['(letters,i=2), second argument i.
letter[2]
'['(letters,i=2)
i
What is the name of the first argument, so the next two expressions will be equivalent?
lapply(1:3,function(x){letters[x]}) lapply(1:3,`[`,param1 = letters) # param1 to be replaced with solution
You should be more specific than "[", for example:
"["
lapply(1:3, `[.numeric_version`, x = letters) # [[1]] # [1] "a" # # [[2]] # [1] "b" # # [[3]] # [1] "c"
(Not sure which [.numeric_versionis the most suitable, though ... I dig a little more)
[.numeric_version
, , . [ . Map lapply, , , Indices, , :
[
Map
lapply
Map("[",list(letters),1:3) [[1]] [1] "a" [[2]] [1] "b" [[3]] [1] "c"
, . ,
rlang::as_closureand purrr::as_mapper, as based on rlang::as_function(see doc) both convert [to a function with named parameters:
rlang::as_closure
purrr::as_mapper
rlang::as_function
lapply(1:3, purrr::as_mapper(`[`), .x = letters) lapply(1:3, rlang::as_closure(`[`), .x = letters) # [[1]] # [1] "a" # # [[2]] # [1] "b" # # [[3]] # [1] "c"
Source: https://habr.com/ru/post/1685126/More articles:SQL Left Join does not return all results - sqlhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1685122/firehose-to-s3-what-happens-to-data-after-unsuccessful-tries-for-24-hours&usg=ALkJrhj3unse14wDeqmUq0_3esmgN4ZIBAAvoiding extra space allocation when using standard collections and storing millions of items - performanceКод Entity Framework - сначала существующая база данных с использованием командной строки - c#ClearableEdittext for xamarin android - androidcheck managed maven dependencies - javaThe fastest way to check if a string is a substring in a string list is python-3.xhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1685129/varargs-a-vs-seqa-parameters-to-function&usg=ALkJrhiAhNlYlBBNgIUxU0y6WmLWlMYtQQVS 2017 "Failed to load this custom viewer" - debuggingHow to check handlers in withHandlers, branch and withState for re-linking with an enzyme? - reactjsAll Articles