R-Project Sample Scripts

***Also see our new R-project Links page!***

The sample scripts below have been develeoped and used by project partners during their research.  They are simple demonstrations of tools which may help you with geo-analysis of your own study data.  If you have developed similar scripts of your own and would like to share them with your project partners please email them to me at neil.alexander@zoo.ox.ac.uk.

Shapefiles and Projections in R

This is an excellent introduction in how to import and manipulate data from ESRI shapefiles (GIS vector data) within R.  It utilises the R packages rgdal and maptools and addresses how to read shapefiles into R and how to manage projection systems.

This How-to guide was kindly contibuted by Els Duhceyne at Euro-AeGIS and Avia-GIS. A member of the EDENext Data Management Team and can be downloaded from this page.

Multiple Euclidean Distance Calculator

This script calculates the Euclidean distance* between multiple points utilising the distances function of the aspace package.  There are three options within the script:

Option 1: Distances for one single point to a list of points

Option 2: All the distances between the points in a single list

Option 3: The distance between each point in list one and all the points in list two 

The script is written to run with demo data from the aspace package, but incudes commented lines which can be utilised to easily import the users own data.

You can download the script from this page.

*The Euclidean distance is the straight line distance (as the crow flies).  The X/Y coordinates inputed should be recorded in metres only.

Decimal Degrees to Degree Minute Seconds (DMS) Converter

Two short scripts in the R statistical programming language the first demonstrates how to convert Decimal Degrees to Degree Minute Seconds (DMS) format and the second script converts the other way from Degree Minute Seconds (DMS) format to Decimal Degrees.

This script was contributed by Daniela Cianci PhD student at the University of Utrecht (FVM) who wrote it while working on the EDENext project.

You can download the scripts from this page.

The zipfile includes both scripts and a list of latitude and longitude points for EDENext institutions which is used as demo data for the scripts.  Please note that if you convert data from decimal degrees to DMS and back again there may be small variation in results due to rounding within the calculations.  But any variation is very minor.

Also note there is a similar function dd2dms included in the sp package which may also be worth checking out.  However our  custom written function provides a simple way to convert a list of points with minimum effort.

Import your sandfly data into the EDENext Sand fly Sample Database Format

The following R-Script developed by Jorian Prudhomme (IRD) to import his sand-fly sample data into the EDENext approved sandfly (PhBD group) database format.

It includes the import script with everything you require to understand and run it:

1. Databank (example of the databank we have to complete) - Import into.
2. Database (example of the database we have after all the dissections) - Input table.
3. Database but in .txt format
4. Script R, I made it with Kate (free software)
Download it from here.
Many thanks to Jorian for allowing us to share this script.