foocators
packageCreate a new factor from two existing factors, where the new factor's levels are the union of the levels of the input factors.
Example:
fbind(iris$Species[c(1, 51, 101)], PlantGrowth$group[c(1, 11, 21)])
This function writes frequency table for a factor.
Example:
freq_out(iris$Species)
Computes linear and robust regression coefficients for gapminder excerpt data frame. Description of the linear and robust coeffcients could be found below and also in Homework4-Section2
Example :
fgap_coefs(gapminder::gapminder)
The main body of fgap_coefs
function, includes fitting the linear model regression with lm, followed by getting the estimated coefficients and residuals from the linear model. Also Robust regression coefficients are calculated . The output of the function is a data frame including all the coefficients:
j_fit - Linear regression model fit for life expectancy over year.
j_coef - Coefficients of the Linear model OLS (Ordinary Least Square)method, including intercept and slope .
r_fit: Robust Regression model fit for Life expectancy over year.
r_coef: Robust regression coefficients ,using fitting the robust linear regression model lmrob.
This function takes the gapmider
excerpt data frame and
compares write.table()
and saveRDS()
functions on mini data frame that is the result of the fgap_coefs()
.
Example:
fgap_rw(gapminder::gapminder)
Basically, the steps covered in the fgap_rw()
are as follow:
Applying gfgap_coefs()function to the grouped variables country and continent of gapminder data.
Reorder factor country based on intercept.
define a new variable that holds the original tail end of the data.
Write coefficients in a txt file with write.table().
Output the coefficients in an RDS
format with saveRDS().
Read the jCoefs.txt
file back with read.delim().
Read the jCoefs.rds
file with readRDS()
.
add a new coulmn to countryLevel that's the tail end of the jCoefs.RDS
add a new coulmn to countryLevel that's the tail end of the jCoefs.txt
Compare the two files i.e. 'jCoefs.txt' and jCoefs.RDS
with the original data.
Note : The idea was taken from Jenny's lecture on Getting Data out of R, I basically applied my coefficents ( from fgap_coefs() function ) to test the comparability of these write methods and their affects on Factors in data.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.