Objects, Class and Attributes

Size: px
Start display at page:

Download "Objects, Class and Attributes"

Transcription

1 Objects, Class and Attributes Introduction to objects classes and attributes Practically speaking everything you encounter in R is an object. R has a few different classes of objects. I will talk mainly about S3 objects. If we have time I will talk about S4 classes. Everything your store in your workspace is an object. The built in functions are objects The datasets are objects ggplot2 graphics are objects (base graphics are not) Every object has a class and many objects have attributes The basics You can use the class function to determine an objects class You can use the attributes function to see its attributes Let s start with a few examples class function (x).primitive("class") class(class) [1] "function" attributes(class) NULL What about data? class(mtcars) [1] "data.frame" attributes(mtcars) $names [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" [11] "carb" $row.names [1] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" [4] "Hornet 4 Drive" "Hornet Sportabout" "Valiant" [7] "Duster 360" "Merc 240D" "Merc 230" [10] "Merc 280" "Merc 280C" "Merc 450SE" [13] "Merc 450SL" "Merc 450SLC" "Cadillac Fleetwood" [16] "Lincoln Continental" "Chrysler Imperial" "Fiat 128" [19] "Honda Civic" "Toyota Corolla" "Toyota Corona" [22] "Dodge Challenger" "AMC Javelin" "Camaro Z28" [25] "Pontiac Firebird" "Fiat X1-9" "Porsche 914-2" [28] "Lotus Europa" "Ford Pantera L" "Ferrari Dino" [31] "Maserati Bora" "Volvo 142E" 1

2 $class [1] "data.frame" Lets create a summary of our data s1 <- summary(mtcars) s1 mpg cyl disp hp Min. :10.40 Min. :4.000 Min. : 71.1 Min. : st Qu.: st Qu.: st Qu.: st Qu.: 96.5 Median :19.20 Median :6.000 Median :196.3 Median :123.0 Mean :20.09 Mean :6.188 Mean :230.7 Mean : rd Qu.: rd Qu.: rd Qu.: rd Qu.:180.0 Max. :33.90 Max. :8.000 Max. :472.0 Max. :335.0 drat wt qsec vs Min. :2.760 Min. :1.513 Min. :14.50 Min. : st Qu.: st Qu.: st Qu.: st Qu.: Median :3.695 Median :3.325 Median :17.71 Median : Mean :3.597 Mean :3.217 Mean :17.85 Mean : rd Qu.: rd Qu.: rd Qu.: rd Qu.: Max. :4.930 Max. :5.424 Max. :22.90 Max. : am gear carb Min. : Min. :3.000 Min. : st Qu.: st Qu.: st Qu.:2.000 Median : Median :4.000 Median :2.000 Mean : Mean :3.688 Mean : rd Qu.: rd Qu.: rd Qu.:4.000 Max. : Max. :5.000 Max. :8.000 class(s1) [1] "table" attributes(s1) $dim [1] 6 11 $dimnames $dimnames[[1]] [1] "" "" "" "" "" "" $dimnames[[2]] [1] " mpg" " cyl" " disp" " hp" " drat" [6] " wt" " qsec" " vs" " am" " gear" [11] " carb" $class [1] "table" What about a graphic library(ggplot2) p1 <- ggplot(mtcars,aes(wt,mpg)) + geom_point() p1 2

3 mpg class(p1) wt [1] "gg" "ggplot" attributes(p1) $names [1] "data" "layers" "scales" "mapping" "theme" [6] "coordinates" "facet" "plot_env" "labels" $class [1] "gg" "ggplot" What about a linear model m1 <- lm(mpg~wt,data=mtcars) m1 Call: lm(formula = mpg ~ wt, data = mtcars) Coefficients: (Intercept) wt class(m1) [1] "lm" 3

4 attributes(m1) $names [1] "coefficients" "residuals" "effects" "rank" [5] "fitted.values" "assign" "qr" "df.residual" [9] "xlevels" "call" "terms" "model" $class [1] "lm" Let s create a summary of our model s1 <- summary(m1) s1 Call: lm(formula = mpg ~ wt, data = mtcars) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) < 2e-16 *** wt e-10 *** --- Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: on 30 degrees of freedom Multiple R-squared: , Adjusted R-squared: F-statistic: on 1 and 30 DF, p-value: 1.294e-10 class(s1) [1] "summary.lm" attributes(s1) $names [1] "call" "terms" "residuals" "coefficients" [5] "aliased" "sigma" "df" "r.squared" [9] "adj.r.squared" "fstatistic" "cov.unscaled" $class [1] "summary.lm" exercise Compute and assign the anova table for m1. What is its class? What are its attributes. Look at the object. Can you tell what function is served by each attribute? Back to basics for class We know that vectors are everywhere in R. Even a scaler is a vector of length 1. 4

5 Once you store a vector you have created an R object. Every object has a mode and storage mode. Vectors have a inherent class based on their mode. There are also a few implicit classes like matrix, array and integer. There are 5 data types that are stored in basic (atomic) vectors class mode storage.mode logical logical logical integer numeric integer numeric numeric double complex complex complex character character character Besides the basic modes of logical, integer, double, complex and character, we will see mode list and function. x <- 1 class(x) [1] "numeric" mode(x) [1] "numeric" attributes(x) NULL x <- 1L class(x) [1] "integer" mode(x) [1] "numeric" attributes(x) NULL dim(x) <- c(1,1) class(x) [1] "matrix" mode(x) [1] "numeric" attributes(x) $dim [1] 1 1 dim(x) <- c(1,1,1) class(x) [1] "array" 5

6 mode(x) [1] "numeric" attributes(x) $dim [1] Matrix and array are not very informative classes because they do not tell us the real type of data they contain. exercise Assign x the value a. What are its class and mode? Give it a dimension c(1,1). What are its class and mode? The difference between a matrix and data frame carmt <- as.matrix(mtcars) carmt mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX Mazda RX4 Wag Datsun Hornet 4 Drive Hornet Sportabout Valiant Duster Merc 240D Merc Merc Merc 280C Merc 450SE Merc 450SL Merc 450SLC Cadillac Fleetwood Lincoln Continental Chrysler Imperial Fiat Honda Civic Toyota Corolla Toyota Corona Dodge Challenger AMC Javelin Camaro Z Pontiac Firebird Fiat X Porsche Lotus Europa Ford Pantera L Ferrari Dino Maserati Bora

7 Volvo 142E cardf <- mtcars cardf mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX Mazda RX4 Wag Datsun Hornet 4 Drive Hornet Sportabout Valiant Duster Merc 240D Merc Merc Merc 280C Merc 450SE Merc 450SL Merc 450SLC Cadillac Fleetwood Lincoln Continental Chrysler Imperial Fiat Honda Civic Toyota Corolla Toyota Corona Dodge Challenger AMC Javelin Camaro Z Pontiac Firebird Fiat X Porsche Lotus Europa Ford Pantera L Ferrari Dino Maserati Bora Volvo 142E dim(carmt) [1] dim(cardf) [1] carmt[10,4] [1] 123 cardf[10,4] [1] 123 They look the same and feel the same. class(carmt) [1] "matrix" 7

8 class(cardf) [1] "data.frame" attributes(carmt) $dim [1] $dimnames $dimnames[[1]] [1] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" [4] "Hornet 4 Drive" "Hornet Sportabout" "Valiant" [7] "Duster 360" "Merc 240D" "Merc 230" [10] "Merc 280" "Merc 280C" "Merc 450SE" [13] "Merc 450SL" "Merc 450SLC" "Cadillac Fleetwood" [16] "Lincoln Continental" "Chrysler Imperial" "Fiat 128" [19] "Honda Civic" "Toyota Corolla" "Toyota Corona" [22] "Dodge Challenger" "AMC Javelin" "Camaro Z28" [25] "Pontiac Firebird" "Fiat X1-9" "Porsche 914-2" [28] "Lotus Europa" "Ford Pantera L" "Ferrari Dino" [31] "Maserati Bora" "Volvo 142E" $dimnames[[2]] [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" [11] "carb" attributes(cardf) $names [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" [11] "carb" $row.names [1] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" [4] "Hornet 4 Drive" "Hornet Sportabout" "Valiant" [7] "Duster 360" "Merc 240D" "Merc 230" [10] "Merc 280" "Merc 280C" "Merc 450SE" [13] "Merc 450SL" "Merc 450SLC" "Cadillac Fleetwood" [16] "Lincoln Continental" "Chrysler Imperial" "Fiat 128" [19] "Honda Civic" "Toyota Corolla" "Toyota Corona" [22] "Dodge Challenger" "AMC Javelin" "Camaro Z28" [25] "Pontiac Firebird" "Fiat X1-9" "Porsche 914-2" [28] "Lotus Europa" "Ford Pantera L" "Ferrari Dino" [31] "Maserati Bora" "Volvo 142E" $class [1] "data.frame" mode(carmt) [1] "numeric" mode(cardf) [1] "list" But they are fundamentally different objects. 8

9 A matrix is a long vector with an attribute (dim) that gives an easier way to access similar items. Each row (same car) and column (same type of measurement) should have something in common. Internally the data stacks the columns. A matrix can be accessed like a vector. length(carmt) [1] 352 carmt[10,4] [1] 123 dim(carmt) [1] carmt[3*32 +10] [1] 123 A data frame is a special type of list. Each element of the list is a vector and each vector must be the same length. The same element number of each vector should have something in common (the same car). A data frame can be accessed like a list. length(cardf) [1] 11 cardf[10,4] [1] 123 cardf[[4]][10] [1] 123 cardf$hp[10] [1] 123 exercise Without using a double index extract the qsec for the Valiant from carmt and cardf The R list object The dataframe$variable notation we are used to more generally a property of lists. You can access an element of a list by listname$elementname. Lists are probably the most important type of objects in R. To prove this lets look at our past objects. class(mtcars) [1] "data.frame" mode(mtcars) [1] "list" class(p1) [1] "gg" "ggplot" 9

10 mode(p1) [1] "list" class(m1) [1] "lm" mode(m1) [1] "list" class(s1) [1] "summary.lm" mode(s1) [1] "list" They all have different classes but internally they are all lists. Most objects other than basic vectors have an attribute that defines their class. Those without a defined class consider their mode to be their class (usually list). Even with a defined class, the object can usually be treated as indicated by their mode. What is a list? It is a more complicated vector. Like a basic vector it can contain any number of elements including zero. Unlike a basic vector, where each element is a single realization of the same basic mode, each element of a list can be any R object and each can be a different type. x <- list() class(x) [1] "list" mode(x) [1] "list" length(x) [1] 0 To assign an element to a list you can type x$function <- lm x$data <- mtcars x$scaler <- 1 length(x) [1] 3 attributes(x) $names [1] "Function" "data" "scaler" A more common way to create the list is x <- list(func=lm,dat=mtcars,onenum=1,model=m1,random=sample(letters,5)) length(x) [1] 5 10

11 attributes(x) $names [1] "func" "dat" "onenum" "model" "random" x$random [1] "A" "H" "Z" "I" "O" Using lists we can create an object containing a variety of different object types. Furthermore we can access the pieces of the list using listname$elementname notation. Also note that mtcars and m1 are objects of mode list. This means a list can contain a list as one of its elements. Since many of the objects we ve created are of mode list, we can access their elements using the list notation. attributes(m1) $names [1] "coefficients" "residuals" "effects" "rank" [5] "fitted.values" "assign" "qr" "df.residual" [9] "xlevels" "call" "terms" "model" $class [1] "lm" m1$coefficients (Intercept) wt exercise use t.test and mtcars, conduct and store an object that tests if mpg differ by transmission type (am). What is the class and mode of the object. Look at its attributes and extract the p value. The pesky factor object in R Lets examine the factor object in R more carefully. It can look a numeric or character but it is really neither. We can use the unclass function to remove the class attribute. A <- gl(3,5,labels=c("red","green","blue")) A [1] red red red red red green green green green green blue [12] blue blue blue blue Levels: red green blue class(a) [1] "factor" mode(a) [1] "numeric" attributes(a) 11

12 $levels [1] "red" "green" "blue" $class [1] "factor" unclass(a) [1] attr(,"levels") [1] "red" "green" "blue" B <- gl(3,1,15,labels=c(4.8,5.3,6.2)) B [1] Levels: unclass(b) [1] attr(,"levels") [1] "4.8" "5.3" "6.2" It is an integer vector with values ranging from 1 to n where n is the number of levels of the factor. It has 2 attributes, levels and class. However it cannot be treated as its mode (numeric) B[1] + B[2] Warning in Ops.factor(B[1], B[2]): '+' not meaningful for factors [1] NA C <- as.numeric(b) C[1] + C[2] [1] 3 D <- as.numeric(as.character(b)) D[1] + D[2] [1] 10.1 Attributes (metadata) What is an attribute? It is a list of additional information that can be attached to an object. class(attributes(m1)) [1] "list" The attributes function can be used to access the whole list. Individual attributes can be accessed using the attr function. attr(b,"levels") [1] "4.8" "5.3" "6.2" 12

13 However you may have noticed there are many attributes that are used repeatedly. These common attributes have conditions and must be set to an acceptable value or an error will occur. Common attributes will have functions that allow you to access them directly. For some common classes, like factor, their attributes will also have a function that can access them directly. levels(b) [1] "4.8" "5.3" "6.2" names(b) NULL The functions not only access the attributes but also allow you to change the value of the attribute. We ve already seen this with dim. names(b) <- paste0("b",1:15) attributes(b) $levels [1] "4.8" "5.3" "6.2" $class [1] "factor" $names [1] "B1" "B2" "B3" "B4" "B5" "B6" "B7" "B8" "B9" "B10" "B11" [12] "B12" "B13" "B14" "B15" names(b)[1] <- "Bob" B Bob B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B Levels: levels(b) <- letters[25:26] Error in `levels<-.factor`(`*tmp*`, value = c("y", "z")): number of levels differs levels(b) <- letters[24:26] B Bob B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 x y z x y z x y z x y z x y z Levels: x y z Attributes that do not have their own functions can be modified using attr a1 <- anova(m1) a1 Analysis of Variance Table Response: mpg Df Sum Sq Mean Sq F value Pr(>F) wt e-10 *** Residuals Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 13

14 attr(a1,"heading") [1] "Analysis of Variance Table\n" "Response: mpg" attr(a1,"heading") <- "ANOVA Table for MPG" a1 ANOVA Table for MPG Df Sum Sq Mean Sq F value Pr(>F) wt e-10 *** Residuals Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 exercise using carsdf rename am " to Trans and vs to Engine. Can you do the same thing to carmt What does class do for an object (Generic Functions) In order to understand the importance of class we need to introduce the generic function. The key to the object oriented nature of R is the a function called UseMethod. UseMethod takes the function name and the class of the first argument, pastes them together and runs a function of the form functionname.class. If no such function exists, it uses the next class listed for an object. If it cannot find a suitable function it runs functionname.default. coef function (object,...) UseMethod("coef") <bytecode: 0x7ff98f54e070> <environment: namespace:stats> The most commonly used generic function is print. Everytime you view an R object, it calls the appropriate print method with default settings. s1 Call: lm(formula = mpg ~ wt, data = mtcars) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) < 2e-16 *** wt e-10 *** --- Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: on 30 degrees of freedom Multiple R-squared: , Adjusted R-squared:

15 F-statistic: on 1 and 30 DF, p-value: 1.294e-10 print(s1) Call: lm(formula = mpg ~ wt, data = mtcars) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) < 2e-16 *** wt e-10 *** --- Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: on 30 degrees of freedom Multiple R-squared: , Adjusted R-squared: F-statistic: on 1 and 30 DF, p-value: 1.294e-10 print(s1,signif.stars=false) Call: lm(formula = mpg ~ wt, data = mtcars) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) < 2e-16 wt e-10 Residual standard error: on 30 degrees of freedom Multiple R-squared: , Adjusted R-squared: F-statistic: on 1 and 30 DF, p-value: 1.294e-10 If you want to view the raw object you can call print.default directly or use the unclass function on the object. print.default(s1) $call lm(formula = mpg ~ wt, data = mtcars) $terms mpg ~ wt attr(,"variables") list(mpg, wt) attr(,"factors") wt mpg 0 15

16 wt 1 attr(,"term.labels") [1] "wt" attr(,"order") [1] 1 attr(,"intercept") [1] 1 attr(,"response") [1] 1 attr(,".environment") <environment: R_GlobalEnv> attr(,"predvars") list(mpg, wt) attr(,"dataclasses") mpg wt "numeric" "numeric" $residuals Mazda RX4 Mazda RX4 Wag Datsun Hornet 4 Drive Hornet Sportabout Valiant Duster 360 Merc 240D Merc Merc 280 Merc 280C Merc 450SE Merc 450SL Merc 450SLC Cadillac Fleetwood Lincoln Continental Chrysler Imperial Fiat Honda Civic Toyota Corolla Toyota Corona Dodge Challenger AMC Javelin Camaro Z Pontiac Firebird Fiat X1-9 Porsche Lotus Europa Ford Pantera L Ferrari Dino Maserati Bora Volvo 142E $coefficients Estimate Std. Error t value Pr(> t ) (Intercept) e-19 wt e-10 $aliased (Intercept) wt FALSE FALSE $sigma [1] $df 16

17 [1] $r.squared [1] $adj.r.squared [1] $fstatistic value numdf dendf $cov.unscaled (Intercept) wt (Intercept) wt attr(,"class") [1] "summary.lm" What R shows you and what the real object looks like can be very different. To see all the methods available for a function use methods methods(coef) [1] coef.aov* coef.arima* coef.default* coef.listof* coef.maov* [6] coef.nls* see '?methods' for accessing help and source code To see what generic functions are available to a given class of object we also use methods methods(class="lm") [1] add1 alias anova case.names [5] confint cooks.distance deviance dfbeta [9] dfbetas drop1 dummy.coef effects [13] extractaic family formula fortify [17] hatvalues influence kappa labels [21] loglik model.frame model.matrix nobs [25] plot predict print proj [29] qr residuals rstandard rstudent [33] simulate summary variable.names vcov see '?methods' for accessing help and source code exercise formula is a generic function. How many classes does the formula function have a specific method for. What happens if you call formula with an lm object. What happens if you call formula with a data.frame object. Caution about classes There are no formal definition for an S3 class. You make any object have class data.frame but if they do not have the appropriate elements and attributes, they will cause errors or strange behaviour. class(carmt) <- "data.frame" class(carmt) 17

18 [1] "data.frame" carmt NULL <0 rows> (or 0-length row.names) carmt <- unclass(carmt) carmt mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX Mazda RX4 Wag Datsun Hornet 4 Drive Hornet Sportabout Valiant Duster Merc 240D Merc Merc Merc 280C Merc 450SE Merc 450SL Merc 450SLC Cadillac Fleetwood Lincoln Continental Chrysler Imperial Fiat Honda Civic Toyota Corolla Toyota Corona Dodge Challenger AMC Javelin Camaro Z Pontiac Firebird Fiat X Porsche Lotus Europa Ford Pantera L Ferrari Dino Maserati Bora Volvo 142E Although you can assign any class to an object, the generic functions in R expect a certain structure. If you follow that structure, it will work x <- list(dbl=rnorm(10),char=letters[1:10],fact=gl(2,5)) x $DBL [1] [7] $CHAR [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" 18

19 $FACT [1] Levels: 1 2 attributes(x) $names [1] "DBL" "CHAR" "FACT" class(x) <- "data.frame" x [1] DBL CHAR FACT <0 rows> (or 0-length row.names) attributes(x) $names [1] "DBL" "CHAR" "FACT" $class [1] "data.frame" rownames(x) <- letters[1:10] x DBL CHAR FACT a A 1 b B 1 c C 1 d D 1 e E 1 f F 2 g G 2 h H 2 i I 2 j J 2 attributes(x) $names [1] "DBL" "CHAR" "FACT" $class [1] "data.frame" $row.names [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" S4 objects So far everything we ve talked about has been considering S3 objects. There is another class of object we have not discussed yet, that is S4 objects. S4 objects can trip you up because they operate differently than S3. There is a formal definition of an S4 class. All objects in an S4 class are forced to follow the appropriate definition. 19

20 library(lmertest) Warning: package 'lmertest' was built under R version Loading required package: Matrix Loading required package: methods Loading required package: lme4 Attaching package: 'lmertest' The following object is masked from 'package:lme4': lmer The following object is masked from 'package:stats': step m1 <- lmer(reaction ~ Days + (Days Subject), sleepstudy) class(m1) [1] "mermodlmertest" attr(,"package") [1] "lmertest" mode(m1) [1] "S4" iss4(m1) [1] TRUE names(attributes(m1)) [1] "Gp" "call" "frame" "flist" "cnms" "lower" "theta" [8] "beta" "u" "devcomp" "pp" "optinfo" "resp" "class" To access S4 data a slightly different syntax is used. names(m1) NULL slotnames(m1) [1] "Gp" "call" "frame" "flist" "cnms" "lower" "theta" [8] "beta" "u" "devcomp" "pp" "optinfo" "resp" m1$gp Error in m1$gp: $ operator not defined for this S4 class m1@gp [1] 0 36 class(m1@gp) [1] "integer" 20

21 [1] FALSE Elements of S4 class objects can be S3 class objects. VC <- VarCorr(m1) class(vc) [1] "VarCorr.merMod" iss4(vc) [1] FALSE names(vc) [1] "Subject" class(vc$subject) [1] "matrix" exercise Compute and store the object vcov(m1). What class and mode is it? What elements does it contain? What is the length of x? Thank You for attending this session. 21

Basic R QMMA. Emanuele Taufer. 2/19/2018 Basic R (1)

Basic R QMMA. Emanuele Taufer. 2/19/2018 Basic R (1) Basic R QMMA Emanuele Taufer file:///c:/users/emanuele.taufer/google%20drive/2%20corsi/5%20qmma%20-%20mim/0%20classes/1-3_basic_r.html#(1) 1/21 Preliminary R is case sensitive: a is not the same as A.

More information

Introduction for heatmap3 package

Introduction for heatmap3 package Introduction for heatmap3 package Shilin Zhao April 6, 2015 Contents 1 Example 1 2 Highlights 4 3 Usage 5 1 Example Simulate a gene expression data set with 40 probes and 25 samples. These samples are

More information

Quick Guide for pairheatmap Package

Quick Guide for pairheatmap Package Quick Guide for pairheatmap Package Xiaoyong Sun February 7, 01 Contents McDermott Center for Human Growth & Development The University of Texas Southwestern Medical Center Dallas, TX 75390, USA 1 Introduction

More information

Introduction to R: Day 2 September 20, 2017

Introduction to R: Day 2 September 20, 2017 Introduction to R: Day 2 September 20, 2017 Outline RStudio projects Base R graphics plotting one or two continuous variables customizable elements of plots saving plots to a file Create a new project

More information

Graphics in R STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley

Graphics in R STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley Graphics in R STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Base Graphics 2 Graphics in R Traditional

More information

Chapter 7. The Data Frame

Chapter 7. The Data Frame Chapter 7. The Data Frame The R equivalent of the spreadsheet. I. Introduction Most analytical work involves importing data from outside of R and carrying out various manipulations, tests, and visualizations.

More information

Resources for statistical assistance. Quantitative covariates and regression analysis. Methods for predicting continuous outcomes.

Resources for statistical assistance. Quantitative covariates and regression analysis. Methods for predicting continuous outcomes. Resources for statistical assistance Quantitative covariates and regression analysis Carolyn Taylor Applied Statistics and Data Science Group (ASDa) Department of Statistics, UBC January 24, 2017 Department

More information

Computing with large data sets

Computing with large data sets Computing with large data sets Richard Bonneau, spring 009 (week ): introduction to R other notes, courses, lectures about R and S Ingo Ruczinski and Rafael Irizarry (Johs Hopkins Biostat): http://www.biostat.jhsph.edu/~bcaffo/statcomp/index.html

More information

Introduction to Huxtable David Hugh-Jones

Introduction to Huxtable David Hugh-Jones Introduction to Huxtable David Hugh-Jones 2018-01-01 Contents Introduction 2 About this document............................................ 2 Huxtable..................................................

More information

Regression Models Course Project Vincent MARIN 28 juillet 2016

Regression Models Course Project Vincent MARIN 28 juillet 2016 Regression Models Course Project Vincent MARIN 28 juillet 2016 Executive Summary "Is an automatic or manual transmission better for MPG" "Quantify the MPG difference between automatic and manual transmissions"

More information

enote 1 1 enote 1 Introduction to R Updated: 01/02/16 kl. 16:10

enote 1 1 enote 1 Introduction to R Updated: 01/02/16 kl. 16:10 enote 1 1 enote 1 Introduction to R Updated: 01/02/16 kl. 16:10 enote 1 INDHOLD 2 Indhold 1 Introduction to R 1 1.1 Getting started with R and Rstudio....................... 3 1.1.1 Console and scripts............................

More information

This is a simple example of how the lasso regression model works.

This is a simple example of how the lasso regression model works. 1 of 29 5/25/2016 11:26 AM This is a simple example of how the lasso regression model works. save.image("backup.rdata") rm(list=ls()) library("glmnet") ## Loading required package: Matrix ## ## Attaching

More information

Will Landau. January 24, 2013

Will Landau. January 24, 2013 Iowa State University January 24, 2013 Iowa State University January 24, 2013 1 / 30 Outline Iowa State University January 24, 2013 2 / 30 statistics: the use of plots and numerical summaries to describe

More information

getting started in R

getting started in R Garrick Aden-Buie // Friday, March 25, 2016 getting started in R 1 / 70 getting started in R Garrick Aden-Buie // Friday, March 25, 2016 INFORMS Code & Data Boot Camp Today we ll talk about Garrick Aden-Buie

More information

Create Awesome LaTeX Table with knitr::kable and kableextra Hao Zhu

Create Awesome LaTeX Table with knitr::kable and kableextra Hao Zhu Create Awesome LaTeX Table with knitr::kable and kableextra Hao Zhu 2017-10-31 Contents Overview 2 Installation 2 Getting Started 2 LaTeX packages used in this package...................................

More information

Advances in integrating statistical inference

Advances in integrating statistical inference Nicos Angelopoulos 1 Samer Abdallah 2 and Georgios Giamas 1 1 Department of Surgery and Cancer, Division of Cancer, Imperial College London, Hammersmith Hospital Campus, Du Cane Road, London W12 ONN, UK.

More information

Create Awesome LaTeX Table with knitr::kable and kableextra

Create Awesome LaTeX Table with knitr::kable and kableextra Create Awesome LaTeX Table with knitr::kable and kableextra Hao Zhu 2018-01-15 Contents Overview 3 Installation 3 Getting Started 3 LaTeX packages used in this package...................................

More information

Handling Missing Values

Handling Missing Values Handling Missing Values STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Missing Values 2 Introduction

More information

The Tidyverse BIOF 339 9/25/2018

The Tidyverse BIOF 339 9/25/2018 The Tidyverse BIOF 339 9/25/2018 What is the Tidyverse? The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar,

More information

Getting started with ggplot2

Getting started with ggplot2 Getting started with ggplot2 STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 ggplot2 2 Resources for

More information

WEEK 13: FSQCA IN R THOMAS ELLIOTT

WEEK 13: FSQCA IN R THOMAS ELLIOTT WEEK 13: FSQCA IN R THOMAS ELLIOTT This week we ll see how to run qualitative comparative analysis (QCA) in R. While Charles Ragin provides a program on his website for running QCA, it is not able to do

More information

S CHAPTER return.data S CHAPTER.Data S CHAPTER

S CHAPTER return.data S CHAPTER.Data S CHAPTER 1 S CHAPTER return.data S CHAPTER.Data MySwork S CHAPTER.Data 2 S e > return ; return + # 3 setenv S_CLEDITOR emacs 4 > 4 + 5 / 3 ## addition & divison [1] 5.666667 > (4 + 5) / 3 ## using parentheses [1]

More information

The xtablelist Gallery. Contents. David J. Scott. January 4, Introduction 2. 2 Single Column Names 7. 3 Multiple Column Names 9.

The xtablelist Gallery. Contents. David J. Scott. January 4, Introduction 2. 2 Single Column Names 7. 3 Multiple Column Names 9. The xtablelist Gallery David J. Scott January 4, 2018 Contents 1 Introduction 2 2 Single Column Names 7 3 Multiple Column Names 9 4 lsmeans 12 1 1 Introduction This document represents a test of the functions

More information

Stat 241 Review Problems

Stat 241 Review Problems 1 Even when things are running smoothly, 5% of the parts produced by a certain manufacturing process are defective. a) If you select parts at random, what is the probability that none of them are defective?

More information

Accessing Databases from R

Accessing Databases from R user Vignette: Accessing Databases from R Greater Boston user Group May, 20 by Jeffrey Breen jbreen@cambridge.aero Photo from http://en.wikipedia.org/wiki/file:oracle_headquarters_redwood_shores.jpg Outline

More information

MBV4410/9410 Fall Bioinformatics for Molecular Biology. Introduction to R

MBV4410/9410 Fall Bioinformatics for Molecular Biology. Introduction to R MBV4410/9410 Fall 2018 Bioinformatics for Molecular Biology Introduction to R Outline Introduce R Basic operations RStudio Bioconductor? Goal of the lecture Introduce you to R Show how to run R, basic

More information

9.1 Random coefficients models Constructed data Consumer preference mapping of carrots... 10

9.1 Random coefficients models Constructed data Consumer preference mapping of carrots... 10 St@tmaster 02429/MIXED LINEAR MODELS PREPARED BY THE STATISTICS GROUPS AT IMM, DTU AND KU-LIFE Module 9: R 9.1 Random coefficients models...................... 1 9.1.1 Constructed data........................

More information

Statistics Lab #7 ANOVA Part 2 & ANCOVA

Statistics Lab #7 ANOVA Part 2 & ANCOVA Statistics Lab #7 ANOVA Part 2 & ANCOVA PSYCH 710 7 Initialize R Initialize R by entering the following commands at the prompt. You must type the commands exactly as shown. options(contrasts=c("contr.sum","contr.poly")

More information

Lab #7 - More on Regression in R Econ 224 September 18th, 2018

Lab #7 - More on Regression in R Econ 224 September 18th, 2018 Lab #7 - More on Regression in R Econ 224 September 18th, 2018 Robust Standard Errors Your reading assignment from Chapter 3 of ISL briefly discussed two ways that the standard regression inference formulas

More information

Lab #13 - Resampling Methods Econ 224 October 23rd, 2018

Lab #13 - Resampling Methods Econ 224 October 23rd, 2018 Lab #13 - Resampling Methods Econ 224 October 23rd, 2018 Introduction In this lab you will work through Section 5.3 of ISL and record your code and results in an RMarkdown document. I have added section

More information

610 R12 Prof Colleen F. Moore Analysis of variance for Unbalanced Between Groups designs in R For Psychology 610 University of Wisconsin--Madison

610 R12 Prof Colleen F. Moore Analysis of variance for Unbalanced Between Groups designs in R For Psychology 610 University of Wisconsin--Madison 610 R12 Prof Colleen F. Moore Analysis of variance for Unbalanced Between Groups designs in R For Psychology 610 University of Wisconsin--Madison R is very touchy about unbalanced designs, partly because

More information

What R is. STAT:5400 (22S:166) Computing in Statistics

What R is. STAT:5400 (22S:166) Computing in Statistics STAT:5400 (22S:166) Computing in Statistics Introduction to R Lecture 5 September 9, 2015 Kate Cowles 374 SH, 335-0727 kate-cowles@uiowa.edu 1 What R is an integrated suite of software facilities for data

More information

Getting started with simulating data in R: some helpful functions and how to use them Ariel Muldoon August 28, 2018

Getting started with simulating data in R: some helpful functions and how to use them Ariel Muldoon August 28, 2018 Getting started with simulating data in R: some helpful functions and how to use them Ariel Muldoon August 28, 2018 Contents Overview 2 Generating random numbers 2 rnorm() to generate random numbers from

More information

Exercise 2.23 Villanova MAT 8406 September 7, 2015

Exercise 2.23 Villanova MAT 8406 September 7, 2015 Exercise 2.23 Villanova MAT 8406 September 7, 2015 Step 1: Understand the Question Consider the simple linear regression model y = 50 + 10x + ε where ε is NID(0, 16). Suppose that n = 20 pairs of observations

More information

EXST 7014, Lab 1: Review of R Programming Basics and Simple Linear Regression

EXST 7014, Lab 1: Review of R Programming Basics and Simple Linear Regression EXST 7014, Lab 1: Review of R Programming Basics and Simple Linear Regression OBJECTIVES 1. Prepare a scatter plot of the dependent variable on the independent variable 2. Do a simple linear regression

More information

Section 2.3: Simple Linear Regression: Predictions and Inference

Section 2.3: Simple Linear Regression: Predictions and Inference Section 2.3: Simple Linear Regression: Predictions and Inference Jared S. Murray The University of Texas at Austin McCombs School of Business Suggested reading: OpenIntro Statistics, Chapter 7.4 1 Simple

More information

Notes based on: Data Mining for Business Intelligence

Notes based on: Data Mining for Business Intelligence Chapter 9 Classification and Regression Trees Roger Bohn April 2017 Notes based on: Data Mining for Business Intelligence 1 Shmueli, Patel & Bruce 2 3 II. Results and Interpretation There are 1183 auction

More information

A Knitr Demo. Charles J. Geyer. February 8, 2017

A Knitr Demo. Charles J. Geyer. February 8, 2017 A Knitr Demo Charles J. Geyer February 8, 2017 1 Licence This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License http://creativecommons.org/licenses/by-sa/4.0/.

More information

Output from redwing2.r

Output from redwing2.r Output from redwing2.r # redwing2.r library(lsmeans) library(nlme) #library(lme4) # not used #library(lmertest) # not used library(multcomp) # get the data # you may want to change the path to where you

More information

R Visualizing Data. Fall Fall 2016 CS130 - Intro to R 1

R Visualizing Data. Fall Fall 2016 CS130 - Intro to R 1 R Visualizing Data Fall 2016 Fall 2016 CS130 - Intro to R 1 mtcars Data Frame R has a built-in data frame called mtcars Useful R functions length(object) # number of variables str(object) # structure of

More information

Organizing data in R. Fitting Mixed-Effects Models Using the lme4 Package in R. R packages. Accessing documentation. The Dyestuff data set

Organizing data in R. Fitting Mixed-Effects Models Using the lme4 Package in R. R packages. Accessing documentation. The Dyestuff data set Fitting Mixed-Effects Models Using the lme4 Package in R Deepayan Sarkar Fred Hutchinson Cancer Research Center 18 September 2008 Organizing data in R Standard rectangular data sets (columns are variables,

More information

Demo yeast mutant analysis

Demo yeast mutant analysis Demo yeast mutant analysis Jean-Yves Sgro February 20, 2018 Contents 1 Analysis of yeast growth data 1 1.1 Set working directory........................................ 1 1.2 List all files in directory.......................................

More information

Metropolis. A modern beamer theme. Matthias Vogelgesang October 12, Center for modern beamer themes

Metropolis. A modern beamer theme. Matthias Vogelgesang October 12, Center for modern beamer themes Metropolis A modern beamer theme Matthias Vogelgesang October 12, 2018 Center for modern beamer themes Introduction Title formats Elements Conclusion 2 Introduction 3 Metropolis The metropolis theme is

More information

36-402/608 HW #1 Solutions 1/21/2010

36-402/608 HW #1 Solutions 1/21/2010 36-402/608 HW #1 Solutions 1/21/2010 1. t-test (20 points) Use fullbumpus.r to set up the data from fullbumpus.txt (both at Blackboard/Assignments). For this problem, analyze the full dataset together

More information

Regression on the trees data with R

Regression on the trees data with R > trees Girth Height Volume 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2 4 10.5 72 16.4 5 10.7 81 18.8 6 10.8 83 19.7 7 11.0 66 15.6 8 11.0 75 18.2 9 11.1 80 22.6 10 11.2 75 19.9 11 11.3 79 24.2 12 11.4 76

More information

Logical operators: R provides an extensive list of logical operators. These include

Logical operators: R provides an extensive list of logical operators. These include meat.r: Explanation of code Goals of code: Analyzing a subset of data Creating data frames with specified X values Calculating confidence and prediction intervals Lists and matrices Only printing a few

More information

Discussion Notes 3 Stepwise Regression and Model Selection

Discussion Notes 3 Stepwise Regression and Model Selection Discussion Notes 3 Stepwise Regression and Model Selection Stepwise Regression There are many different commands for doing stepwise regression. Here we introduce the command step. There are many arguments

More information

Introduction to R Software

Introduction to R Software 1. Introduction R is a free software environment for statistical computing and graphics. It is almost perfectly compatible with S-plus. The only thing you need to do is download the software from the internet

More information

Introduction to R, Github and Gitlab

Introduction to R, Github and Gitlab Introduction to R, Github and Gitlab 27/11/2018 Pierpaolo Maisano Delser mail: maisanop@tcd.ie ; pm604@cam.ac.uk Outline: Why R? What can R do? Basic commands and operations Data analysis in R Github and

More information

The linear mixed model: modeling hierarchical and longitudinal data

The linear mixed model: modeling hierarchical and longitudinal data The linear mixed model: modeling hierarchical and longitudinal data Analysis of Experimental Data AED The linear mixed model: modeling hierarchical and longitudinal data 1 of 44 Contents 1 Modeling Hierarchical

More information

Introduction to R. Introduction to Econometrics W

Introduction to R. Introduction to Econometrics W Introduction to R Introduction to Econometrics W3412 Begin Download R from the Comprehensive R Archive Network (CRAN) by choosing a location close to you. Students are also recommended to download RStudio,

More information

Spring 2017 CS130 - Intro to R 1 R VISUALIZING DATA. Spring 2017 CS130 - Intro to R 2

Spring 2017 CS130 - Intro to R 1 R VISUALIZING DATA. Spring 2017 CS130 - Intro to R 2 Spring 2017 CS130 - Intro to R 1 R VISUALIZING DATA Spring 2017 Spring 2017 CS130 - Intro to R 2 Goals for this lecture: Review constructing Data Frame, Categorizing variables Construct basic graph, learn

More information

Random coefficients models

Random coefficients models enote 9 1 enote 9 Random coefficients models enote 9 INDHOLD 2 Indhold 9 Random coefficients models 1 9.1 Introduction.................................... 2 9.2 Example: Constructed data...........................

More information

that is, Data Science Hello World.

that is, Data Science Hello World. R 4 hackers Hello World that is, Data Science Hello World. We got some data... Sure, first we ALWAYS do some data exploration. data(longley) head(longley) GNP.deflator GNP Unemployed Armed.Forces Population

More information

1 Simple Linear Regression

1 Simple Linear Regression Math 158 Jo Hardin R code 1 Simple Linear Regression Consider a dataset from ISLR on credit scores. Because we don t know the sampling mechanism used to collect the data, we are unable to generalize the

More information

Gelman-Hill Chapter 3

Gelman-Hill Chapter 3 Gelman-Hill Chapter 3 Linear Regression Basics In linear regression with a single independent variable, as we have seen, the fundamental equation is where ŷ bx 1 b0 b b b y 1 yx, 0 y 1 x x Bivariate Normal

More information

Analysis of variance - ANOVA

Analysis of variance - ANOVA Analysis of variance - ANOVA Based on a book by Julian J. Faraway University of Iceland (UI) Estimation 1 / 50 Anova In ANOVAs all predictors are categorical/qualitative. The original thinking was to try

More information

Estimating R 0 : Solutions

Estimating R 0 : Solutions Estimating R 0 : Solutions John M. Drake and Pejman Rohani Exercise 1. Show how this result could have been obtained graphically without the rearranged equation. Here we use the influenza data discussed

More information

Regression Lab 1. The data set cholesterol.txt available on your thumb drive contains the following variables:

Regression Lab 1. The data set cholesterol.txt available on your thumb drive contains the following variables: Regression Lab The data set cholesterol.txt available on your thumb drive contains the following variables: Field Descriptions ID: Subject ID sex: Sex: 0 = male, = female age: Age in years chol: Serum

More information

Statistical Bioinformatics (Biomedical Big Data) Notes 2: Installing and Using R

Statistical Bioinformatics (Biomedical Big Data) Notes 2: Installing and Using R Statistical Bioinformatics (Biomedical Big Data) Notes 2: Installing and Using R In this course we will be using R (for Windows) for most of our work. These notes are to help students install R and then

More information

References R's single biggest strenght is it online community. There are tons of free tutorials on R.

References R's single biggest strenght is it online community. There are tons of free tutorials on R. Introduction to R Syllabus Instructor Grant Cavanaugh Department of Agricultural Economics University of Kentucky E-mail: gcavanugh@uky.edu Course description Introduction to R is a short course intended

More information

Facets and Continuous graphs

Facets and Continuous graphs Facets and Continuous graphs One way to add additional variables is with aesthetics. Another way, particularly useful for categorical variables, is to split your plot into facets, subplots that each display

More information

Package assertr. R topics documented: February 23, Type Package

Package assertr. R topics documented: February 23, Type Package Type Package Package assertr February 23, 2018 Title Assertive Programming for R Analysis Pipelines Version 2.5 Provides functionality to assert conditions that have to be met so that errors in data used

More information

Practice in R. 1 Sivan s practice. 2 Hetroskadasticity. January 28, (pdf version)

Practice in R. 1 Sivan s practice. 2 Hetroskadasticity. January 28, (pdf version) Practice in R January 28, 2010 (pdf version) 1 Sivan s practice Her practice file should be (here), or check the web for a more useful pointer. 2 Hetroskadasticity ˆ Let s make some hetroskadastic data:

More information

Practical Guide To Cluster Analysis in R

Practical Guide To Cluster Analysis in R Multivariate Analysis I Alboukadel Kassambara Practical Guide To Cluster Analysis in R Unsupervised Machine Learning sthda.com Edition 1 A. Kassambara 2015 1 2 Copyright 2017 by Alboukadel Kassambara.

More information

Data Structures STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley

Data Structures STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley Data Structures STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Data Types and Structures To make the

More information

Getting Started in R

Getting Started in R Getting Started in R Phil Beineke, Balasubramanian Narasimhan, Victoria Stodden modified for Rby Giles Hooker January 25, 2004 1 Overview R is a free alternative to Splus: a nice environment for data analysis

More information

Programming Paradigms

Programming Paradigms Week 10 Lecture: Programming Paradigms, Introduction to Object Oriented Programming Introduction to Programming and Geoprocessing Using R GEO6938 4172 GEO4938 4166 Programming Paradigms Procedural Programming

More information

ETC 2420/5242 Lab Di Cook Week 5

ETC 2420/5242 Lab Di Cook Week 5 ETC 2420/5242 Lab 5 2017 Di Cook Week 5 Purpose This lab is to practice fitting linear models. Reading Read the material on fitting regression models in Statistics online textbook, Diez, Barr, Cetinkaya-

More information

Getting Started in R

Getting Started in R Getting Started in R Giles Hooker May 28, 2007 1 Overview R is a free alternative to Splus: a nice environment for data analysis and graphical exploration. It uses the objectoriented paradigm to implement

More information

Visualisation. Wolfgang Huber

Visualisation. Wolfgang Huber Visualisation Wolfgang Huber Visualisation 1-dim. data: distributions 2-dim. data: scatterplots Overview 3-dim. data: pseudo-3d displays a few more than 2-dim: colours, drill-down, lattice, parallel coordinates

More information

Knitr. Introduction to R for Public Health Researchers

Knitr. Introduction to R for Public Health Researchers Knitr Introduction to R for Public Health Researchers Introduction Exploratory Analysis Plots of bike length Multiple Facets Means by type Linear Models Grabbing coefficients Broom package Testing Nested

More information

arxiv: v1 [stat.ml] 17 Aug 2016

arxiv: v1 [stat.ml] 17 Aug 2016 arxiv:1608.04961v1 [stat.ml] 17 Aug 2016 Clustering Mixed Datasets Using Homogeneity Analysis with Applications to Big Data Rajiv Sambasivan January 13, 2019 Abstract Clustering datasets with a mix of

More information

The lmekin function. Terry Therneau Mayo Clinic. May 11, 2018

The lmekin function. Terry Therneau Mayo Clinic. May 11, 2018 The lmekin function Terry Therneau Mayo Clinic May 11, 2018 1 Background The original kinship library had an implementation of linear mixed effects models using the matrix code found in coxme. Since the

More information

Package reghelper. April 8, 2017

Package reghelper. April 8, 2017 Type Package Title Helper Functions for Regression Analysis Version 0.3.3 Date 2017-04-07 Package reghelper April 8, 2017 A set of functions used to automate commonly used methods in regression analysis.

More information

Stat 5303 (Oehlert): Response Surfaces 1

Stat 5303 (Oehlert): Response Surfaces 1 Stat 5303 (Oehlert): Response Surfaces 1 > data

More information

Recall the expression for the minimum significant difference (w) used in the Tukey fixed-range method for means separation:

Recall the expression for the minimum significant difference (w) used in the Tukey fixed-range method for means separation: Topic 11. Unbalanced Designs [ST&D section 9.6, page 219; chapter 18] 11.1 Definition of missing data Accidents often result in loss of data. Crops are destroyed in some plots, plants and animals die,

More information

Non-Linear Regression. Business Analytics Practice Winter Term 2015/16 Stefan Feuerriegel

Non-Linear Regression. Business Analytics Practice Winter Term 2015/16 Stefan Feuerriegel Non-Linear Regression Business Analytics Practice Winter Term 2015/16 Stefan Feuerriegel Today s Lecture Objectives 1 Understanding the need for non-parametric regressions 2 Familiarizing with two common

More information

Model Selection and Inference

Model Selection and Inference Model Selection and Inference Merlise Clyde January 29, 2017 Last Class Model for brain weight as a function of body weight In the model with both response and predictor log transformed, are dinosaurs

More information

Statistical Analysis of Series of N-of-1 Trials Using R. Artur Araujo

Statistical Analysis of Series of N-of-1 Trials Using R. Artur Araujo Statistical Analysis of Series of N-of-1 Trials Using R Artur Araujo March 2016 Acknowledgements I would like to thank Boehringer Ingelheim GmbH for having paid my tuition fees at the University of Sheffield

More information

Package colf. October 9, 2017

Package colf. October 9, 2017 Type Package Package colf October 9, 2017 Title Constrained Optimization on Linear Function Version 0.1.3 URL https://github.com/lyzander/colf BugReports https://github.com/lyzander/colf/issues Depends

More information

Package dglm. August 24, 2016

Package dglm. August 24, 2016 Version 1.8.3 Date 2015-10-27 Title Double Generalized Linear Models Package dglm August 24, 2016 Author Peter K Dunn and Gordon K Smyth Maintainer Robert Corty

More information

DSCI 325: Handout 24 Introduction to Writing Functions in R Spring 2017

DSCI 325: Handout 24 Introduction to Writing Functions in R Spring 2017 DSCI 325: Handout 24 Introduction to Writing Functions in R Spring 2017 We have already used several existing R functions in previous handouts. For example, consider the Grades dataset. Once the data frame

More information

Package truncreg. R topics documented: August 3, 2016

Package truncreg. R topics documented: August 3, 2016 Package truncreg August 3, 2016 Version 0.2-4 Date 2016-08-03 Title Truncated Gaussian Regression Models Depends R (>= 1.8.0), maxlik Suggests survival Description Estimation of models for truncated Gaussian

More information

file:///users/williams03/a/workshops/2015.march/final/intro_to_r.html

file:///users/williams03/a/workshops/2015.march/final/intro_to_r.html Intro to R R is a functional programming language, which means that most of what one does is apply functions to objects. We will begin with a brief introduction to R objects and how functions work, and

More information

Package PSEA. R topics documented: November 17, Version Date Title Population-Specific Expression Analysis.

Package PSEA. R topics documented: November 17, Version Date Title Population-Specific Expression Analysis. Version 1.16.0 Date 2017-06-09 Title Population-Specific Expression Analysis. Package PSEA November 17, 2018 Author Maintainer Imports Biobase, MASS Suggests BiocStyle Deconvolution of gene expression

More information

STENO Introductory R-Workshop: Loading a Data Set Tommi Suvitaival, Steno Diabetes Center June 11, 2015

STENO Introductory R-Workshop: Loading a Data Set Tommi Suvitaival, Steno Diabetes Center June 11, 2015 STENO Introductory R-Workshop: Loading a Data Set Tommi Suvitaival, tsvv@steno.dk, Steno Diabetes Center June 11, 2015 Contents 1 Introduction 1 2 Recap: Variables 2 3 Data Containers 2 3.1 Vectors................................................

More information

R tutorial. Updated by. Hilda Ibriga, Jincheng Bai and Qi Wang. July Originally created by

R tutorial. Updated by. Hilda Ibriga, Jincheng Bai and Qi Wang. July Originally created by R tutorial Updated by Hilda Ibriga, Jincheng Bai and Qi Wang July 2016 Originally created by Hilda Ibriga, Linna Henry, Patricia Wahyu Haumahu, Qi Wang, Yixuan Qiu and Yuying Song March 2016 Statistical

More information

Package BiDimRegression

Package BiDimRegression Version 2.0.0 Date 2018-05-09 Package BiDimRegression May 16, 2018 Title Calculates the Bidimensional Regression Between Two 2D Configurations Imports Formula, methods Depends R (>= 1.8.0) Calculates the

More information

Package mvprobit. November 2, 2015

Package mvprobit. November 2, 2015 Version 0.1-8 Date 2015-11-02 Title Multivariate Probit Models Package mvprobit November 2, 2015 Author Arne Henningsen Maintainer Arne Henningsen

More information

Orange Juice data. Emanuele Taufer. 4/12/2018 Orange Juice data (1)

Orange Juice data. Emanuele Taufer. 4/12/2018 Orange Juice data (1) Orange Juice data Emanuele Taufer file:///c:/users/emanuele.taufer/google%20drive/2%20corsi/5%20qmma%20-%20mim/0%20labs/l10-oj-data.html#(1) 1/31 Orange Juice Data The data contain weekly sales of refrigerated

More information

Chapitre 2 : modèle linéaire généralisé

Chapitre 2 : modèle linéaire généralisé Chapitre 2 : modèle linéaire généralisé Introduction et jeux de données Avant de commencer Faire pointer R vers votre répertoire setwd("~/dropbox/evry/m1geniomhe/cours/") source(file = "fonction_illustration_logistique.r")

More information

An Introductory Guide to R

An Introductory Guide to R An Introductory Guide to R By Claudia Mahler 1 Contents Installing and Operating R 2 Basics 4 Importing Data 5 Types of Data 6 Basic Operations 8 Selecting and Specifying Data 9 Matrices 11 Simple Statistics

More information

Regression Analysis and Linear Regression Models

Regression Analysis and Linear Regression Models Regression Analysis and Linear Regression Models University of Trento - FBK 2 March, 2015 (UNITN-FBK) Regression Analysis and Linear Regression Models 2 March, 2015 1 / 33 Relationship between numerical

More information

Statistical transformations

Statistical transformations Statistical transformations Next, let s take a look at a bar chart. Bar charts seem simple, but they are interesting because they reveal something subtle about plots. Consider a basic bar chart, as drawn

More information

More data analysis examples

More data analysis examples More data analysis examples R packages used library(ggplot2) library(tidyr) library(mass) library(leaps) library(dplyr) ## ## Attaching package: dplyr ## The following object is masked from package:mass

More information

Functional Programming. Biostatistics

Functional Programming. Biostatistics Functional Programming Biostatistics 140.776 What is Functional Programming? Functional programming concentrates on four constructs: 1. Data (numbers, strings, etc) 2. Variables (function arguments) 3.

More information

Review Stats after TOS Change

Review Stats after TOS Change Review Stats after TOS Change library(knitr) library(ggplot2) library(plotrix) # for pie3d suppressmessages(library(dplyr)) Description of dataset #sum(dfremovals$perc == 100) #dfremovals$perc == 100 df

More information

Introduction to hypothesis testing

Introduction to hypothesis testing Introduction to hypothesis testing Mark Johnson Macquarie University Sydney, Australia February 27, 2017 1 / 38 Outline Introduction Hypothesis tests and confidence intervals Classical hypothesis tests

More information

Section 2.2: Covariance, Correlation, and Least Squares

Section 2.2: Covariance, Correlation, and Least Squares Section 2.2: Covariance, Correlation, and Least Squares Jared S. Murray The University of Texas at Austin McCombs School of Business Suggested reading: OpenIntro Statistics, Chapter 7.1, 7.2 1 A Deeper

More information