######################## # Topic 1: FIRST STEPS # ######################## rm(list=ls())# clean all objects in memory setwd ('D:/Data Lab/Data Vianney/Class/R ecology/Class 2017-2018/data_class') # set up new wd # UPDATE if(!require(installr)) { install.packages("installr"); require(installr)} updateR() # PACKAGE install.packages ("abc") # install the package 'abc' library ("abc") # load the package 'abc' # HELP ? median help (median) # help on median function median # basic use of the function ?? median # help on all function with median in the description # WORKING DIRECTORY getwd() # identify your current working directory ?setwd # set up a new working directory # QUIT R # q() # to quit R # OBJECTS ls() # all objects in memory rm(list=ls()) # clean all objects in memory # press CTRL +L to clean all your console # CALCULATOR 3+2 # addition 3-2 # substraction 3*2 # multiplication 3/2 # division 3^3 # power log(2) # logarithm exp(2) # exponential (5 + 3) / 4 # define priority using () or {} pi*4 # common function # READING DATA setwd ('D:/.../') # setwd ('D:/Data Lab/Data Vianney/Class/R ecology/Rclass/dataset') read.table ("taiwan_coral.txt",header = TRUE,sep="\t", dec=".") # same as following if we are not changing the working directory read.table ("D:/.../taiwan_coral.txt",header = T, sep="\t", dec=".") # also same as: read.table("taiwan_coral.txt", TRUE, "\t",".") # create and name object taiwan_coral <- read.table ("taiwan_coral.txt", header = TRUE, sep="\t", dec=".") taiwan_coral # you can locate the file by hand dat <- read.table (file.choose (), header = T, sep="\t", dec=".") # you can also use read.delim(), read.csv(), and others functions ####### # END # #######