Return to Stat Tools Home

Title: Summarize R Macro

Evaluate this tool by clicking on the stars:

%VOTE{id="EvalStatTools" stars1="Tools Overall Rating" stars2="Code Works Well" stars3="Good Instructions" global="off" open="off" secret="off" format="| $key | $small
Score: $score, My vote: $mylast, Total votes: $sum |" }%

Add Comments and then click on "Add comment" button

Please note any errors found in the macros.

%COMMENT%

StatToolsForm edit

Type of Tool R-Function
Title Summarize R Macro
Programmer/Email SallyThurston
Contributing Site Rochester
Description Contains 2 functions: (1) lookup; (2) summarize. Summarize is the primary function

(1) lookup: returns the longname for the relevant part of a vector - point is to be able to work with short name when coding, but be able to use the longname in making plots or tables.

(2) summarize: give nicely formatted summary statistics of all columns in a dataframe. User has option to choose whether this is displayed by longnames (from lookup), what quantiles to show, whether to show results on screen, name of file (if want to save it to a file), and whether the output should be plain text or LaTeX.
Classification Graph Type
References
Datasets
Data
Software Program R
Software R
Macro Parameters For (1) lookup: colname (column name of a dataframe), longnames (vector of longer variable names, where the name of longnames should include colname)

For (2) summarize:
### REQUIRED arguments are:
### tmat = dataframe containing variable for which we want a summary
### OPTIONAL arguments are:
### digits = number of digits to show in the summary
### quants = quantiles to be included. Default is c(0,.25,.5,.75,1)
### If don't want quantiles, make quants=NULL
### latex = TRUE if want output in LaTeX
### full.latex = TRUE if want latex output to be a stand-alone
### LaTeX file. If latex=TRUE and full.latex=FALSE, the
### output can be included with an \include{filename} command.
### (may be useful if output from this function will be
### included as one part of a larger set of function calls.)
### SD = TRUE if want to show SD
### nmis = TRUE if want to show number missing observations
### uniq = TRUE if want to show number of categories
### lookup.names = vector of longer variable names, where column names
### should match variable names in tmat
### filename = name of file where output should be saved
### (default is NULL, not to save it to a file)
### screen = TRUE if want to view results on the screen
### caption = caption for LaTeX format
R-Code - Attachment Rochester_Summarize R_Fuinction
R-Code
SAS-Code - Attachment
SAS-Code
Stata-Code - Attachment
Stata-Code
Other Code - Attachment
Other Code
Called Data Manipulation
Called Tool/Utility
Called Checking Macro
Called Other
Creation-Date
Revision-Date
Example Code R Example Code
Example Output R Example Output
SAS Examples
SAS_Example_Code
SAS_Example_Output
R Examples
R_Example_Code Rochester_Summarize R_R Example Code
R_Example_Output Rochester_Summarize R_R Example Output
Stats Examples
Special Features
Special Features Attached
Special Features Text Examples are given in summarize.example.R. Here is a subset of examples:

## Default settings
summarize(airquality)

## Don't show quantiles, sbut show # missing and # unique values
summarize(airquality,nmis=TRUE,uniq=TRUE)

## Create a table to input into a LaTeX file, using defaults
## NOTE: make screen=FALSE if don't want to also display on screen
summarize(airquality,screen=TRUE,latex=TRUE,caption="Illustration of summarize using air quality data")
Notes1-Legend Section with calls to needed macros
Notes1
Notes2-Legend Macro call with fully specified parameters
Notes2
Notes3-Legend Section with definitions of global macro parameters
Notes3
Notes4-Legend Section with definitions of local macro variables
Notes4
See Also
Checklists
Stat Tools Disclaimer
Discliamer The views expressed within CTSpedia are those of the author and must not be taken to represent policy or guidance on the behalf of any organization or institution with which the author is affiliated.
Permission Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT OLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Reference Image
This topic: CTSpedia > WebHome > StatToolsHome > StatToolsTopic047
Topic revision: 21 Jun 2012, MaryBanach
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback