Documentation:Importing data in RStat on a mac computer from text and CSV files

From UBC Wiki

It can sometimes be useful to read Data in from another file using R. There are a few different ways this can be accomplished using both Rstat and Rstudio. The file types dicussed in this article are CSV and txt files.

To import data out of a file use the following command. >mydata= read.table("/mydata.xlsx", header=TRUE)
read.table's first argument takes the path to the file. It's second argument will tell R whether the first row listed is a header

If you plan to extract multiple files from the same working directory, it may be beneficial to set the location of those files as your working directory(eg. /users/documents as the working directory for a file and path /user/username/myfile.txt)

To do this, use the following code
>setwd("/Users/username/My Documents/x/y/z")
Note: R will not be able to read files located outside your working directory.

Alternatively, you can set your working directory by clicking the misc. tab in the top menu, select change working directory, and selecting the directory you wish to change to. and example of the ways to change your directory are shown below.


RStat user interface


To check data that has already been parsed into R type the name of the variable that you saved the data to (eg. type mydata to view the data) or if you want to view a single column of the data, type the variable name, followed by [#], where # is the number of the column you wish to view.

You may also be interested in these links

Documentation:Importing data in RStat on a windows computer from CSV and text files
Documentation:Importing data in RStudio on a windows computer from excel files ‎
Documentation:Importing data in RStudio on a mac computer from text and CSV files
Documentation:Importing data in RStat on a mac computer from excel files‎
Documentation:Importing data in RStudio on a mac computer from excel files
Documentation:Importing data in RStat on a windows computer from excel files ‎
Documentation:Importing data in RStudio on a windows computer from CSV and text files