Dr. Mark Gardener

Home
About

Providing training for:

  • Ecology
  • Data analysis
  • Statistics
  • R The statistical programming language
  • Data management
  • Data mining

Tips and Tricks - for R and Excel

On this page you can find tips, tricks and hints for using both R and Excel. At the end of each tip there are links forwards and backwards as appropriate. There is also an index of R tips and an index of Excel tips.

For most analytical purposes the combination of Excel and R is unbeatable! Excel is great as a data management tool and for preparing data for analysis. You can also use it to get an overview of your data or to make simple (and not so simple) graphs. R is an analytical "swiss army knife" and can carry out a mind-boggling array of analytical routines as well as producing great graphics.

Tips & Tricks for R | Tips & Tricks for Excel | An Introduction to R | MonogRaphs | Writer's Bloc


na.omit()
na.rm = TRUE

Top

NA items

The NA item is a special object and represents "Not Available". Sometimes this is because data were genuinely not collected but often it is because you have unequal columns and your data frame is padded out with NA to make the short columns longer. The na.rm = TRUE instruction can be used to strip out NA items before some commands, for example:

> x
[1] 2 4 3 6 2 8 NA NA


> mean(x)
[1] NA

> mean(x, na.rm = TRUE)
[1] 4.166667

However, this does not always work:

> length(x, na.rm = TRUE)
Error in length(x, na.rm = TRUE) :
2 arguments passed to 'length' which requires 1

In this case the na.omit() command can be used to strip out the NA items:

> length(na.omit(x))
[1] 6


Top << Previous Tip: Interactive file choice >> Next Tip: Add comments to objects
 
Follow me...
Facebook Twitter Google+ Linkedin Amazon
Top Tips & Tricks Home Index of R Tips Index of Excel Tips  
More links:

An introduction to R

See my Publications about Excel, R, statistics and data analysis Courses in R, data analysis, data management and statistics Visit the R Project website
 

See my Publications about statistics and data analysis.

MonogRaphs: random topics in R

Writer's Bloc – my latest writing project includes R scripts

Courses in data analysis, data management and statistics.

My Publications about statistics and data analysis

Managing Data Using Excel, Cover

See my personal pages at GardenersOwn


Top Home
Data Analysis
Contact GardenersOwn Homepage