Dr. Mark Gardener
Dr. Christine Gardener

GO...
Gardeners Own Home
Education Home
Other Publications
About Us

Statistics for Ecologists using R and Excel

Data Collection, Exploration, Analysis and Presentation

Available from Pelagic Publishing. Get a 20% discount using the S4E20 code!

Find supplementary material on this page - Data examples used in the book.

For an outline/overview of the book see here.

Note that there is a new edition of this book -- these notes relate only to the original. See the Publications home page for more details.


PPLogo

Get a 20% discount on "Statistics for Ecologists" when you buy direct from the publisher! Enter the voucher code S4E20 in the shopping basket at Pelagic Publishing.

List of example data files. Click to view or right click to download:

Pivot.txt
Beetle size.txt
Beetle comparison.txt
Leaf sizes.txt
Ridge Furrow.txt
Paired data.txt
Correlation.txt
Pearson.txt
Polynomial.txt
Logarithmic.txt
Chi Sq.txt
Goodness of Fit.txt
Three sites.txt
Twoway anova xl.txt
Twoway anova br.txt
Hoglouse Three sites.txt
Regression.txt
Post pivot.txt
Pie chart.txt
Mayfly regression.txt
Beach hoppers.txt
fly data.txt

Back to top

Statistics for Ecologists: Data examples

Throughout the book we use examples of data to illustrate various ideas, concepts and statistical analyses. This web page contains examples taken from the book that you may download and use to practice with. The data are all plain text and set out in Tab delimited format. This means that they may be viewed in a range of computer programs. You can view the data from your web browser and the files may also be opened in a word processor or notepad as well as a spreadsheet like Excel. In addition you can import the data into the R. I hope that you will be able to use these examples to help your understanding of the ideas in the book and to consolidate your learning of the various processes illustrated.


All the files are plain text and will display in your browser or may be downloaded and opened using Excel, notepad or R. Each file contains a few lines of comment at the top; these comments give a brief introduction as well as containing notes on getting the data into the R program. Slightly more detailed notes on each file are on this page (jump direct to instruction list).


In general to get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #; you may ignore them or delete the rows.


To get the data into R you require either the scan() command or the read.table() command, according to which data file you are looking at. The comment rows at the top of each file give appropriate instructions. In the book we generally use the read.csv() command; this is a special form of the read.table() command with various defaults. CSV files do not display clearly in web browsers so the decision was made to use Tab delimited files.


The following text gives brief notes about each file in turn. The file name is a hyperlink and clicking on this will open the data in your browser. To download the file right click and select “Save file as…” or similar (this varies according to browser).

Click on an example name below to go directly to the instructions for that example:

Pivot.txt | Beetle size.txt | Beetle comparison.txt | Leaf sizes.txt | Ridge Furrow.txt | Paired data.txt
Correlation.txt | Pearson.txt | Polynomial.txt | Logarithmic.txt | Chi Sq.txt | Goodness of Fit.txt
Three sites.txt | Twoway anova xl.txt | Twoway anova br.txt | Hoglouse Three sites.txt | Regression.txt
Post pivot.txt | Pie chart.txt | Mayfly regression.txt | Beach hoppers.txt | fly data.txt


Example file for practice: Pivot.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Pivot table example

File

Pivot.txt

Structure

The file contains 3 columns; count, habitat and obs. These relate to the number of butterfly species, habitat type and observation number (each habitat was visited several times).

Uses

We will use these data to make a simple pivot table in a spreadsheet. We want to end up with a table with a column for each habitat. Once the data are assembled into 3 separate samples you could try creating summary statistics for each sample and creating appropriate graphs. We will not carry out a pivot table operation using R (although there is a similar function) but we may wish to use the data for other purposes (e.g. Kruskal-Wallis test).

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Pivot.data = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Pivot.data” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Beetle size.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Beetle sizes

File

Beetle size.txt

Structure

The data consists of 5 columns of figures; they are split like this simply to make them more compact. The values are the size of a water beetle in millimetres.

Uses

Summary statistics: We use these data to look at ways to summarize samples using averages for instance. These data can be used to make a distribution graph e.g. a histogram.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Beetle = scan(file.choose(), sep = “\t”, comment = “#”)

You can replace the “Beetle” part with a name of your own choosing (in the book they are called bd). The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored. If the data are read in correctly you should see them as a single sample of data.


Example file for practice: Beetle comparison.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Comparison of two samples of beetle sizes

File

Beetle comparison.txt

Structure

There are two columns in the data file, one for Jun and one for Mar. The values are the size of the beetles in millimetres.

Uses

The main use for these data is to illustrate differences in data distribution. You may create a histogram or stem-leaf plot for each sample for example. There are many other things that may be done with these data, for example, summary statistics, comparison of two samples, graphs.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get the data into R we have a couple of choices; we may open the file in Excel and copy each column to the clipboard to create a data object for each month or we can copy the file in its current form. In the first case we use something like the following:

Jun = scan()

Then paste the copied column; in this case the Jun sample. We then repeat the process but using a new name and the other (Mar) column. We end up with two separate data items in R. Alternatively we can read the data as one item like so:

Beetles = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Beetles” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored. We now have a single data object that contains both samples.


Example file for practice: Leaf sizes.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Leaf sizes and running averages

File

Leaf sizes.txt

Structure

The data comprises of 10 columns of data; each column is a sample of 10 leaf sizes.

Uses

We used these data to illustrate standard error. We can summarize each sample and create a running average (mean or median). We might also examine the distribution of each sample and the entire 100 values in the set. If we read the data into R they will appear as a single sample (of 100 values); see if you can work out how to create a data object containing 10 separate samples.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Leaf = scan(file.choose(), sep = “\t”, comment = “#”)

You can replace the “Leaf” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Ridge Furrow.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Test for significant difference

File

Ridge Furrow.txt

Structure

The data comprises of two columns, one for the ridge sample and one for the furrow. The values represent the number of plant species found in quadrats in the two kinds of habitat.

Uses

The main use of these data is to illustrate the t-test; a parametric test of differences between two samples. However, the data may also be used to look at summary statistics, distribution and graphing.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Ridge.Furrow = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Ridge.Furrow” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Paired data.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Matched pair data

File

Paired data.txt

Structure

These data are in two columns. One column for captures on white coloured targets and the other for yellow targets. The data are paired with each row being a single bi-coloured target.

Uses

The principle use for these data is to illustrate use of matched pair data for examining differences. We may use the t-test of the Wilcoxon test. We can use these data for other purposes too, graphing for example.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Whitefly = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Whitefly” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Correlation.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Simple correlation

File

Correlation.txt

Structure

These data comprise of 2 columns, one represents water speed and the other the abundance of mayfly at the location the corresponding speed was measured.

Uses

The main use is to illustrate simple correlation between two variables. We could also use the data to create a graph.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Mayfly = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Mayfly” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Pearson.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Pearson correlation example

File

Pearson.txt

Structure

These data comprise of 2 columns, one represents water speed and the other the abundance of a freshwater invertebrate at the location the corresponding speed was measured.

Uses

The main use is to illustrate simple correlation between two variables. We could also use the data to create a graph.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Fwater = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Fwater” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Polynomial.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Polynomial regression

File

Polynomial.txt

Structure

Here we have two columns, one relates to light intensity and the other to abundance of a plant, bluebell.

Uses

We use these data to illustrate curvilinear relationships. Here we have a polynomial example. We can also draw a graph of the relationship.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Bbel = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Bbel” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Logarithmic.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Logarithmic regression

File

Logarithmic.txt

Structure

Here we have two columns, one relates to soil nutrient concentration and the other to growth of plants at each concentration.

Uses

We use these data to illustrate curvilinear relationships. Here we have a logarithmic example. We can also draw a graph of the relationship.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Nitrate = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Nitrate” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Chi Sq.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Association test example

File

Chi Sq.txt

Structure

These data comprise of 3 columns of insect taxa and 4 rows of habitats. We have a contingency table of observations and the table has row and column headings.

Uses

The main use for these data is to illustrate the chi squared test for association. We can also use the data to create graphs, e.g. pie charts.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Inverts = read.table(file.choose(), sep = “\t”, comment = “#”, row.names = 1, header = TRUE)

You can replace the “Inverts” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored. In this case we require the first column (the habitat names) to be treated as row names so we use the row.names = 1 part.


Example file for practice: Goodness of Fit.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Goodness of Fit example

File

Goodness of Fit.txt

Structure

These data comprise 2 columns and 4 rows of values along with extra rows for heading names and row names.

Uses

The main use for these data is to illustrate goodness of fit testing.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Peas = read.table(file.choose(), sep = “\t”, comment = “#”, row.names = 1, header = TRUE)

You can replace the “Peas” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored. In this case we require the first column (the habitat names) to be treated as row names so we use the row.names = 1 part.


Example file for practice: Three sites.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Sward height at three sites

File

Three sites.txt

Structure

The data comprise of 3 columns, each is a sample of sward heights from a site.

Uses

We use these data to look at differences between more than two samples. We may use analysis of variance or a Kruskal-Wallis test. We can also use the data to create a graph.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Sward = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Sward” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Twoway anova xl.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Two way anova in Excel

File

Twoway anova xl.txt

Structure

The data are in 3 columns; the first column shows the grazing regime and the next 2 columns show the abundance of a plant species in two sites.

Uses

The principle use for these data is to illustrate 2-way analysis of variance. These data are in a layout that only works for sensibly Excel. We may also use these data to create a graph.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

These data are in a layout that is not really suitable for analysis in R. I would be possible to use the read.table() command in a similar manner to other data but before any meaningful analyses could be carried out some rearrangement would need to be done. The data are also presented in more “normal” layout in a separate file (Twoway anova br.txt); see following example.

Example file for practice: Twoway anova br.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Plant abundance in relation to grazing and site

File

Twoway anova br.txt

Structure

The file contains 3 columns; the first is the abundance of a plant species in a series of quadrats. The next column is the site where the observations were made and the final column shows the grazing treatment at that location. These data are the same as the previous example (Twoway anova xl.txt) but are in regular recording format.

Uses

The main use for these data is to illustrate 2-way analysis of variance. We may also use the data for other purposes, to draw a graph for example.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Graze = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Graze” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Hoglouse Three sites.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Houglouse abundance at three sites

File

Hoglouse Three sites.txt

Structure

The data are in 3 columns, one for each site. Each column contains values for the abundance of a freshwater invertebrate for that site.

Uses

The main use for these data is to illustrate use of the Kruskal-Wallis test for differences. We might also use the data to draw a graph.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Hog = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Hog” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Regression.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Butterflies and food – a regression

File

Regression.txt

Structure

The data comprises of 3 columns. The first is the abundance of a butterfly species. The next two contain values for the abundance of larval and adult food plants.

Uses

The principle use for these data is to illustrate multiple regression. We may also use these data for other purposes, drawing graphs for example.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Bfly = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Bfly” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Post pivot.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Butterfly abundance at 3 sites – post pivot table

File

Post pivot.txt

Structure

These data are in 3 columns, one for each site. The values represent the numbers of butterfly species seen on repeated visits to each site.

Uses

These data are the result of creating a pivot table using data we met earlier (Pivot.txt). In this form we may use them to carry out a differences test (e.g. Kruskal-Wallis or anova) or perhaps create a graph.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Bfly = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Bfly” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Pie chart.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Garden birds and habitat selection

File

Pie chart.txt

Structure

The data consists of 5 columns and 6 rows of values. The columns are various habitats and the rows are various common bird species. We have both row and column headings.

Uses

We use these data to illustrate the use of pie charts but it is also suitable for a chi squared test for association.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Birds = read.table(file.choose(), sep = “\t”, comment = “#”, row.names = 1, header = TRUE)

You can replace the “Birds” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored. In this case we require the first column (the habitat names) to be treated as row names so we use the row.names = 1 part.


Example file for practice: Mayfly regression.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Mayfly and multiple regression

File

Mayfly regression.txt

Structure

These data comprise of a column of mayfly sizes and 4 columns of habitat data.

Uses

The main use is to illustrate multiple regression; in the text we looked at stepwise regression. The data may also be used for other purposes such as summarizing samples and drawing graphs.

Excel

To get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

Mfly = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “Mfly” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: Beach hoppers.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Californian beach hoppers logistic regression

File

Beach hoppers.txt

Structure

These data are composed of a column of latitude information. The next two columns show the number of individuals at each of the latitudes that had one version or the other of a particular allele. The final column is a proportion at that latitude of individuals with the second version of the allele.

Uses

The main use is to illustrate one form of logistic regression.

Excel

This example is intended to be used in R but to get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

CBH = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “CBH” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Example file for practice: fly data.txt

Click to view or right click to download

Back to Instruction list
Back to File list
Back to top

Title

Flies and sugar diets

File

fly data.txt

Structure

These data are composed of a column for the "growth" and a column for the diet "sugar".

Uses

The main use is to illustrate how to create graphs (the data are used for a boxplot in the text) but you can also carry out ANOVA and post-hoc tests.

Excel

This example is intended to be used in R but to get the data into Excel simply open the program and then the file. You will need to tell Excel that the data are in delimited format and that the delimiter is the Tab character. Then Excel is able to display the data in separate cells. The top few lines are for information and begin with the hash character #. You may ignore them or delete the rows.

R

To get these data into R we need to use a command like so:

fly = read.table(file.choose(), sep = “\t”, comment = “#”, header = TRUE)

You can replace the “fly” part with a name of your own choosing. The sep = “\t” part tells R that the data are separated by Tab characters and the comment = “#” part tells R that the # character begins comment lines, which are ignored.


Click to view or right click to download

Pivot.txt | Beetle size.txt | Beetle comparison.txt | Leaf sizes.txt | Ridge Furrow.txt | Paired data.txt
Correlation.txt | Pearson.txtPolynomial.txt | Logarithmic.txt | Chi Sq.txt | Goodness of Fit.txt
Three sites.txt | Twoway anova xl.txt | Twoway anova br.txt | Hoglouse Three sites.txt | Regression.txt
Post pivot.txt | Pie chart.txt | Mayfly regression.txt | Beach hoppers.txt | fly data.txt

 

See also...

Learn to use R for statistical analyses:

Index page

blogger counter
 


Top
Gardeners Own Home
Education Home
Other Publications
About Us