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@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.