List autocomplete in RStudio

Given the following list, do I need to choose between clean code or autocomplete, or can I have both? I am using the latest version of RStudio for MacOS 10.10.5.

> l <- list() > l$`__a` <- data.frame(`__ID` = stringi::stri_rand_strings(10, 1), col = stringi::stri_rand_strings(10, 1), check.names = F ) > l$`__b` <- data.frame(`__ID` = stringi::stri_rand_strings(10, 1), col = stringi::stri_rand_strings(10, 1), check.names = F ) > l$`__c` <- data.frame(`__ID` = stringi::stri_rand_strings(10, 1), col = stringi::stri_rand_strings(10, 1), check.names = F ) 

Autocomplete, but with reverse line characters (less clean and difficult to programmatically manipulate):

 > l$`__a` __ID col 1 iu 2 4 V 3 b Y 4 j B 5 kd 6 ZQ 7 TH 8 f A 9 j Y 10 k P 

With operator and lines [ (cleaner and more programmatically simple, but without autocomplete):

 > l[["__a"]] __ID col 1 iu 2 4 V 3 b Y 4 j B 5 kd 6 ZQ 7 TH 8 f A 9 j Y 10 k P 

Or is there a third possibility, for example, to write all the code with callback symbols first, and then find a way to automatically replace them with [[ and ]] ?

0
source share
1 answer

Fortunately, it is possible to have both autocomplete and beautifully formatted code. In RStudio, autocomplete works for both $ and [[ , but it works a bit differently.

For indexing with $ the autocomplete list starts immediately after entering $ .

However, for [[ you must press tab before the autocomplete list is displayed. And it works on several levels in the same way as with $ .

The note above from @docendo discimus was helpful in finding this answer.

+1
source

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


All Articles