450 likes | 587 Views
Basics. R is a powerful statistical and graphical environment. Free, open-source, C-based, object-oriented programming language maintained and supported by community developers. Popular in scientific community. Extendible thru user-developed packages. R is effective for data management.
E N D
R is a powerful statistical and graphical environment. Free, open-source, C-based, object-oriented programming language maintained and supported by community developers. Popular in scientific community. Extendible thru user-developed packages. R is effective for data management. Handles calculations involving vectors, arrays, and matrices. Large collection of tools for data analysis. Powerful graphical capabilities. http://cran.r-project.org/
Outline • Installation of R - Windows • R GUI • Customizing R • R Code Editors • R Features • R Objects • R Data Structures • Vectors • Lists • Factors • Arrays • Matrices • Strings • Data frames
Installation of R - Windows http://cran.us.r-project.org/
Installation of R - Windows ## 32-bit (i386) vs. 64-bit (x64) • Only relevant with 64-bit versions of Windows • # Advantages.. • Better for handling large data structures • 32-bit <1GB object size • 64-bit >1GB object size • # Disadvantages.. • Less efficient for small data structures (store 8 bytes rather than 4 bytes) • Less external software is available for 64-bit versions (ex. ODBC drivers) • Some packages not compatible with 64-bit builds
Installation of R - Windows ## Functions/Packages/Libraries in R ## Functions.. # Compiled code (built-in or developed) to perform certain tasks ## Packages.. # Collections of R functions, data, and compiled code in a well-defined format. search() # Shows available packages currently loaded ## Libraries.. # The directory where packages are stored library() # Shows installed packages ## List of available packages in R http://cran.r-project.org/web/packages/available_packages_by_name.html
Installation of R - Windows • # Packages we will be using from CRAN • RODBC ODBC database access • rgdal geospatial data abstraction • raster geospatial data analysis with rasters • rgeos spatial geometry with polygons Choose one that is close to you
Installation of R - Windows # Install the package RODBC install.packages('RODBC', dependencies=TRUE) # To list all available packages in library library() ## Homework: # Install the rgdal, raster, and rgeos packages. # To install multiple packages pkgs <- c('rgdal', 'raster', 'rgeos') install.packages(pkgs, dependencies=TRUE)
Installation of R - Windows ## Getting help in R help(package = RODBC) # Help for package help(odbcConnect) # Help for functions # or.. ?odbcConnect # Help for functions ??odbc # Search for functions with odbc ## Components of help files for functions # Usage Shows parameters of functions # Arguments Describes parameters # Details More details of parameters # Value The output from function # Note Miscellaneous information of functions # Author(s) The creator of the function # See Also Other similar functions to link to # Examples An example using functions with executable code
R GUI ## File.. # Source R code.. Open and run R script # New script..Open text editor within R and start a new script # Open script.. Open a saved script within R # Display files.. Shows browser with files in working directory # Load/Save Workspace.. Load/save current R workspace (.Rdata) # Load/Save History.. Load/save current R commands # Change dir... Changes working directory [ same as: setwd("dirpath") ] ## Working directory.. setwd("C:/Rworkshop") ## Use forward slashes getwd()
Customizing R ##To customize R environment # There is a text file called Rprofile.sitein the user home directory (C:/.../R/R-3.0.1/etc). # This file is used to initialize settings every time you open an R workspace. # Here, you can add a default working directory or add options.. # To modify this file, open in a text editor, such as Notepad or Wordpad. # Add a line anywhere in the file with setwd("working directory") # Example: setwd("C:\\1IW\\1Projects") ## To set options (settings).. options() # look at current options options("digits") # look at current options for digits help(options) # get help on option settings a <- 1234567891234.123456789 a # Display a options(scipen=6) # bias against scientific notation options(digits=20) # controls number of digits to print a # Display a again options("digits") options(digits=7) # Return back to default
Exercise 1 ## Exercise 1 # What is your current directory? This is the default directory. # Change the working directory to your Rworkshop folder. # Add options(scipen=6) to your Rprofile.site file. Note: You many need administrative privileges, depending on system.
R Code Editors # R Commander: A basic statistics graphical user interface (GUI) for R (John Fox) http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/ # Rstudio: A free, open source, integrated development environment for R. http://www.rstudio.com/ # Tinn-R A free, open source editor/work processor for Windows operating system only http://nbcgib.uesc.br/lec/software/des/editores/tinn-r/en # Notepad ++ A free source code editor that supports several languages http://notepad-plus-plus.org/ # NpptoR Similar to R gui built-in editor, extends functionality of code passing from Notepad++ to R. http://sourceforge.net/projects/npptor/
R Features ## R code is immediately executed, not compiled… and object-oriented # Math 1 + 1 # Addition 5 * 20 # Multiplication 10 == 100 # Logical 4^2 # 4 squares sqrt(4) # Square root abs(-5) # Absolute # Get time or date Sys.time() Sys.Date() # Variable assignment (R objects) a <- 1 + 1 a =1 + 1 assign("a", 1 + 1) # Print object to screen print(a)
R Objects ## Objects.. # store data elements # are members of different classes # you can use different methods (functions) to operate on them ## Example objects # variables, vectors, lists, arrays, matrices, data frames ## Common attributes of R objects # class - defines type of object, what properties it possesses, how it behaves, # and how it relates to other types of objects # (numeric, character, logical, list, factor, matrix, dataframe, etc...) # mode - storage mode or type of object (numeric, character, logical, list, function, etc...) # typeof - typeof is an internal descriptor for R, similar to mode, although somewhat # more specific (See example below). # method - a function associated with a particular type of object (ex. summary, print) # Link to discussion on objects http://cran.r-project.org/doc/manuals/r-release/R-lang.html#Introduction
R Objects • ## Two types of R objects – S3 and S4 • # S3 objects – classes and methods from beginning – informal methods • # S4 objects – classes and methods developed later – more formal methods (spatial) • ## Object names.. • # Case sensitive • # Consists of letters, numbers, and the dot or underline character • # Can not contain spaces or dashes '-' or special characters • # Can not start with a number or a dot followed by number • # Can not be a reserved word (stored R object). • ## Testing object types and modes • myObject <- 1.2345 # Create object • isS4(myObject) # Test if object is S4 object • mode(myObject) # Get mode • typeof(myObject) # Get type • class(myObject) # Get class • is.character(myObject) # Test if object is character • is.vector(myObject) # Test if object is vector
R Objects ## Creating/Removing R objects in R workspace myObject <- 1 # Create object ls() # Lists objects in R workspace ls(pattern="my") # Lists only objects with 'my' in name rm(myObject); ls() # Removes object from R workspace ## Saving/Loading/Removing R objects in working directory myObject <- 1 save(myObject, file="mydata.Rda") # Saves object to working directory list.files(getwd()) # Lists files in working directory list.files(getwd(), pattern=".Rda") # Lists only files ending in *.Rda rm(myObject); ls() load("mydata.Rda"); ls() # Loads object back to R workspace file.remove("mydata.Rda") # Removes object from working directory help(file.remove) file.exists("mydata.Rda") # Checks if file exists Note: *.Rda, *.rda, or *.Rdata are all valid R data formats
R Data Types # character 'Name' (Factor) # Note: a string is a character variable with 1 or more characters myObject <- "1" is.character(myObject) mode(myObject) # integerwhole numbers (ex. 1, 2, 3) myObject <- 1 # Create object is.integer(myObject) # Check if object is integer mode(myObject) # Check mode typeof(myObject) # Check typeof myObject <- as.integer(myObject) # Create new object is.integer(myObject) # Check if object is integer mode(myObject) # Check mode typeof(myObject) # Check typeof # numeric double precision number. Identical to double (ex. 1.2345) myObject <- 1.2345 is.numeric(myObject) is.double(myObject) mode(myObject) typeof(myObject) # logical TRUE/FALSE myObject <- TRUE is.logical(myObject) mode(myObject)
Exercise 2 2.1 Create an object named x and assign it the value . 2.2 Create an object named a and assign it to the value pi. Display the value of a. 2.3 Create an object named b and assign it to the value "pi". 2.4 What are the modes of a and b? 2.5 Without using pi create an object e that has the value . 2.6 Save e to a file named pi.Rda in your working directory, then remove e from your R workspace, then check it is not in the R workspace. 2.7 Load e back to R workspace and check that it is there. 2.8 Remove all the objects you created and the file you stored e in. Is your workspace empty?
R Data Structures # vector group of single objects or elements (all elements must be the same mode) # factorsvector of values that are limited to a fixed set of values (categories) # list group of objects called components (can be different modes and lengths) # array group of vectors with more than 1 dimension (all elements must be the same mode) format: array(data=NA, dim=c(dim1, dim2, ..) # matrix 2-dimensional array (group of vectors with rows and columns) (all elements must be the same mode). format: matrix(data=NA, nrow=1, ncol=1, byrow=FALSE) # data frame 2-dimensional list (group of vectors of the same length) (can be different modes) format: data.frame(row, col) Images from: https://www.stat.auckland.ac.nz/~paul/ItDT/HTML/node64.html
Vectors ## Vector - group of single objects or elements (all elements must be the same mode) a <- 1 + 1 # numeric b <- 5 * 20 # numeric d<- a + b # numeric e<- "string" # character f<- TRUE # logical # c – combines elements to a vector.. all elements coerced to common type help(c) g <- c(a, b, d) # Numeric vector g <- c(a=a, b=b, d=d) # Create a named vector g # Display values of g mode(g) # Display mode of g h <- c(d, e, f) # Change all elements to character h # Display values of h mode(h) # Display mode of h names(h) <- c("d","e","f") # Create a named vector names(h) # Display the names of elements of h h # Display names and values of elements of h
Vectors ## Vector cont… print(g) # Print g to console g # Display contents of g ## Accessing elements of vector g[1] # Display first element of vector g[c(1,3)] # Display first and third element of vector g[1:3] # Displayfirst thru third elements of vector g["b"] # Display element named "b" names(g)[2] # Display the name of second element of vector g[c(1,"b")] # Note: can not combine element number and name g[c("a","b")] # Correct way ## Add/Remove elements of a vector g["e"] <- 50 # Add element named 'e' to vector g g <- c(g, 60) # Another way to add an element to vector g # Note: no name for last element names(g)[5] names(g)[5] <- "last" # Add name to last element of g print(g) # Display g
Exercise 3 ## Run the code on the previous slides.. 3.1 Form a vector named j, consisting of the objects b, d and e, with names 'b', 'd' and 'e'. 3.2 What is the mode of j? Check whether j is a vector (Hint: use is.******( ) function). 3.3 Add the elements of vector g named "b" and "d". Do the same for the vector j. Why the error message for one and not the other? Change the mode of the elements in j to numeric and try again. 3.4 Replace the "d" element of the vector g with the sum of the elements "b" and "last" of the vector g. What is the value of the element "d" of the vector g? 3.5 Clean up your workspace, remove all objects. We would like to remove all the objects without typing them into rm(). Hint, try list=ls() and print the object list onto the screen. Can you combine this with rm()? You have to be careful with this, but it is a way clear your workspace up.
Vectors ## Generate vectors v1 <- seq(1,20) # Create vector of numbers from 1 to 20 v2 <- seq(1,40,2) # Create vector of number 1 to 40 by 2 v3 <- rep(1, 20) # Create vector of 1 with length 20 v1 <- sample(v1) # Creates a permutation of v1 v4 <- v1 / v2 # Create vector from other vectors mode(v1) mode(v4) typeof(v1) typeof(v4) ## Vector functions mean(v1) # Mean of vector max(v1) # Max value vector sort(v1) # Order vector length(v1) # Number of elements in vector sum(v1) # Sum elements of vector round(v4, 2) # Round elements of vector by 2 decimal places v5 <- sort(v1) # Makes new vector equal to v1 in order v5 v5 + 2 # Adds 2 to each element of v5 c(rep(-1,10), rep(2,10)) # Creates a vector of 20 elements v5 + c(rep(-1,10), rep(2,10)) # Adds the two vectors element by element
Vectors ## Logical operators >, >= # greater than, greater than or equal to <, <= # less than, less than or equal to ==, != # equal to; not equal to x & y # and x | y # or %in% # equal to a set of values !x # not ## Logical vectors are conditional statements v5; mode(v5) # Display v5; check mode length(v5) == 10 # Is the number of elements of v5 equal to 10? length(v5) == 20 # Is the number of elements of v5 equal to 20? is.character(v5) # Are elements of v5 character? !is.character(v5) # Are elements of v5 not character? v5 %in% c(100:200) # Are the elements of v5 in the range 100 to 200? v5 < 5 # Are the elements of v5 less than 5? all(v5 < 5) # Do all element of v5 meet logical condition(<5)? any(v5 < 5) # Do any element of v5 meet logical condition(<5)? which(v1 < 5) # Position of elements from v1 which meet logical # condition(<5).
Vectors ## Logical operators – Example # Find the mean of all elements in vect5 which are greater than 15. We can do it in steps. # Step 1: The logical vector for elements which are greater than 15 v5 > 15 # Step 2: The vector of elements in v5 which are greater than 15 v5[v5 > 15] # Display on screen temp.vect <- v5[v5 > 15] # Assign to an object # Step 3: The mean of all elements in v5 which are greater than 15 mean(v5[v5 > 15]) # Display on screen mean(temp.vect) # Use the assigned vector
Vectors ## Logical operators – More examples # Logical vectors v6 <- v5 + 10; v6 # Add 5 to v5 and assign to v6; Display v6 v6 < 13 # Logical vector for condition (< 13) v6[which(v6 < 13)] # Integer vector of elements of v6 which are < 13 # Vector elements v6[v6 < 13] # Vector of elements less than 13 v6[v6 < 13 | v6 > 25] # Vector of elements less than 13 or greater than 25 v6[v6 == 20] # Vector of elements equal to 20 v6[v6 != 20] # Vector of elements not equal to 20 v6[v6 %in% c(20:25)] # Vector of elements equal to values 20 thru 25 v6[!v6 %in% c(20:25)] # Vector of elements not equal to values 20 thru 25 # Functions to vector elements sum(v6 < 13) # Number of elements less than 13 sum(v6[v6 < 13]) # Sum of elements less than 13 min(v6[v6 < 13]) # Minimum value of elements less than 13 # Change vector elements based on logical vector v6[v6 >= 20] <- 10 # Change values > 20 to 10 sort(v6) # Display vector in order
Vectors • ## Creating vectors from a sample • ## We will see later that logical vectors are used a lot in R!! • vect5 <- sample(1:30, 25, replace = TRUE) # Look at help(sample) • length(vect5) • vect5 # Run above code. Are your vector and my vector the same? • vect6 <- sample(1:30,25,replace = TRUE) • vect5 == vect6 # Is vect5 the same vector as vect6? • sum(vect5 == vect6) • # A way to make them the same no matter which computer run on • set.seed(1234, kind=NULL); • vect5 <- sample(1:30,25,replace = TRUE) • vect5 # Does your vector and mine vector agree now? • set.seed(1234, kind=NULL); • vect6 <- sample(1:30,25,replace = TRUE) • sum(vect5 == vect6)
Exercise 4 # Run the following code to create vect1 and vect2: vect1 <- c(rep(1,10), rep(2,10)) # Creates a vector named vect1, with length 20, where the first 10 elements are 1 and next 10 # elements are 2. vect2 <- c(seq(1,30), seq(40,60)) # Creates a vector named vect2, which contains the numbers from 1 to 30 and numbers from # 40 to 60. 4.1 Create a vector named vect3, which contains a sample of size 20, without replacement, from the numbers between 1 to 30 and from 40 to 50. Hint, use vect2 and the function sample(). So we can compare answers set a seed of 673. Display vect3. 4.2 Add 1 to the first 10 elements of vect3 and 2 to the next 10 elements. Hint use vect1. 4.3 How many elements in vect3 are greater than 25? 4.4 How many elements in vect3 are less than 50? 4.5 What is the max of the elements in vect3 which are less than 50? 4.6 How many elements in vect3 are greater than 25 and less than 50? 4.7 What is the mean of the elements in vect3 are greater than 25 and less than 50?
Lists ## Lists- group of objects (can be different modes) a <- 1 + 1 # numeric b <- 5 * 20 # numeric d <- a + b # numeric e <- "string" # character f <- TRUE # logical g <- c(a, b, d); g <- c(a=a, b=b, d=d) # vector i<- list(d, e, f)# list – (can be different mode) i<- list(d=d, e=e, f=f) # named components of list i$g<- g # append a vector to list i # display list names(i) # get names of list ## Accessing elements of a list i[1] # Identifies first element of list i[1:3] # Identifies first thru third element of list i[[1]] # Identifies value of first element of list i[["d"]] # Identifies value of list element "d" i$d # Identifies value of list element "d" names(i$g) # Get names of list element "g" i[["g"]] # Get value of list element "g" i[["g"]][2] # Get second element of list element "g" unlist(i[1:3]) # Converts first thru third list elements to a vector unlist(i) # Converts list to a vector
Exercise 5 ## Run the code on the previous slides and then the following code. h <- c(d, e, f) names(h) <- c("d","e","f") 5.1 What is the mode of i ? What is the mode of h? 5.2 What is the mode of i[1]? What is the mode of i[[1]]? 5.3 Print i[[2]] and h[2] and then compare their modes. 5.4 Print i[[3]] and h[3] and then compare their modes.
Factors ## Factors – categorical data # A vector whose elements can take on one of a fixed set of values, called levels. # used in specific model and plotting function # requires less storage because each unique category is stored as a number ## Create a factor vector f <- factor(c("one", " two", "three")) mode(f) class(f) ## Accessing elements of factor f[1:2] # Identifies first 2 elements of factor vector levels(f) # Identifies different levels of factor vector ## Add elements to a factor f[4] <- "four" # Add element to factor (error: invalid) levels(f)[4] <- "four" # Add new level to factor levels f[4] <- "four" # Add element to factor as.character(f)# Converts factor vector to character vector
Arrays/Matrices # array group of vectors with more than 1 dimension (all elements must be the same mode) #array(data=NA, dim=c(dim1, dim2, ..) # matrix 2-dimensional array (a group of vectors with rows and columns, all of same mode). # matrix(data=NA, nrow=1, ncol=1, byrow=FALSE, dimnames=NULL) ## Array array(data=0, dim=c(5,2)) # 2-dimensional array (matrix) array(data=0, dim=c(5,2,4)) # 3-dimensional array ## Matrix g <- rep(1,3) h <- seq(3) i <- c("one", "two", "three") matrix(data=0, nrow=5, ncol=2) # Create matrix of 0 values mat <- matrix(c(g, h), nrow=3, ncol=2) # Create matrix of 2 vectors, g and h mat2 <- matrix(c(h, i), nrow=3, ncol=2) # Create matrix of 2 vectors, h and i # (changes all values to strings) dimnames(mat) <- list(NULL, c("h", "i")) # Name columns of matrix rownames <- c("row1", "row2", "row3") # Create row names dimnames(mat) <- list(rownames, c("h", "i")) # Name columns and rows of matrix matrix(c(1,2,3,4,5,6), ncol=2, nrow=3, byrow=FALSE) # fill matrix by column matrix(c(1,2,3,4,5,6), ncol=2, nrow=3, byrow=TRUE) # fill matrix by row
Matrices ## Matrix manipulation mat # Display matrix mat is.matrix(mat) # Check if object is a matrix dim(mat) # Get dimensions of matrix t(mat) # transpose matrix c(mat) # Create a vector from matrix c(t(mat)) # Create a vector from transposed matrix ## Accessing elements of a matrix mat[1,2] # Identify value in row 1, column 2 mat[3,2]# Identify value in row 3, column 2 mat[2,] # Identify values in row 2 (vector) mat[,2] # Identify values in column 2 (vector) mat[2:3,2] # Identify values in rows 2 thru 3 and column 2 (vector) mat[mat==1] <- 11 # Change all values of 1 to 11 ## Add/Remove elements of a matrix mat2 <- rbind(mat2, c("new", "row")) # Add row to matrix mat2 <- mat2[-(2:3),] # Removes 2nd thru 3rd row of matrix
Matrices ## Vector & Matrix calculations vect <- rep(5, 5) vect2 <- seq(1,3) mat1 <- matrix(data=c(rep(1,5), rep(2,5)), nrow=5, ncol=2) mat2 <- matrix(data=c(rep(5,5), rep(2,5)), nrow=5, ncol=2) # Element-wise vect+ mat1 # Add vect elements to all elements of mat1 vect2 + mat1 # Elements wise addition the vector just repeats vect* mat1 # Multiply vect elements to all elements of mat1 mat2 - 1 # Subtract 1 from all elements of mat2 vect * t(mat1) # Multiply vectwith transposed matrix mat1 * mat2 # Multiply all elements of mat1 with all elements of mat2 t(mat1 * mat2) # Transpose results of multiplication # Product vect %*% mat1 # Product of vect multiplied by elements of mat1
Strings ## String functions str <- "filename.csv" # Define string nchar(str) # Get number of characters in string strsplit(str, "[.]") # Get components of string split by . unlist(strsplit(str, "[.]")) # Get components of string split by . unlist(strsplit(str, "\\.")) # Get components of string split by . a <- unlist(strsplit(str, "[.]"))[1] # Get first component of string split b<- strsplit(str, "[.]")[[1]][2] # Get second component of string split extension(str) # Get the extension of a string (raster) grep("file", str) # Find pattern in string sub("file", "new", str) # Substitute one pattern for new pattern toupper(str) # Convert string to upper case paste("one", "two", "three", sep="-")# Concatenate strings paste(a, "_2.", b, sep="") # Concatenate strings
Data Frames ## Data frames are the primary data structure in R. ## Data frames are used for storing data tables, such as forest inventory data tables. ## A data frame is similar structure to a matrix, except a data frame may contain categorical data, such as species names. ## Each column of a data frame is treated as a vector component of a list and therefore, can be different modes. The difference is that each vector component must have same length.
Data Frames # data frame 2-dimensional list (group of vectors of the same length; can be different modes) # data.frame(row, column) ## Start with a matrix mat <- matrix(data=c(seq(1,5), rep(2,5)), nrow=5, ncol=2) df <- data.frame(mat) # Convert matrix to data frame is.data.frame(df) # Check if object is a data frame dim(df) # Get dimensions of data frame str(df) # Get structure of data frame matv <- c(mat) # Create a vector from matrix is.vector(matv) dflst <- c(df) # Create a list from data frame is.list(dflst) ## Accessing elements of a data frame ## Data frames can be accessed exactly like matrices, but they can also be accessed by column names. df[3,1] # Identify value in row 3, column 1 df[3,] # Identify values in row 3 (vector) df[,2] # Identify values in column 2 (vector) df[2:4,1] # Identify values in rows 2 thru 4and column 1 (vector) df[3,"X2"] # Identify value in row 3, column 2 df[,"X2"] # Identify values in column 2('X2') df[2:4,"X1"] # Identify values in rows 2 thru 4 and column 1('X1')
Data Frames • ## Building your own data frame.. • dat <- edit(data.frame()) ## Build data frame from vectors of rows and columns.. # Column vectors numbervect <- c(1, 2, 3) stringvect <- c("a", "b", "c") logicalvect <- c(TRUE, FALSE, TRUE) # Combine column vectors into a data frame and name columns df <- data.frame(cbind(numbervect, stringvect, logicalvect)) df <- data.frame(cbind(COLUMN1=numbervect, COLUMN2=stringvect, COLUMN3=logicalvect)) # Row vectors row1vect <- c(1, "a", TRUE) row2vect <- c(2, "b", FALSE) row3vect <- c(3, "c", TRUE) # Combine row vectors into a data frame df <- data.frame(row1vect, row2vect, row2vect) # Name data frame columns names(df) <- c("COLUMN1", "COLUMN2", "COLUMN3")
Exercise 6 Scenerio: You collected data on one plot today. We need to compile the data in R for analysis. There were 5 trees: pine, pine, walnut, walnut, alder The heights were: 100, 75, 120, 90, 50 The tree status was: live, live, live, dead, live 6.1 Create a vector with 5 elements of tree names and assign it to an object named 'tree'. 6.2 Display the number of elements in the tree vector? 6.3 What is the mode of the tree vector? 6.4 Display the .number of elements in the tree vector that are "walnut". 6.5 Create a vector with 5 elements of tree heights and assign it to an object named 'ht'. 6.6 What is the mode of the ht vector? 6.7 What is the maximum height of all 5 trees?.. what is the average height? 6.8 Create another vector of 5 elements with tree status and assign to an object named 'status'. 6.9 What is the mode of 'status'? 6.10 Change 'status' to a factor with 2 levels, 1:live; 2:dead and assign back to object 'status'.
Exercise 6 cont.. 6.11 Create a data frame object named 'treesdf', with the 3 vectors you just made, 'tree', 'ht', and 'status'. 6.12 What are the dimensions of treesdf? 6.13 What are the column names of treesdf? 6.14 What does the structure of treesdf look like? 6.15 You missed a tree. It was a dead pine tree with height of 30 meters. Add it to treesdf and assign this new data frame to on object named 'treesdf2'. 6.16 Save the object, treesdf2 to a file in your workspace named 'treesdf2.Rda'.
R Help Links # List of available packages in R http://cran.r-project.org/web/packages/available_packages_by_name.html http://www.cran.r-project.org/doc/manuals/R-intro.pdf # Link to discussion on objects http://cran.r-project.org/doc/manuals/r-release/R-lang.html#Introduction # Link to discussion on S4 classes and Methods http://www.r-project.org/conferences/useR-2004/Keynotes/Leisch.pdf # R Wiki - Tips http://rwiki.sciviews.org/doku.php?id=tips:tips#data