The commands referenced below are all part of special phylogenetic packages in R, not the basic R install. Be sure that you have installed and loaded the packages containing the commands referenced below before continuing. For example:
This loads the package ape and its required packages gee, nlme and lattice into your R session.
How do I input data corresponding to the tips of my phylogeny into R?
First, assemble your data into a tab delimited text file (this can be done, for example, in a simple text editor or as a "save as" option in MS Excel). By default, the rows of the datafile correspond to the taxa at the tips of your phylogeny. The first column should represent the names of your taxa exactly as they appear in your phylogeny (see previous section). The second and any subsequent columns of the datafile should correspond to the variables in your dataset. The first row of the datafile should contain the names of the variables in your dataset, noting that this row will have one fewer entry than the other rows. In other words, do not supply a title for the column containing the taxon names.
Once the text file is properly formatted, the read.table command will import it as an object in R. For example, this will create the data table "MyData" from the file "MyDatafile.txt".
MyData <- read.table ("MyDatafile.txt")
The procedure above should work on any white-space (space, tab or line-end) delimited text file. There are several other options for inputing data using read.table and its derivatives. For example, read.csv will read a comma-delimited text file. Use the following command for more information on the nuances of read.table.
To load the sample Geospiza tip data file that is used in several of the worked examples, save the linked file to your working directory, then execute this command.
geodata <- read.table ("geospiza.txt")