Primero cargo el paquete tablas
if (!require("tables")) {
install.packages("tables")
library(tables)
}
## Loading required package: tables
## Loading required package: Hmisc
## Loading required package: grid
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
##
## Attaching package: 'Hmisc'
##
## The following objects are masked from 'package:base':
##
## format.pval, round.POSIXt, trunc.POSIXt, units
library(tables)
iris2 <- iris[ iris$Species != 'versicolor', ]
iris2$Species <- factor(iris2$Species)
P.value <- function(x) t.test(x ~ iris2$Species)$p.value
tmp <- tabular( Petal.Width+Petal.Length + Sepal.Width+Sepal.Length ~ Species* (mean+sd) + P.value, data=iris2 )
tmp
##
## Species
## setosa virginica
## mean sd mean sd P.value
## Petal.Width 0.246 0.1054 2.026 0.2747 2.437e-48
## Petal.Length 1.462 0.1737 5.552 0.5519 9.270e-50
## Sepal.Width 3.428 0.3791 2.974 0.3225 4.571e-09
## Sepal.Length 5.006 0.3525 6.588 0.6359 3.967e-25