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.

languages, the backslash character has a special meaning. The backslash indicatesan escape sequence, indicating that the character following the backslash meanssomething special. For example, \t indicates a tab, rather than the letter t. (Youcan read more about escape sequences in Chapter 12.) Rest assured that, althoughthe working directory is displayed differently from what you’re used to, R is smartenough to translate it when you save or load files. Conversely, when you type a filepath, you have to use slashes, not backslashes.2. Type the following code in your console, using a filename likeyourname.rda, and then press Enter.> save(yourname, file=”yourname.rda”)R silently saves the file in the working directory. If the operation is successful,you don’t get any confirmation message.3. To make sure that the operation was successful, use your filebrowser to navigate to the working directory, and see whether the newfile is there.Retrieving your workTo retrieve saved data, you use the load() function. Say you want to retrievethe value of yourname that you saved previously.First, remove the variable yourname, so you can see the effect of the loadprocess:> rm(yourname)If you’re using RStudio, you may notice that yourname is no longer displayed inthe Workspace.Next, use load to retrieve your variable. Type load followed by the filenameyou used to save the value earlier:> load(“yourname.rda”)Notice that yourname reappears in the Workspace window of RStudio.

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

Saved successfully!

Ooh no, something went wrong!