R Studio_Excel Commands.pdf - Excel AVERAGE = MEAN-MEDIAN =...

• 8

This preview shows page 1 - 4 out of 8 pages.

Excel AVERAGE ( ) = MEAN -MEDIAN ( ) = MEDIAN -VAR ( ) = VARIANCE - STDEV ( ) = STANDARD DEVIATION -MIN ( ) - Remember to highlight the range - MAX ( ) - QUARTILE.INC (array, quart) - to calculate interquartile and quartile ranges 0 = min value 1 = first quartile (25th %) 2 = median (2nd quartile, 50%) 3 = third quartile (75%) 4 = max value R Studio Basics: Creating vectors To create a vector = c( ) If want to name it do name= c(#) Working With Functions c ( ) Sum ( ) Mean ( ) Min ( ) Max ( ) Sample( ) You get a random subset of numbers Checking Data tail ( ) see last 6 rows head( ) see first six rows Working with Data names( ) = to see column names \$ = to access a particular column Ex: MyData\$food Numerical vs Categorical str(MyData) Checks how r studio interpreted data Indicates the type of data in each column
We can correct data type by doing colClasses("","") Force the columns into specific data types Can see the column names = names( ) MyData = read.csv("metabolic.csv",colClasses=c('factor','numeric', 'factor','numeric','factor','numeric')) New data that is subset of the original one = subset(data, condition) Graphs year= c ( insert data here separated by commas) plot( put name of x , put name of y) xlab or ylab = ("whatever you want to label it") Colour data color( ) to get all data and colours Ex: color("blue", "purple"…. Scatter Plot • plot( ) • abline ( ) create straight lines on a plot • Abline( v ) is where you want the line drawn Eabline(v=84.1155,col= 'blue') abline(h=69.0015,col= 'red') Line Plots Plot ( ) Set X and Y axis Xlab Ylab Boxplot x= MyData\$ column y = MyData\$ column boxplot() EX: boxplot(mercury~lake,main="Mercury Concentrations by Lake",ylab='Mercury Concentration (ppb)',xlab='Lake',col=c('lightblue','red'),data=MyData) Mercury~lake Indicates to boxplot() that mercury quantiles should be calc for each level in lake levels(MyData\$columnname) Factor(x,order) x is vector to reorder and order is want categories to appear on your figure Histograms • hist( ) • To create a custom figure= xlab = "…." & ylab=".." • main="…" - (this is the title) Bar Plot
barplot( ) ylim = c(a,b) Add colour , col="red"
• • • 