Hi Silvano
I cannot use the data and function as the data is not available to me
for the xtable part using data from xtable try as an example to see if it
fits your needs
data(tli)
head(tli)
for(j in 1:5){ xx <- xtable(tli[1:6,]); caption(xx) <-
paste("Table", j);
print(xx); if(j < 5) cat("\n\n")}
You can amend the xtable part to suit -- the cat command gives some spacing
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
Behalf Of Silvano Cesar da Costa
Sent: Thursday, 9 January 2014 04:24
To: r-help at r-project.org
Subject: [R] Function inside Sweave
Hi,
I have a data set involving 25 Questions (Q1, Q2, ... , Q25), 100 Disciplina
and 5 series. The variables are:
ALUNO DISCIPLINA SERIE TURMA Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 ... Q25
I want to create tables associating each of the 25 questions to the
Disciplina.
Something like:
tab1 = table(DISCIPLINA, Q1)
tab1.prop = round(100*prop.table(tab1, 1), 2) tab1.txt = xtable(tab1.prop,
align="l|rrrrr", label='Q1', caption=c("Apresenta??o da
proposta de programa
a ser desenvolvida na disciplina", "Q1")) print(tab1.txt,
format.args=list(big.mark = ".", decimal.mark = ","),
caption.placement='top', table.placement='H')
With the help of a friend, was created the following function:
require(xtable)
DISCIPLINA <- rep(c("A", "B", "C",
"D", "E"), 5) for (i in 1:25){
aux <- paste("Q", i, sep="")
assign(aux, sample(rep(seq(1:5),5)))
}
cria.tabela <- function(Questao){
Questao1 <- get(Questao)
tab1 <- table(DISCIPLINA, Questao1)
tab1.prop = round(100*prop.table(tab1, 1), 2)
tab1.txt = xtable(tab1.prop, align="l|rrrrr", label=Questao,
caption=paste(Questao))
print(tab1.txt, format.args=list(big.mark = ".", decimal.mark =
","),
caption.placement='top', table.placement='H') }
geral <- function(){
for (i in 1:25){
x<-paste("Q", i, sep="")
cria.tabela(x)
}
}
geral()
I need to change the variable DISCIPLINA created in the function by the
variable DISCIPLINA in my dataset, but not working.
Reading data was taken with:
require(foreign)
require(xtable)
dados = read.epiinfo('C:/Colegiado de
Veterin?ria/Dados/A2013/A2013.rec')
head(dados)
tail(dados)
str(dados)
attach(dados)
serie_1 = subset(dados, SERIE=='1')
head(serie_1)
tail(serie_1)
attach(serie_1)
How can I do this?
Thanks a lot,
---------------------------------------------
Silvano Cesar da Costa
Universidade Estadual de Londrina
Centro de Ci?ncias Exatas
Departamento de Estat?stica
Fone: (43) 3371-4346
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.