12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

opinions, so the naming of functions in R is far from standardized.Structuring your codeNames aren’t the only things that can influence the readability of your code.When you start nesting functions or perform complex calculations, your code canturn into a big mess of text and symbols rather quickly. Luckily, you have sometricks to clear up your code so you can still decipher what you did three monthsdown the road.Nesting functions and doing complex calculations can lead to very long lines ofcode. If you want to make a vector with the names of your three most belovedsong titles, for example, you’re already in for trouble. Luckily, R lets you break aline of code over multiple lines in your script, so you don’t have to scroll to the rightthe whole time.You don’t even have to use a special notation or character. R will know thatthe line isn’t finished as long as you give it some hint. Generally speaking, you haveto make sure the command is undoubtedly incomplete. There are several ways todo that:You can use a quotation mark to start a string. R will take all the followinginput — including the line breaks — as part of the string, until it meets thematching second quotation mark.You can end the incomplete line with an operator (like +, /,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!