Code Completion for R scripts
The power editor supports completion of R code by relying on the CompletePlus function in the svMisc package. This function uses the completion engine that comes with R (formerly implemented in the rcompgen package and incorporated in utils in recent versions of R), and looks in documentation files for additional information related to each finding, for example when completing
"rnorm( ", the
CompletePlus function looks into the help page for rnorm and retrieves the description of each of the arguments :
R> require( svMisc )
Loading required package: svMisc
R> CompletePlus( "rnorm(" )
[1,] "n = " "rnorm"
[2,] "mean = " "rnorm"
[3,] "sd = " "rnorm"
[1,] "number of observations. If 'length(n) > 1', the length is taken to be the number required."
[2,] "vector of means."
[3,] "vector of standard deviations."
The power editor plugin uses this information to display completion popups:
Completion of Colors
In special cases, instead of argument or function names, the engine will complete for colours using the current R palette :
or names of colors if you started to type a quote character
here the user started to type
gre so the completion engine looks for colors having a name that matches the pattern gre. This is basically obtained as follows:
> head( grep( "gre", colors(), value = T ) )
 "darkgreen" "darkgrey" "darkolivegreen" "darkolivegreen1"
 "darkolivegreen2" "darkolivegreen3"
Line Type completion
lty argument is associated with a line type, the completion engine suggests the basic line types as documented in ?par
Plot Character Completion
Same with the pch argument and the plotting character.