Title: | Functions and Datasets for the Book by Keon-Woong Moon |
---|---|
Description: | Several analysis-related functions for the book entitled "R statistics and graph for medical articles" (written in Korean), version 1, by Keon-Woong Moon with Korean demographic data with several plot functions. |
Authors: | Keon-Woong Moon [aut, cre] |
Maintainer: | Keon-Woong Moon <[email protected]> |
License: | GPL-2 |
Version: | 0.3.4 |
Built: | 2025-02-21 03:29:59 UTC |
Source: | https://github.com/cardiomoon/moonbook |
A dataset containing demographic data and laboratory data of 857 patients with acute coronary syndrome(ACS).
A data frame with 857 rows and 17 variables:
patient age in years
"Male" or "Female"
"No" or "Yes"
vascular access route, either "Femoral" or "Radial"
Final diagnosis, One of the followings : STEMI, NSTEMI or Unstable Angina
ejection fraction, percentage by echocardiography
height in centimeter
weight in kilogram
body mass index in kg/m2
obesity, "No" or "Yes"
total cholesterol level in mg/dL
low density lipoprotein cholesterol level in mg/dL
high density lipoprotein cholesterol level in mg/dL
triglyceride level in mg/dL
history of diabetes mellitus,"No" or "Yes"
history of hypertension,"No" or "Yes"
history of smoking, One of the followings : "Never","Ex-smoker","Smoker"
Change numbers into formatted numbers
addComma(x) ## S3 method for class 'mytable' addComma(x) ## S3 method for class 'mytable.df' addComma(x) ## S3 method for class 'cbind.mytable' addComma(x) ## S3 method for class 'data.frame' addComma(x) ## S3 method for class 'character' addComma(x)
addComma(x) ## S3 method for class 'mytable' addComma(x) ## S3 method for class 'mytable.df' addComma(x) ## S3 method for class 'cbind.mytable' addComma(x) ## S3 method for class 'data.frame' addComma(x) ## S3 method for class 'character' addComma(x)
x |
An object |
addComma(mytable)
: S3 method for class mytable
addComma(mytable.df)
: S3 method for class mytable.df
addComma(cbind.mytable)
: S3 method for class cbind.mytable
addComma(data.frame)
: S3 method for class data.frame
addComma(character)
: S3 method for class character
## Not run: require(stringr) require(magrittr) require(ggplot2) mytable(cut~.,data=diamonds) %>% addComma x=mytable(Dx~sex,data=acs) addComma(x) ## End(Not run)
## Not run: require(stringr) require(magrittr) require(ggplot2) mytable(cut~.,data=diamonds) %>% addComma x=mytable(Dx~sex,data=acs) addComma(x) ## End(Not run)
Add value labels to the data.frame
addLabelDf(data, mapping = NULL)
addLabelDf(data, mapping = NULL)
data |
A data.frame |
mapping |
Set of aesthetic mappings created by aes or aes_. |
Perform chisq.test or fisher test
cat.test(x, mode = 1, ...)
cat.test(x, mode = 1, ...)
x |
a numeric vector or matrix. x and y can also both be factors. |
mode |
An integer. If 1(default), perform chisq.test first, If 2, perform fisher.test first |
... |
Further arguments to be passed to chisq.test or fisher.test |
cbind function for class "mytable"
## S3 method for class 'mytable' cbind(..., caption, y = NULL)
## S3 method for class 'mytable' cbind(..., caption, y = NULL)
... |
Objects of class "mytable", a result of a call to |
caption |
Unique values of grouping variables used for column name of table |
y |
Names of grouping variables used for caption of table |
Internal mytable functions These are not to be called by the user
centerprint(x, ..., width = 10)
centerprint(x, ..., width = 10)
x |
a character vector |
... |
further arguments passed to or from other methods. |
width |
an integer |
Change column names with labels
changeColnameLabel(data)
changeColnameLabel(data)
data |
A data.frame |
Convert number to formatted number
comma(x, ...)
comma(x, ...)
x |
A numeric vector |
... |
Further arguments to be passed to function format |
Make complete table
completeTable(y, x, data, origData)
completeTable(y, x, data, origData)
y |
character Another name of column |
x |
character A name of column |
data |
A data.frame with some limited data |
origData |
A data.frame with full data |
a table
Compress an object of class mytable or cbind.mytable
compress(x, no = 2, add.label = TRUE) ## S3 method for class 'mytable' compress(x, no = 2, add.label = TRUE) ## S3 method for class 'cbind.mytable' compress(x, no = 2, add.label = TRUE) ## S3 method for class 'data.frame' compress(x, no = 2, add.label = TRUE)
compress(x, no = 2, add.label = TRUE) ## S3 method for class 'mytable' compress(x, no = 2, add.label = TRUE) ## S3 method for class 'cbind.mytable' compress(x, no = 2, add.label = TRUE) ## S3 method for class 'data.frame' compress(x, no = 2, add.label = TRUE)
x |
An object of class mytable or cbind.mytable |
no |
Representative group of two groups |
add.label |
Logical. Whether or not add representative group name |
compress(mytable)
: S3 method for class mytable
compress(cbind.mytable)
: S3 method for class cbind.mytable
compress(data.frame)
: S3 method for class data.frame
require(stringr) require(magrittr) mytable(acs) %>% compress mytable(Dx~.,data=acs) %>% compress ## Not run: require(ztable) mytable(Dx~.,data=acs) %>% compress %>% ztable mytable(Dx+sex~.,data=acs) %>% compress ## End(Not run)
require(stringr) require(magrittr) mytable(acs) %>% compress mytable(Dx~.,data=acs) %>% compress ## Not run: require(ztable) mytable(Dx~.,data=acs) %>% compress %>% ztable mytable(Dx+sex~.,data=acs) %>% compress ## End(Not run)
Delete rows of class mytable object
deleteRows(x, rows)
deleteRows(x, rows)
x |
An object of class mytable or cbind.mytable |
rows |
rows to delete |
Make Kernel density plot
densityplot(formula, data, main = "", xlab = "", ylab = "", ...)
densityplot(formula, data, main = "", xlab = "", ylab = "", ...)
formula |
an R model formula, of the form ~ variable to estimate the unconditional density of variable, or variable ~ factor to estimate the density of variable within each level of factor. |
data |
an optional data frame containing the data. |
main |
main title of plot |
xlab |
label for the horizontal-axis; defaults to the name of the variable x. |
ylab |
label for the vertical axis; defaults to "Density". |
... |
arguments to be passed to plot |
This function return NULL invisibly and draw graphs.
require(moonBook) data(acs) densityplot(age~Dx,data=acs)
require(moonBook) data(acs) densityplot(age~Dx,data=acs)
Extract hazard ratio from a data.frame
extractHR(x, digits = 2)
extractHR(x, digits = 2)
x |
an object of class coxph |
digits |
An integer indicating the number of decimal places (round) or significant digits to be used. Default value is 2. |
a data.frame consist of hazard ratio and 95 the p values.
require(survival) data(cancer) fit=coxph(Surv(time,status)~age+sex+obstruct+perfor,data=colon) extractHR(fit)
require(survival) data(cancer) fit=coxph(Surv(time,status)~age+sex+obstruct+perfor,data=colon) extractHR(fit)
Extract kind of an object of class mytable
extractKind(df)
extractKind(df)
df |
An object of class mytable or cbind.mytable |
Extract the odds ratios from a S3 object of glm
extractOR(x, digits = 2, method = "default")
extractOR(x, digits = 2, method = "default")
x |
A S3 object of glm |
digits |
An integer indicating the number of decimal places (round) or significant digits to be used. Default value is 2. |
method |
Method to compute confidence interval. Choices are one of c("default","LRT"). |
A data.frame consist of odds ratios and 95 p values
data(cancer,package="survival") x=glm(status~rx+sex+age+obstruct+nodes,data=colon,family="binomial") extractOR(x)
data(cancer,package="survival") x=glm(status~rx+sex+age+obstruct+nodes,data=colon,family="binomial") extractOR(x)
Add column labels to the data.frame
getLabel(data, colname, use.column.label = TRUE)
getLabel(data, colname, use.column.label = TRUE)
data |
A data.frame |
colname |
character. column name |
use.column.label |
Logical. Whether or not use column labels. |
extract variable name from mapping, aes
getMapping(mapping, varname)
getMapping(mapping, varname)
mapping |
aesthetic mapping |
varname |
variable name to extract |
variable name in character
require(ggplot2) mapping=aes(colour=sex) getMapping(mapping,"colour") getMapping(mapping,"x")
require(ggplot2) mapping=aes(colour=sex) getMapping(mapping,"colour") getMapping(mapping,"x")
Draw a hazard ratio plot
HRplot( out, type = 1, xlab = "", ylab = "", show.OR = TRUE, show.CI = FALSE, sig.level = 1, cex = 1.2, lwd = 2, pch = 18, col = NULL, ... )
HRplot( out, type = 1, xlab = "", ylab = "", show.OR = TRUE, show.CI = FALSE, sig.level = 1, cex = 1.2, lwd = 2, pch = 18, col = NULL, ... )
out |
an object of class coxph or a resultant data.frame of mycph function |
type |
an integer indicating the type of plot. Default value is 1 |
xlab |
a title for the x axis |
ylab |
a title for the y axis |
show.OR |
a logical vector indicating whether or not show the text indicating the p value |
show.CI |
a logical vector indicating whether or not show the text indicating the confidence interval |
sig.level |
a numeric value of upper limit of p value of showing variables |
cex |
A numerical value giving the amount by which plotting OR/HR symbols should be magnified relative to the default, defaulting 1.2. |
lwd |
The line width, a positive number, defaulting to 2. |
pch |
Either an integer specifying a symbol or a single character to be used as the default in plotting OR/HR points. |
col |
A specification for the default plotting color. |
... |
arguments to be passed to plot |
This function return NULL invisibly and draw graphs
require(survival) attach(colon) colon$TS=Surv(time,status==1) out=mycph(TS~.,data=colon) out HRplot(out) ## Not run: HRplot(out,type=1,pch=2,col=c("blue","red")) HRplot(out,type=2,show.CI=TRUE,pch=2,cex=2,main="Hazard ratios of all individual variables") ## End(Not run)
require(survival) attach(colon) colon$TS=Surv(time,status==1) out=mycph(TS~.,data=colon) out HRplot(out) ## Not run: HRplot(out,type=1,pch=2,col=c("blue","red")) HRplot(out,type=2,show.CI=TRUE,pch=2,cex=2,main="Hazard ratios of all individual variables") ## End(Not run)
Internal mytable functions These are not to be called by the user
my.chisq.test(x, y, mydata, catMethod = 2)
my.chisq.test(x, y, mydata, catMethod = 2)
x |
a vector |
y |
a vector |
mydata |
A data.frame |
catMethod |
An integer indicating methods for categorical variables. Possible values in methods are
Default value is 2. |
Internal mytable functions These are not to be called by the user
my.t.test(y, x)
my.t.test(y, x)
y |
a vector |
x |
a numeric vector |
Perform coxph of individual expecting variables
mycph(formula, data, digits = 2)
mycph(formula, data, digits = 2)
formula |
An object of class "formula". Left side of ~ must be a variable of class Surv and the right side of ~ must have variables in an additive way. |
data |
A data.frame contains data for analysis. |
digits |
An integer indicating the number of decimal places (round) or significant digits to be used. Default value is 2. |
a data.frame consist of hazard ratio and 95% confidence intervals and the p values.
require(survival) data(cancer) attach(colon) colon$TS=Surv(time,status==1) out=mycph(TS~.,data=colon) out HRplot(out,type=2,show.CI=TRUE,main="Hazard ratios of all individual variables")
require(survival) data(cancer) attach(colon) colon$TS=Surv(time,status==1) out=mycph(TS~.,data=colon) out HRplot(out,type=2,show.CI=TRUE,main="Hazard ratios of all individual variables")
Export to csv file for class "mytable" or "cbind.mytable"
mycsv(x, row.names = FALSE, ...)
mycsv(x, row.names = FALSE, ...)
x |
An object of class "mytable" or "cbind.mytable" |
row.names |
either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written. |
... |
further arguments passed to or from other methods. |
## Not run: require(moonBook) res=mytable(sex~age+DM,data=acs) mycsv(res,file="test.csv") mycsv(summary(res),file="testsummary.csv") ## End(Not run)
## Not run: require(moonBook) res=mytable(sex~age+DM,data=acs) mycsv(res,file="test.csv") mycsv(summary(res),file="testsummary.csv") ## End(Not run)
Export to csv file for class "cbind.mytable"
## S3 method for class 'cbind.mytable' mycsv(x, row.names = FALSE, ...)
## S3 method for class 'cbind.mytable' mycsv(x, row.names = FALSE, ...)
x |
An object of class "cbind.mytable" a result of a call to |
row.names |
either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written. |
... |
further arguments passed to or from other methods. |
## Not run: require(moonBook) res1=mytable(sex+Dx~age+DM,data=acs) mycsv(res1,file="test1.csv") mycsv(summary(res1),file="testsummary1.csv") ## End(Not run)
## Not run: require(moonBook) res1=mytable(sex+Dx~age+DM,data=acs) mycsv(res1,file="test1.csv") mycsv(summary(res1),file="testsummary1.csv") ## End(Not run)
Export to csv file for class "mytable"
## S3 method for class 'mytable' mycsv(x, row.names = FALSE, ...)
## S3 method for class 'mytable' mycsv(x, row.names = FALSE, ...)
x |
An object of class "mytable" a result of a call to |
row.names |
either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written. |
... |
further arguments passed to or from other methods. |
## Not run: require(moonBook) res=mytable(sex~age+DM,data=acs) mycsv(res,file="test.csv") mycsv(summary(res),file="testsummary.csv") ## End(Not run)
## Not run: require(moonBook) res=mytable(sex~age+DM,data=acs) mycsv(res,file="test.csv") mycsv(summary(res),file="testsummary.csv") ## End(Not run)
Export to csv file for class "mytable.df"
## S3 method for class 'mytable.df' mycsv(x, row.names = FALSE, ...)
## S3 method for class 'mytable.df' mycsv(x, row.names = FALSE, ...)
x |
An object of class "mytable.df" a result of a call to |
row.names |
either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written. |
... |
further arguments passed to or from other methods. |
## Not run: require(moonBook) res=mytable(acs) mycsv(res,file="test.csv") ## End(Not run)
## Not run: require(moonBook) res=mytable(acs) mycsv(res,file="test.csv") ## End(Not run)
Export to html file for class "mytable" or "cbind.mytable" of "data.frame"
myhtml(x, caption = NULL, rownames = TRUE) ## Default S3 method: myhtml(x, caption = NULL, rownames = TRUE) ## S3 method for class 'mytable' myhtml(x, caption = NULL, rownames = TRUE) ## S3 method for class 'cbind.mytable' myhtml(x, caption = NULL, rownames = TRUE)
myhtml(x, caption = NULL, rownames = TRUE) ## Default S3 method: myhtml(x, caption = NULL, rownames = TRUE) ## S3 method for class 'mytable' myhtml(x, caption = NULL, rownames = TRUE) ## S3 method for class 'cbind.mytable' myhtml(x, caption = NULL, rownames = TRUE)
x |
An object of class "mytable" or "cbind.mytable" |
caption |
A character |
rownames |
A logical value whether or not include rownames in table |
myhtml(default)
:
myhtml(mytable)
:
myhtml(cbind.mytable)
:
require(moonBook) res=mytable(sex~age+Dx,data=acs) myhtml(res) res1=mytable(sex+Dx~.,data=acs) myhtml(res1) x=head(iris) myhtml(x) myhtml(x,caption="Table 1. myhtml Test") myhtml(x,caption="Table 1. myhtml Test",rownames=FALSE)
require(moonBook) res=mytable(sex~age+Dx,data=acs) myhtml(res) res1=mytable(sex+Dx~.,data=acs) myhtml(res1) x=head(iris) myhtml(x) myhtml(x,caption="Table 1. myhtml Test") myhtml(x,caption="Table 1. myhtml Test",rownames=FALSE)
Exporting "cbind.mytable","mytable" to LaTeX format
mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" ) ## Default S3 method: mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" ) ## S3 method for class 'mytable' mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" ) ## S3 method for class 'cbind.mytable' mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" )
mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" ) ## Default S3 method: mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" ) ## S3 method for class 'mytable' mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" ) ## S3 method for class 'cbind.mytable' mylatex( myobj, size = 5, caption = NULL, caption.placement = "top", caption.position = "c" )
myobj |
An object of class 'mytable' |
size |
An integer indicating font size, defaulting is 5. |
caption |
A character |
caption.placement |
The caption will be have placed at the top of the table if caption.placement is "top" and at the bottom of the table if it equals "bottom". Default value is "top". |
caption.position |
The caption will be have placed at the center of the table if caption.position is "center" or "c", and at the left side of the table if it equals "left" or "l", and at the right side of the table if it equals "right" or "r". Default value is "center". |
mylatex(default)
: Exporting "cbind.mytable","mytable" to LaTeX format
mylatex(mytable)
: Exporting "cbind.mytable","mytable" to LaTeX format
mylatex(cbind.mytable)
: Exporting "cbind.mytable","mytable" to LaTeX format
require(moonBook) out=mytable(sex~.,data=acs) mylatex(out) out1=mytable(sex+Dx~.,data=acs) mylatex(out1,size=6)
require(moonBook) out=mytable(sex~.,data=acs) mylatex(out) out1=mytable(sex+Dx~.,data=acs) mylatex(out1,size=6)
Produce table for descriptive statistics by groups for several variables easily. Depending on the nature of these variables, different descriptive statistical methods were used(t-test, ANOVA,Kruskal-Wallis, chisq, Fisher,...)
mytable(x, ...) ## S3 method for class 'formula' mytable(x, ...) ## S3 method for class 'data.frame' mytable(x, ...)
mytable(x, ...) ## S3 method for class 'formula' mytable(x, ...) ## S3 method for class 'data.frame' mytable(x, ...)
x |
An R object, formula or data.frame |
... |
arguments to be passed to |
mytable(formula)
: S3 method for formula
mytable(data.frame)
: S3 method for data.frame
mytable(acs) mytable(~age+sex,data=acs) mytable(Dx~age+sex+height+weight+TC+TG+HDLC,data=acs,method=3,digits=2) mytable(am+cyl~.,data=mtcars) out=mytable(sex~.,data=acs) out summary(out) ## Not run: require(ztable) ztable(out) ## End(Not run) mytable(acs)
mytable(acs) mytable(~age+sex,data=acs) mytable(Dx~age+sex+height+weight+TC+TG+HDLC,data=acs,method=3,digits=2) mytable(am+cyl~.,data=mtcars) out=mytable(sex~.,data=acs) out summary(out) ## Not run: require(ztable) ztable(out) ## End(Not run) mytable(acs)
make mytable from data.frame
mytable_df( x, use.labels = TRUE, use.column.label = TRUE, max.ylev = 5, maxCatLevel = 20, digits = 1, method = 1, useSE = FALSE, show.all = FALSE )
mytable_df( x, use.labels = TRUE, use.column.label = TRUE, max.ylev = 5, maxCatLevel = 20, digits = 1, method = 1, useSE = FALSE, show.all = FALSE )
x |
A data.frame |
use.labels |
Logical. Whether or not use labels. |
use.column.label |
Logical. Whether or not use column labels. |
max.ylev |
An integer indicating the maximum number of levels of grouping variable. If a column have unique values less than max.ylev it is treated as a categorical variable. Default value is 5. |
maxCatLevel |
An integer indicating the maximum number of unique levels of categorical variable. If a column have unique values more than maxCatLevel, categorical summarization will not be performed. |
digits |
An integer indicating the number of decimal places (round) or significant digits to be used. Default value is 1. |
method |
An integer indicating methods for continuous variables. Possible values in methods are
Default value is 1. |
useSE |
logical If true, use standard error instead of standard deviation |
show.all |
A logical value indicating whether or not all statistical values have to be shown in table. Default value is FALSE. |
An object of class "mytable.df". 'print' returns a table for descriptive statistics.
Produce table for descriptive statistics by groups for several variables easily. Depending on the nature of these variables, different descriptive statistical methods were used(t-test, ANOVA,Kruskal-Wallis, chisq, Fisher,...)
mytable_sub( x, data, use.labels = TRUE, use.column.label = TRUE, max.ylev = 5, maxCatLevel = 20, digits = 1, method = 1, useSE = FALSE, catMethod = 2, show.all = FALSE, exact = FALSE, show.total = FALSE, missing = FALSE, clean_names = FALSE )
mytable_sub( x, data, use.labels = TRUE, use.column.label = TRUE, max.ylev = 5, maxCatLevel = 20, digits = 1, method = 1, useSE = FALSE, catMethod = 2, show.all = FALSE, exact = FALSE, show.total = FALSE, missing = FALSE, clean_names = FALSE )
x |
An object of class "formula". Left side of ~ must contain the name of one grouping variable or two grouping variables in an additive way(e.g. sex+group~), and the right side of ~ must have variables in an additive way. |
data |
A data.frame contains data for analysis |
use.labels |
Logical. Whether or not use labels. |
use.column.label |
Logical. Whether or not use column labels. |
max.ylev |
An integer indicating the maximum number of levels of grouping variable ('y'). If a column have unique values less than max.ylev it is treated as a categorical variable. Default value is 5. |
maxCatLevel |
An integer indicating the maximum number of unique levels of categorical variable. If a column have unique values more than maxCatLevel, categorical summarization will not be performed. |
digits |
An integer indicating the number of decimal places (round) or significant digits to be used. Default value is 1. |
method |
An integer indicating methods for continuous variables. Possible values in methods are
Default value is 1. |
useSE |
logical If true, use standard error instead of standard deviation |
catMethod |
An integer indicating methods for categorical variables. Possible values in methods are
Default value is 2. |
show.all |
A logical value indicating whether or not all statistical values have to be shown in table. Default value is FALSE. |
exact |
A logical value indicating whether or not permit call with approximate parameter. If true, only exact column name permitted.Default value is FALSE. |
show.total |
A logical value indicating whether or not show total group value. Default value is FALSE. |
missing |
A logical value indicating whether or not perform missing data analysis. Default value is FALSE. |
clean_names |
A logical value indicating whether or not clean names of data using janitor::make_clean_names. Default value is FALSE. |
An object of class "mytable". 'print' returns a table for descriptive statistics. 'summary' returns a table with all statistical values.
Internal mytable functions These are not to be called by the user
mytable_sub2( y, x, data, max.ylev = 5, maxCatLevel = 20, method = 1, useSE = FALSE, catMethod = 2, show.total = FALSE, origData )
mytable_sub2( y, x, data, max.ylev = 5, maxCatLevel = 20, method = 1, useSE = FALSE, catMethod = 2, show.total = FALSE, origData )
y |
a vector |
x |
a vector |
data |
a data.frame |
max.ylev |
an integer |
maxCatLevel |
an integer |
method |
an integer |
useSE |
logical |
catMethod |
an integer |
show.total |
a logical value |
origData |
a data.frame |
Produce table for descriptive statistics by two grouping variables for several variables easily. Depending on the nature of these variables, different descriptive statistical methods were used(t-test, ANOVA,Kruskal-Wallis, chisq, Fisher,...)
mytable2( formula, data, use.labels = TRUE, use.column.label = TRUE, max.ylev = 5, maxCatLevel = 20, digits = 2, method = 1, useSE = FALSE, catMethod = 2, show.all = FALSE, exact = FALSE, show.total = FALSE, origData = NULL )
mytable2( formula, data, use.labels = TRUE, use.column.label = TRUE, max.ylev = 5, maxCatLevel = 20, digits = 2, method = 1, useSE = FALSE, catMethod = 2, show.all = FALSE, exact = FALSE, show.total = FALSE, origData = NULL )
formula |
An object of class "formula". Left side of ~ must contain two grouping variables in an additive way(e.g. sex+group~), and the right side of ~ must have variables in an additive way. |
data |
A data.frame contains data for analysis |
use.labels |
Logical. Whether or not use labels. |
use.column.label |
Logical. Whether or not use column labels. |
max.ylev |
An integer indicating the maximum number of levels of grouping variable ('y'). If a column have unique values less than max.ylev it is treated as a categorical variable. Default value is 5. |
maxCatLevel |
An integer indicating the maximum number of unique levels of categorical variable. If a column have unique values more than maxCatLevel, categorical summarization will not be performed. |
digits |
An integer indicating the number of decimal places (round) or significant digits to be used. Default value is 1. |
method |
An integer indicating methods for continuous variables. Possible values in methods are
Default value is 1. |
useSE |
logical If true, use standard error instead of standard deviation |
catMethod |
An integer indicating methods for categorical variables. Possible values in methods are
Default value is 2. |
show.all |
A logical value indicating whether or not all statistical values have to be shown in table. Default value is FALSE. |
exact |
A logical value indicating whether or not permit call with approximate parameter. If true, only exact column name permitted.Default value is FALSE. |
show.total |
A logical value indicating whether or not show total group value. Default value is FALSE. |
origData |
A data.frame contains data for analysis |
An object of class "cbind.mytable"
Add N number into data.frame
mytable2df(x)
mytable2df(x)
x |
An object of class "mytable" a result of a call to |
a data.frame with N number
Add N number into data.frame
mytable2html(x)
mytable2html(x)
x |
An object of class "mytable" a result of a call to |
a data.frame with N number
Internal mytable functions These are not to be called by the user
num_summary(x)
num_summary(x)
x |
a numeric vector |
Internal mytable functions These are not to be called by the user
obj2linecount(myobj)
obj2linecount(myobj)
myobj |
an R object |
Plot for odds ratios for a S3 object of glm
ORplot( x, type = 1, xlab = "", ylab = "", show.OR = TRUE, show.CI = FALSE, sig.level = 1, cex = 1.2, lwd = 2, pch = 18, col = NULL, ... )
ORplot( x, type = 1, xlab = "", ylab = "", show.OR = TRUE, show.CI = FALSE, sig.level = 1, cex = 1.2, lwd = 2, pch = 18, col = NULL, ... )
x |
A S3 object of glm |
type |
an integer defining the shape of plots; default value is 1 |
xlab |
label for the horizontal-axis; defaults to "Odds Ratios" |
ylab |
label for the vertical axis; defaults to "". |
show.OR |
A logical value; Whether or not show p values on plot |
show.CI |
A logical value; Whether or not show 95% CI values on plot |
sig.level |
A numeric value of upper limit of p value of showing variables |
cex |
A numerical value giving the amount by which plotting OR/HR symbols should be magnified relative to the default, defaulting 1.2. |
lwd |
The line width, a positive number, defaulting to 2. |
pch |
Either an integer specifying a symbol or a single character to be used as the default in plotting OR/HR points. |
col |
A specification for the default plotting color. |
... |
arguments to be passed to plot |
This function return NULL invisibly and draw graphs
require(survival) data(colon) out1=glm(status~sex+age+rx+obstruct+node4,data=colon) out2=glm(status~rx+node4,data=colon) ORplot(out1,type=2,show.CI=TRUE,xlab="This is xlab",main="Main Title") ORplot(out2,type=1,main="Main Title") ORplot(out1,type=2,show.CI=TRUE,main="Main Title") ORplot(out1,type=3,show.CI=TRUE,main="Main Title",sig.level=0.05) ORplot(out1,type=3,show.CI=TRUE,main="Main Title",sig.level=0.05, pch=1,cex=2,lwd=4,col=c("red","blue"))
require(survival) data(colon) out1=glm(status~sex+age+rx+obstruct+node4,data=colon) out2=glm(status~rx+node4,data=colon) ORplot(out1,type=2,show.CI=TRUE,xlab="This is xlab",main="Main Title") ORplot(out2,type=1,main="Main Title") ORplot(out1,type=2,show.CI=TRUE,main="Main Title") ORplot(out1,type=3,show.CI=TRUE,main="Main Title",sig.level=0.05) ORplot(out1,type=3,show.CI=TRUE,main="Main Title",sig.level=0.05, pch=1,cex=2,lwd=4,col=c("red","blue"))
Plot for odds ratios for a S3 object of glm
ORplot.sub( result, type = 1, xlab = "", ylab = "", show.OR = TRUE, show.CI = FALSE, sig.level = 1, cex = 1.2, lwd = 2, pch = 18, col = NULL, ... )
ORplot.sub( result, type = 1, xlab = "", ylab = "", show.OR = TRUE, show.CI = FALSE, sig.level = 1, cex = 1.2, lwd = 2, pch = 18, col = NULL, ... )
result |
A resultant data.frame of function extractOR |
type |
an integer defining the shape of plots; default value is 1 |
xlab |
label for the horizontal-axis; defaults to "Odds Ratios" |
ylab |
label for the vertical axis; defaults to "". |
show.OR |
A logical value; Whether or not show p values on plot |
show.CI |
A logical value; Whether or not show 95% CI values on plot |
sig.level |
A numeric value of upper limit of p value of showing variables |
cex |
A numerical value giving the amount by which plotting OR/HR symbols should be magnified relative to the default, defaulting 1.2. |
lwd |
The line width, a positive number, defaulting to 2. |
pch |
Either an integer specifying a symbol or a single character to be used as the default in plotting OR/HR points. |
col |
A specification for the default plotting color. |
... |
Further arguments to be passed to plot |
This function return NULL invisibly and draw graphs
Internal mytable functions These are not to be called by the user
p2sig(value)
p2sig(value)
value |
a numeric vector |
Print function for class "cbind.mytable"
## S3 method for class 'cbind.mytable' print(x, ...)
## S3 method for class 'cbind.mytable' print(x, ...)
x |
an object of class "cbind.mytable", a result of a call to |
... |
further arguments passed to or from other methods. |
Print function for class "mytable"
## S3 method for class 'mytable' print(x, ...)
## S3 method for class 'mytable' print(x, ...)
x |
An object of class "mytable", a result of a call to |
... |
further arguments passed to or from other methods. |
Print an object of mytable.df
## S3 method for class 'mytable.df' print(x, ...)
## S3 method for class 'mytable.df' print(x, ...)
x |
An object of class mytable.df |
... |
Further arguments |
Internal mytable functions These are not to be called by the user
printmytable2(obj, digits = 1, useSE = FALSE)
printmytable2(obj, digits = 1, useSE = FALSE)
obj |
an object |
digits |
an integer |
useSE |
logical |
Subfunction used in mylatex
r(string)
r(string)
string |
a character vector |
A dataset containing demographic data and laboratory data of 115 patients performing IVUS(intravascular ultrasound) examination of a radial artery after tansradial coronary angiography.
A data frame with 115 rows and 15 variables:
if Male, 1; if Female 0
patient age in years
height in centimeter
weight in kilogram
history of hypertension, 1 for yes or 0 for no
history of diabetes mellitus, 1 for yes or 0 for no
history of smoking, One of the followings : "non-smoker","ex-smoker","smoker"
total cholesterol level in mg/dL
triglyceride level in mg/dL
high density lipoprotein cholesterol level in mg/dL
low density lipoprotein cholesterol level in mg/dL
high-sensitive C reactive protein
normalized total atheroma volume measured by IVUS in cubic mm
percent atheroma volume in percentage
Factor with two levels; "Male" or "Female"
rank a numeric vector and returns a new ordinal vector
rank2group(y, k = 4)
rank2group(y, k = 4)
y |
a numeric vector |
k |
a integer specifies how many groups you want to classify. default value is 4 |
a ordinal vector(numeric) with the same length of y
require(ggplot2) data(diamonds) diamonds$PriceGroup=rank2group(diamonds$price,4) table(diamonds$PriceGroup) aggregate(price~PriceGroup,data=diamonds,range) diamonds$PriceGroup3=rank2group(diamonds$price,3) table(diamonds$PriceGroup3) aggregate(price~PriceGroup3,data=diamonds,range) diamonds$PriceGroup5=rank2group(diamonds$price,5) table(diamonds$PriceGroup5) aggregate(price~PriceGroup5,data=diamonds,range)
require(ggplot2) data(diamonds) diamonds$PriceGroup=rank2group(diamonds$price,4) table(diamonds$PriceGroup) aggregate(price~PriceGroup,data=diamonds,range) diamonds$PriceGroup3=rank2group(diamonds$price,3) table(diamonds$PriceGroup3) aggregate(price~PriceGroup3,data=diamonds,range) diamonds$PriceGroup5=rank2group(diamonds$price,5) table(diamonds$PriceGroup5) aggregate(price~PriceGroup5,data=diamonds,range)
Internal mytable functions These are not to be called by the user
reprint(x, times)
reprint(x, times)
x |
a character vector |
times |
an integer |
Internal mytable functions These are not to be called by the user
space(num)
space(num)
num |
an integer |
calculate stendard error
std.error(x, na.rm = FALSE)
std.error(x, na.rm = FALSE)
x |
a numeric vector |
na.rm |
logical |
x=c(179,160,136,227,123,23,45,67,1,234) std.error(x)
x=c(179,160,136,227,123,23,45,67,1,234) std.error(x)
Summarizing function for class "cbind.mytable"
## S3 method for class 'cbind.mytable' summary(object, ...)
## S3 method for class 'cbind.mytable' summary(object, ...)
object |
An object of class "cbind.mytable", a result of a call |
... |
further arguments passed to or from other methods. |
out=mytable(am+cyl~.,data=mtcars) summary(out)
out=mytable(am+cyl~.,data=mtcars) summary(out)
Summarizing function for class "mytable"
## S3 method for class 'mytable' summary(object, ...)
## S3 method for class 'mytable' summary(object, ...)
object |
An object of class "mytable", a result of a call |
... |
further arguments passed to or from other methods. |
out=mytable(am~.,data=mtcars) summary(out)
out=mytable(am~.,data=mtcars) summary(out)
Find valid string among character vector from approximate string
validColname(pattern, x)
validColname(pattern, x)
pattern |
character string to be matched in the given character |
x |
a character vector where matches are sought |
returns NA in case of no matched string found or a character string in string vector x
a="dx" b=c("Age","Sex","Dx") validColname(a,b)
a="dx" b=c("Age","Sex","Dx") validColname(a,b)