describe.numeric: Description of numeric variables

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Describes a numeric variable.

Usage

1
2
 describe.numeric(x,varname="",
  num.desc=c("mean","median","var","sd","valid.n"))

Arguments

x

A numeric vector.

varname

The variable name to display.

num.desc

The names of the functions to apply to the vector.

Details

describe.numeric displays the name of the vector and the results of the functions whose names are passed in num.desc. Note that any functions that are called by describe.numeric must have an na.rm argument, even if it is a dummy.

Value

The vector of values returned from the functions in num.desc.

Author(s)

Jim Lemon

See Also

describe, valid.n

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 x<-rnorm(100)
 # include a function that calculates the "smoothness" of a vector
 # of numbers by calculating the mean of the absolute difference
 # between each successive value - all values equal would be 0
 smoothness<-function(x,na.rm=TRUE) {
  if(na.rm) x<-x[!is.na(x)]
  xspan<-diff(range(x))
  return(mean(abs(diff(x))/xspan,na.rm=TRUE))
 }
 describe(x,num.desc=c("mean","median","smoothness"),xname="x")
 # now sort the values to make the vector "smoother"
 describe(sort(x),num.desc=c("mean","median","smoothness"),xname="x")

Example output

Description of x 

 Numeric 
   mean median smoothness
x -0.04   0.03       0.23
Description of x 

 Numeric 
   mean median smoothness
x -0.04   0.03       0.01

prettyR documentation built on May 2, 2019, 2:16 a.m.