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


Object class logical
TRUE
FALSE

Top

Types of R object – 2. logical

All R objects have a class attribute, which can be important as R "decides" how to deal with objects based upon their class.

Simple 1-dimensional objects are called vectors but vector is not a class in itself. A vector can be numeric or character in nature (these are class attributes). You can also have a logical class, which is either TRUE or FALSE.

> lv
[1] FALSE TRUE FALSE FALSE FALSE
> class(lv)
[1] "logical"

You can create a logical vector by using TRUE or FALSE in a command like c() for example:

> lv2 <- c(TRUE, FALSE, FALSE, TRUE)
> lv2
[1] TRUE FALSE FALSE TRUE

R recognises TRUE and FALSE as logical. You must use upper case but you can abbreviate using T or F:

> lv3 <- c(T, T, F, F)
> lv3
[1] TRUE TRUE FALSE FALSE

If you are typing commands for yourself then using abbreviations is fine but when your commands are destined to be seen by others then it is a good idea to use the "full" version.


Top << Previous Tip: Types of R object – 1. basics >> Next Tip: Types of R object – 3. complex numbers
 
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.


Top Home
Data Analysis
Contact GardenersOwn Homepage