How it works...

Step 1 shows some functions for tidying an lm object with the lm() function. The first step is to create the object. Here, we perform a multiple regression model using the mtcars data. We then use the tidy() function on the model to return the object summary of components of the model, for example, the coefficient, as a tidy dataframe. The augment() function returns extra per-observation data for an lm object should we want that—again, it's in tidy format. The glance() function inspects the model itself and returns summaries about itnaturally, in tidy format. glance() is useful for comparing models.

Step 2 shows the same process for the t.test object. First, we run a t-test on two vectors of random numbers. The tidy() function gives us all of the details in a tidy dataframe.

In Step 3, we run an ANOVA on the iris data. We use the aov() function to look at the effect of Species on Petal.Length. We can use tidy() again on the result but it gives a summary of the components of the model. In fact, we're probably more interested in the comparisons from a post-hoc test, which is performed using the TukeyHSD() function on the next line; it too can be used in tidy().

In Step 4, we use the biobroom version of tidy() on the ExpressionSet object. This turns the square matrix of expression values into a tidy dataframe along with columns for sample and other types of data. The extra argument, addPheno, is specific to this type of object and inserts the phenotype metadata from the ExpressionSet metadata container. Note that the resulting dataframe is over 2 million lines long—biological datasets can be large and can generate very large dataframes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.206.91