A guide for complete R beginners :- R Syntax

R is a functional based language, the inputs to a function, including options, are in brackets. Note that all dat and options are separated by a comma

  • Function(data, options)

Even quit is a function

  • q()

So is help

help(read.table)

Provides the help page for the FUNCTION ‘read.table’

help.search(“t test”)

Searches for help pages that might relate to the phrase ‘t test’

NOTE: quotes are needed for search strings, they are not needed when referring to data objects or function names.

There is a short cut for help,

? shows the help page on a function name, same as help(function)

?read.table

?? searches for help pages on functions, same as help.search(‘phrase’)

??“t test”

Information is usually returned from a function, by default this is printed to screen

read.table(‘data.tsv’)

This can always be stored, we call what it is stored in an ‘object’

mydata

here mydata is an object of type dataframe

Reminder:

  • Vector: a list of numbers, equivalent to a column in a table
  • Data Frame = a collection of vectors. Equivalent to a table

Hint:

  • Up/Down arrow keys can be use to cycle through previous commands