Skip to content
Prev 247178 / 398503 Next

syntax for extending a line in a script??

On 1/12/2011 2:46 PM, Mike Williamson wrote:
You can put the right hand side of the assignment in parentheses. Then 
even with the same breaks, the first line is not complete, so R will 
continue parsing.  An emacs still indents reasonably. (I added a second 
line break to try and avoid email wrapping affecting things).

numericColumns <- (names(listOfDataFrames[[myDF]][,columnsOI])
                    [sapply(listOfDataFrames[[myDF]][,columnsOI],
                            is.numeric)])
Putting the right hand side in curly braces might work too.  That would 
turn it into a code block, which should evaluate to whatever the last 
statement in the code block is (which in this case is the only 
statement).  I wouldn't be surprised if there is some case where curly 
braces might lead to a different result; parentheses shouldn't (but I 
may be wrong).