Skip to content

syntax for extending a line in a script??

4 messages · Brian Diggs, David Winsemius, Mike Williamson

#
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).

  
    
#
On Jan 12, 2011, at 5:46 PM, Mike Williamson wrote:

            
My practice is to use the opening of a paired code delimiter like "["  
or "(" at the end of a line as I have modified your code to show:
David Winsemius, MD
West Hartford, CT