12.07.2015 Views

R dummies

R dummies

R dummies

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

extensions that much. But using .Rhistory as a file extension will make it easier torecognize as a history file.If you want to load a history file you saved earlier, you can use theloadhistory() function. This will replace the history with the one saved in the.Rhistory file in the current working directory. If you want to load the history froma specific file, you use the file argument again, like this:> loadhistory(“Chapter3.Rhistory”)Keeping Your Code ReadableYou may wonder why you should bother about reading code. You wrote thecode yourself, so you should know what it does, right? You do now, but will you beable to remember what you did if you have to redo that analysis six months fromnow on new data? Besides, you may have to share your scripts with other people,and what seems obvious to you may be far less obvious for them.Some of the rules you’re about to see aren’t that strict. In fact, you can getaway with almost anything in R, but that doesn’t mean it’s a good idea. In thissection, we explain why you should avoid some constructs even though they aren’tstrictly wrong.Following naming conventionsR is very liberal when it comes to names for objects and functions. Thisfreedom is a great blessing and a great burden at the same time. Nobody isobliged to follow strict rules, so everybody who programs something in R canbasically do as he or she pleases.Choosing a correct nameAlthough almost anything is allowed when giving names to objects, there arestill a few rules in R that you can’t ignore:Names must start with a letter or a dot. If you start a name with a dot, thesecond character can’t be a digit.

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

Saved successfully!

Ooh no, something went wrong!