Re: [R] Selecting elements
Wow, That's exactly what I want. But, if possible, that a list was created with the selected elements (variable and value). Is it possible to add in the output file? Thank you very much. Prof. Dr. Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 Em qua., 25 de ago. de 2021 às 03:12, Jim Lemon escreveu: > Hi Silvano, > I was completely stumped by your problem until I looked through Petr's > response and guessed that you wanted the largest sum of 'Var.1" > constrained by the specified numbers in your three schemes. I think > this is what you want, but I haven't checked it exhaustively. > > set.seed(123) > Var.1 <- rep(LETTERS[1:4], 10) > Var.2 <- sample(1:40, replace=FALSE) > data <- data.frame(Var.1, Var.2) > (Order <- data[order(data$Var.2, decreasing=TRUE), ]) > allowed<-matrix(c(3,3,2,2,2,5,0,3,3,4,2,1),nrow=3,byrow=TRUE) > colnames(allowed)<-LETTERS[1:4] > select_largest<-function(x,allowed,n=10) { > totals<-rep(0,nrow(allowed)) > indices<-matrix(0,ncol=n,nrow=nrow(allowed)) > for(i in 1:nrow(allowed)) { > ii<-1 > for(j in 1:ncol(allowed)) { >if(allowed[i,j]) { > indx<-which(x[,1] == colnames(allowed)[j]) > totals[i]<-totals[i]+sum(x[indx[1:allowed[i,j]],2]) > indices[i,ii:(ii+allowed[i,j]-1)]<-indx[1:allowed[i,j]] > ii<-ii+allowed[i,j] >} > } > } > largest<-which.max(totals) > return(list(scheme=largest,total=totals[largest], > indices=sort(indices[largest,]))) > } > select_largest(Order,allowed) > > Jim > > On Tue, Aug 24, 2021 at 7:11 PM PIKAL Petr wrote: > > > > Hi. > > > > Now it is understandable. However the solution is not clear for me. > > > > table(Order$Var.1[1:10]) > > A B C D > > 4 1 2 3 > > > > should give you a hint which scheme could be acceptable, but how to do > it programmatically I do not know. > > > > maybe to start with lower value in the table call and gradually increse > it to check which scheme starts to be the chosen one > > > > > table(data.o$Var.1[1]) # scheme 2 is out > > C > > 1 > > ... > > > table(data.o$Var.1[1:5]) #scheme 3 > > A B C D > > 1 1 2 1 > > > > > table(data.o$Var.1[1:6]) #scheme 3 > > > > A B C D > > 2 1 2 1 > > > > > table(data.o$Var.1[1:7]) # scheme1 > > A B C D > > 2 1 2 2 > > > > > table(data.o$Var.1[1:8]) # no such scheme, so scheme 1 is chosen one > > A B C D > > 2 1 2 3 > > > > #Now you need to select values based on scheme 1. > > # 3A - 3B - 2C - 2D > > > > sss <- split(Order, Order$Var.1) > > selection <- c(3,3,2,2) > > result <- vector("list", 4) > > > > #I would use loop > > > > for(i in 1:4) { > > result[[i]] <- sss[[i]][1:selection[i],] > > } > > > > Maybe someone come with other ingenious solution. > > > > Cheers > > Petr > > > > From: Silvano Cesar da Costa > > Sent: Monday, August 23, 2021 7:54 PM > > To: PIKAL Petr > > Cc: r-help@r-project.org > > Subject: Re: [R] Selecting elements > > > > Hi, > > > > I apologize for the confusion. I will try to be clearer in my > explanation. I believe that with the R script it becomes clearer. > > > > I have 4 variables with 10 repetitions and each one receives a value, > randomly. > > I order the dataset from largest to smallest value. I have to select 10 > elements in > > descending order of values, according to one of three schemes: > > > > # 3A - 3B - 2C - 2D > > # 2A - 5B - 0C - 3D > > # 3A - 4B - 2C - 1D > > > > If the first 3 elements (out of the 10 to be selected) are of the letter > D, automatically > > the adopted scheme will be the second. So, I have to (following) choose > 2A, 5B and 0C. > > How to make the selection automatically? > > > > I created two selection examples, with different schemes: > > > > > > > > set.seed(123) > > > > Var.1 = rep(LETTERS[1:4], 10) > > Var.2 = sample(1:40, replace=FALSE) > > > > data = data.frame(Var.1, Var.2) > > > > (Order = data[order(data$Var.2, decreasing=TRUE), ]) > > > > # I must select the 10 highest values (), > > # but which follow a certain scheme: > > # > > # 3A - 3B - 2C - 2D or > > # 2A - 5B - 0C - 3D or > > # 3A - 4B - 2C - 1D > > # > > # In this case, I started with the highest value that refers to the > letter C. > > # Next co
Re: [R] Selecting elements
Hi, I apologize for the confusion. I will try to be clearer in my explanation. I believe that with the R script it becomes clearer. I have 4 variables with 10 repetitions and each one receives a value, randomly. I order the dataset from largest to smallest value. I have to select 10 elements in descending order of values, according to one of three schemes: # 3A - 3B - 2C - 2D # 2A - 5B - 0C - 3D # 3A - 4B - 2C - 1D If the first 3 elements (out of the 10 to be selected) are of the letter D, automatically the adopted scheme will be the second. So, I have to (following) choose 2A, 5B and 0C. How to make the selection automatically? I created two selection examples, with different schemes: set.seed(123) Var.1 = rep(LETTERS[1:4], 10) Var.2 = sample(1:40, replace=FALSE) data = data.frame(Var.1, Var.2) (Order = data[order(data$Var.2, decreasing=TRUE), ]) # I must select the 10 highest values (), # but which follow a certain scheme: # # 3A - 3B - 2C - 2D or # 2A - 5B - 0C - 3D or # 3A - 4B - 2C - 1D # # In this case, I started with the highest value that refers to the letter C. # Next comes only 1 of the letters B, A and D. All are selected once. # The fifth observation is the letter C, completing 2 C values. In this case, # following the 3 adopted schemes, note that the second scheme has 0C, # so this scheme is out. # Therefore, it can be the first scheme (3A - 3B - 2C - 2D) or the # third scheme (3A - 4B - 2C - 1D). # The next letter to be completed is the D (fourth and seventh elements), # among the 10 elements being selected. Therefore, the scheme adopted is the # first one (3A - 3B - 2C - 2D). # Therefore, it is necessary to select 2 values with the letter B and 1 value # with the letter A. # # Manual Selection - # The end result is: (Selected.data = Order[c(1,2,3,4,5,6,7,9,13,16), ]) # Scheme: 3A - 3B - 2C - 2D sort(Selected.data$Var.1) #-- # Second example: - #-- set.seed(4) Var.1 = rep(LETTERS[1:4], 10) Var.2 = sample(1:40, replace=FALSE) data = data.frame(Var.1, Var.2) (Order = data[order(data$Var.2, decreasing=TRUE), ]) # The end result is: (Selected.data.2 = Order[c(1,2,3,4,5,6,7,8,9,11), ]) # Scheme: 3A - 4B - 2C - 1D sort(Selected.data.2$Var.1) How to make the selection of the 10 elements automatically? Thank you very much. Prof. Dr. Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 Em seg., 23 de ago. de 2021 às 05:05, PIKAL Petr escreveu: > Hi > > Only I got your HTML formated mail, rest of the world got complete mess. > Do not use HTML formating. > > As I got it right I wonder why in your second example you did not follow > 3A - 3B - 2C - 2D > > as D were positioned 1st and 4th. > > I hope that you could use something like > > sss <- split(data$Var.2, data$Var.1) > lapply(sss, cumsum) > $A > [1] 38 73 105 136 166 188 199 207 209 210 > > $B > [1] 39 67 92 115 131 146 153 159 164 168 > > $C > [1] 40 76 105 131 152 171 189 203 213 222 > > $D > [1] 37 71 104 131 155 175 192 205 217 220 > > Now you need to evaluate this result according to your sets. Here the > highest value (76) is in C so the set with 2C is the one you should choose > and select you value according to this set. > > With > > set.seed(666) > > Var.1 = rep(LETTERS[1:4], 10) > > Var.2 = sample(1:40, replace=FALSE) > > data = data.frame(Var.1, Var.2) > > data <- data[order(data$Var.2, decreasing=TRUE), ] > > sss <- split(data$Var.2, data$Var.1) > > lapply(sss, cumsum) > $A > [1] 36 70 102 133 163 182 200 207 212 213 > > $B > [1] 35 57 78 95 108 120 131 140 148 150 > > $C > [1] 40 73 102 130 156 180 196 211 221 225 > > $D > [1] 39 77 114 141 166 189 209 223 229 232 > > Highest value is in D so either 3A - 3B - 2C - 2D or 3A - 3B - 2C - 2D > should be appropriate. And here I am again lost as both sets are same. > Maybe you need to reconsider your statements. > > Cheers > Petr > > From: Silvano Cesar da Costa > Sent: Friday, August 20, 2021 9:28 PM > To: PIKAL Petr > Cc: r-help@r-project.org > Subject: Re: [R] Selecting elements > > Hi, thanks you for the answer. > Sorry English is not my native language. > > But you got it right. > > As C is first and fourth biggest value, you follow third option and > select 3 highest A, 3B 2C and 2D? > > I must select the 10 (not 15) highest values, but which follow a certain > order: > 3A - 3B - 2C - 2D or > 2A - 5B - 0C - 3D or > 3A - 3B - 2C - 2D > I'll put the example in Excel for a better understanding (with 20 elements > only). > I must select 10 elements (the highest values of variable Var.2), which > fit one of the 3 options above. > > Numb
Re: [R] Selecting elements
Hi, thanks you for the answer. Sorry English is not my native language. But you got it right. > As C is first and fourth biggest value, you follow third option and select 3 highest A, 3B 2C and 2D? I must select the 10 (not 15) highest values, but which follow a certain order: 3A - 3B - 2C - 2D or 2A - 5B - 0C - 3D or 3A - 3B - 2C - 2D I'll put the example in Excel for a better understanding (with 20 elements only). I must select 10 elements (the highest values of variable Var.2), which fit one of the 3 options above. Number Position Var.1 Var.2 1 27 C 40 2 30 B 39 Selected: 3 5 A 38 Number Position Var.1 Var.2 4 16 D 37 1 27 C 40 5 23 C 36 2 30 B 39 3A - 3B - 2C - 2D 6 13 A 35 3 5 A 38 7 20 D 34 4 16 D 37 3A - 3B - 1C - 3D 8 12 D 33 5 23 C 36 9 9 A 32 6 13 A 35 2A - 5B - 0C - 3D 10 1 A 31 7 20 D 34 11 21 A 30 10 9 A 32 12 35 C 29 13 14 B 28 13 14 B 28 17 6 B 25 14 8 D 27 15 7 C 26 16 6 B 25 17 40 D 24 18 26 B 23 19 29 A 22 20 31 C 21 Second option (other data set): Number Position Var.1 Var.2 1 36 D 20 2 11 B 19 Selected: 3 39 A 18 Number Position Var.1 Var.2 4 24 D 17 1 36 D 20 5 34 B 16 2 11 B 19 3A - 3B - 2C - 2D 6 2 B 15 3 39 A 18 7 3 A 14 4 24 D 17 3A - 3B - 1C - 3D 8 32 D 13 5 34 B 16 9 28 D 12 6 2 B 15 2A - 5B - 0C - 3D 10 25 A 11 7 3 A 14 11 19 B 10 8 32 D 13 12 15 B 9 9 25 A 11 13 17 A 8 10 18 C 7 14 18 C 7 15 38 B 6 16 10 B 5 17 22 B 4 18 4 D 3 19 33 A 2 20 37 A 1 How to make the selection of these 10 elements that fit one of the 3 options using R? Thanks, Prof. Dr. Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 Em sex., 20 de ago. de 2021 às 03:28, PIKAL Petr escreveu: > Hallo > > I am confused, maybe others know what do you want but could you be more > specific? > > Let say you have such data > set.seed(123) > Var.1 = rep(LETTERS[1:4], 10) > Var.2 = sample(1:40, replace=FALSE) > data = data.frame(Var.1, Var.2) > > What should be the desired outcome? > > You can sort > data <- data[order(data$Var.2, decreasing=TRUE), ] > and split the data > > split(data$Var.2, data$Var.1) > $A > [1] 38 35 32 31 30 22 11 8 2 1 > > $B > [1] 39 28 25 23 16 15 7 6 5 4 > > $C > [1] 40 36 29 26 21 19 18 14 10 9 > > $D > [1] 37 34 33 27 24 20 17 13 12 3 > > T inspect highest values. But here I am lost. As C is first and fourth > biggest value, you follow third option and select 3 highest A, 3B 2C and 2D? > > Or I do not understand at all what you really want to achieve. > > Cheers > Petr > > > -Original Message- > > From: R-help On Behalf Of Silvano Cesar > da > > Costa > > Sent: Thursday, August 19, 2021 10:40 PM > > To: r-help@r-project.org > > Subject: [R] Selecting elements > > > > Hi, > > > > I need to select 15 elements, always considering the highest values > > (descending order) but obeying the following configuration: > > > > 3A - 4B - 0C - 3D or > > 2A - 5B - 0C - 3D or > > 3A - 3B - 2C - 2D > > > > If I have, for example, 5 A elements as the highest values, I can only > choose > > (first and third choice) or 2 (second choice) elements. > > > > how to make this selection? > > > > > > library(dplyr) > > > > Var.1 = rep(LETTERS[1:4], 10) > > Var.2 = sample(1:40, replace=FALSE) > > > > data = data.frame(Var.1, Var.2) > > (data = data[order(data$Var.2, decreasing=TRUE), ]) > > > > Elements = data %>% > > arrange(desc(Var.2)) > > > > Thanks, > > > > Prof. Dr. Silvano Cesar da Costa > > Universidade Estadual de Londrina > > Centro de Ciências Exatas > > Departamento de Estatística > > > > Fone: (43) 3371-4346 > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Selecting elements
Hi, I need to select 15 elements, always considering the highest values (descending order) but obeying the following configuration: 3A - 4B - 0C - 3D or 2A - 5B - 0C - 3D or 3A - 3B - 2C - 2D If I have, for example, 5 A elements as the highest values, I can only choose 3 (first and third choice) or 2 (second choice) elements. how to make this selection? library(dplyr) Var.1 = rep(LETTERS[1:4], 10) Var.2 = sample(1:40, replace=FALSE) data = data.frame(Var.1, Var.2) (data = data[order(data$Var.2, decreasing=TRUE), ]) Elements = data %>% arrange(desc(Var.2)) Thanks, Prof. Dr. Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Common elements
Hi, I have a dataset with ten columns, but I need extract only lines that has common elements. The columns are: Animal Mother [1,] 1143430 [2,] 1144134 [3,] 1146 3 [4,] 1147151 [5,] 1150230 [6,] 1156290 [7,] 1157227 [8,] 1159757 [9,] 1160 3 [10,] 1161236 [11,] 1162231 [12,] 1164132 [13,] 1165420 [14,] 1168290 [15,] 1169229 [16,] 1172425 [17,] 1173134 [18,] 1174234 [19,] 1175233 [20,] 1178239 [21,] 1179757 [22,] 1180236 [23,] 1185420 [24,] 1186389 [25,] 1190425 [26,] 1192235 How can I do this? Thanks. Prof. Dr. Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Reading access file
Hello everybody. I have a access file to read in R but I can’t to do this. I used Hmisc package, but it doesn’t work. Someone has the commands to read this kind of file? I attached the access file. Thanks. Silvano. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Differences between MTDFReml and kinship2
Hi, I fitted a genetic model using kinship2 and I compared it with MTDFReml program output. The residual variance of both are very close but the genetic variance are very differents. The output are: MTDFReml: genetic variance = 1.24015 residual variance = 5.93424 R (Kinship2): genetic variance = 0.767187 residual variance = 5.6712 Both of them use REML method. Could someone tell why the difference? Thanks a lot, Silvano. [[alternative HTML version deleted]] __ 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.
[R] Problems with table
Hi, I have 25 questions divided into 3 modules. I'm building tables of DISCIPLINE with each of the questions (Q1, Q2, Q3, ..., Q25). Each table, of course, has a different title. In the first module (questions Q1, Q2, ..., Q7) I donât have problems with the titles of tables. DISCIPLINA - serie_2$DISCIPLINA for (i in 1:7){ aux - paste(Q, i, sep=) } for (i in 1:7){ aux - paste(nome.Questao, i, sep=) assign(aux, paste(Nome da Questao, i)) } nome.Questoes = c(Apresentação da proposta de programa a ser desenvolvida na disciplina., Profundidade dos temas em relação aos objetivos da disciplina., Aplicabilidade dos temas abordados., Articulação do conteúdo da disciplina com outras e com a profissão., Estabelecimento de critérios de avaliação claros e adequados., Os resultados das avaliações são discutidos com os alunos., Atendimento da disciplina à s suas expectativas.) cria.tabela - function(Questao, i){ Questao1 - get(Questao) tab1 - table(DISCIPLINA, Questao1) tab1.prop = round(100*prop.table(tab1, 1), 2) capt - nome.Questoes[i] tab1.txt = xtable(tab1.prop, align=l|r, label=Questao, caption=paste(capt)) print(tab1.txt, format.args=list(big.mark = ., decimal.mark = ,), caption.placement='top', table.placement='H') cat(\n\n\n) } Discip - function(){ for (i in 1:7){ x - paste(Q, i, sep=) cria.tabela(x, i) } } Discip() In the second module the questions are Q8, Q9 and Q10 and I try use the same code, but all titles (3 tables) are equal. INFRA - serie_2$DISCIPLINA for (i in 8:10){ aux - paste(Q, i, sep=)} for (j in 1:3){ aux - paste(nome.Questao, j, sep=) assign(aux, paste(Nome da Questao, j)) } nome.Infra = c(As instalações utilizadas durante as aulas da disciplina., Qualidade dos recursos didáticos e demais materiais relacionados à disciplina., Disponibilidade das referências bibliográficas atuais e demais materiais didáticos.) cria.tabela - function(Questao, i){ Questao1 - get(Questao) tab1 - table(INFRA, Questao1) tab1.prop = round(100*prop.table(tab1, 1), 2) capt - nome.Infra[j] tab1.txt = xtable(tab1.prop, align=l|r, label=Questao, caption=paste(capt)) print(tab1.txt, format.args=list(big.mark = ., decimal.mark = ,), caption.placement='top', table.placement='H') cat(\n\n\n) } Infra - function(){ for (i in 8:10){ x - paste(Q, i, sep=) cria.tabela(x, i) } } Infra() How can I solve this problem? Thanks, Silvano. --- Este email está limpo de vÃrus e malwares porque a proteção do avast! AntivÃrus está ativa. [[alternative HTML version deleted]] __ 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.
[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|r, 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|r, 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.
[R] ftable and data.frame
Hi, I used this command to produce a table: (tab1 = ftable(SEX, ESTCIV, Q1)) Q1 B L M N SEXOESTCIV F A 11 13 4 2 E 1 0 0 0 M A 5 0 3 1 E 0 0 0 0 but I need something like: SEXOESTCIVB L M N FA 11 13 4 2 FE 1 0 0 0 M A 5 0 3 1 M E 0 0 0 0 How can I get it? I need this format to use ordinal logistic regression and I have many tables. Thanks, Silvano. --- Este email está limpo de vírus e malwares porque a proteção do avast! Antivírus está ativa. [[alternative HTML version deleted]] __ 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.
[R] Problems with xtable?
Hi, I'm using Sweave to create some tables. My code is: label=Q1, echo=FALSE, results=tex= tab1 = table(DISCIPLINA, Q1) tab1.prop = round(addmargins(100*prop.table(tab1, 1), FUN=list(Total=sum)), 2) tab1.txt = xtable(tab1.prop, align=l|rr, 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') @ but, the output is Margins computed over dimensions in the following order: 1: DISCIPLINA 2: Q1 % latex table generated in R 3.0.0 by xtable 1.7-1 package % Fri Dec 13 19:00:35 2013 \begin{table}[H] \centering \caption[Q1]{Apresentação da proposta de programa a ser desenvolvida na disciplina} \label{Q1} \begin{tabular}{l|rr} \hline 1 2 3 4 5 Total \\ \hline 6BAV039 5,45 20,00 40,00 29,09 5,45 100,00 \\ 6BIO029 1,85 1,85 31,48 37,04 27,78 100,00 \\ 6BIO030 0,00 0,00 5,45 45,45 49,09 100,00 \\ 6BIO031 0,00 1,89 45,28 30,19 22,64 100,00 \\ 6BIQ014 0,00 0,00 9,26 42,59 48,15 100,00 \\ 6CIF023 1,85 3,70 20,37 42,59 31,48 100,00 \\ 6EMA024 1,85 9,26 25,93 38,89 24,07 100,00 \\ 6HIT011 0,00 0,00 3,70 27,78 68,52 100,00 \\ 6MOR012 0,00 0,00 41,82 47,27 10,91 100,00 \\ 6PAT013 0,00 5,56 29,63 44,44 20,37 100,00 \\ 6SOC016 3,64 9,09 38,18 29,09 20,00 100,00 \\ Total 14,65 51,35 291,11 414,43 328,47 1.100,00 \\ \hline \end{tabular} \end{table} and I don't want this output Margins computed over dimensions in the following order: 1: DISCIPLINA 2: Q1 How can I get out it? Thanks, - 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.
[R] Randomization
Hi, I have a set of 80 animals and their respective weights. I would like create 4 groups of 20 animals so that the groups have means and variances with values ??very close. How can I make this randomization in R? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] timereg
Hi, I tried to fit a model using a timecox function in R version 3.0.0, using sTRACE data present in survival package. If I use the 2.9.0 version, I don't have problems, but in 3.0.0 version, I get the following error message: out - timecox(Surv(time/365, status==9) ~ age+sex+diabetes+chf+vf, sTRACE, max.time=7, n.sim=500) Error in .C(OStimecox, as.double(times), as.integer(Ntimes), as.double(designX), : OStimecox not available for .C() for package timereg I don't know what's happend. I would like use 3.0.0 version, but I don't know what's wrong. Somebody help me? Also, when I use the aalen model I get differents results in 3.0.0 and 2.9.0 versions. Why? Version 3.0.0: fit1.semi - aalen(Surv(time/365, status==9)~age+sex+diabetes+chf+vf, sTRACE,max.time=7,n.sim=500) summary(fit1.semi) Additive Aalen Model Test for nonparametric terms Test for non-significant effects Supremum-test of significance p-value H_0: B(t)=0 (Intercept) 7.29 0.000 age 8.63 0.000 sex 2.95 0.060 diabetes 2.31 0.240 chf 5.30 0.000 vf 2.95 0.042 Test for time invariant effects Kolmogorov-Smirnov test p-value H_0:constant effect (Intercept) 0.68600 0.006 age 0.00934 0.008 sex 0.16900 0.078 diabetes 0.22100 0.184 chf 0.14800 0.176 vf0.46100 0.008 in 2.9.0 version: fit1.semi - aalen(Surv(time/365, status==9)~age+sex+diabetes+chf+vf, sTRACE,max.time=7,n.sim=500) summary(fit1.semi) Additive Aalen Model Test for nonparametric terms Test for non-significant effects sup| hat B(t)/SD(t) | p-value H_0: B(t)=0 (Intercept) 7.29 0.000 age 8.63 0.000 sex 2.95 0.052 diabetes 2.31 0.246 chf 5.30 0.000 vf2.95 0.026 Test for time invariant effects sup| B(t) - (t/tau)B(tau)| p-value H_0: B(t)=b t (Intercept)0.68600 0.004 age0.00934 0.004 sex0.16900 0.084 diabetes 0.22100 0.208 chf0.14800 0.158 vf 0.46100 0.004 part of them... Thanks a lot, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] means in tables
Hi. I have 2 tables, with same dimensions (8000 x 5). Something like: tab1: V1 V2 V3 V4 V5 14.23 1.71 2.43 15.6 127 13.20 1.78 2.14 11.2 100 13.16 2.36 2.67 18.6 101 14.37 1.95 2.50 16.8 113 13.24 2.59 2.87 21.0 118 tab2: V1 V2 V3 V4 V5 1.23 1.1 2.3 1.6 17 1.20 1.8 2.4 1.2 10 1.16 2.6 2.7 1.6 11 1.37 1.5 2.0 1.8 13 1.24 2.9 2.7 2.0 18 I need generate a table of averages, the elements in the same position in both tables, like: tab3: (14.23 + 1.23)/2 (1.71+1.1)/2 (127+17)/2 and so on I tried the program: Médias = matrix(NA, nrow(tab1), ncol(tab1)) for(i in 1:nrow(tab1)){ for(j in 1:ncol(tab1)){ for(k in 1:nrow(tab2)){ for(l in 1:ncol(tab2)){ Médias = tab1$i[j] Médias but it does't work. I don't know programming. How can I do this? Thanks, - 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.
[R] SNPRelate problems
Hi, I'm trying convert plink files to gds (SNPRelate). I have the files: baep.fam, baep.bed and baep.bim and the program to convert data is: setwd('C:/Silvano/Incor/Baependi/Dados Baependi/') library(gdsfmt)# versão 0.9.10 library(SNPRelate) # versão 0.9.8 # Arquivos PLINK BED bed.fn - system.file(C:/Silvano/Incor/Baependi/Dados Baependi/, baep.bed, package=SNPRelate) bim.fn - system.file(C:/Silvano/Incor/Baependi/Dados Baependi/, baep.bim, package=SNPRelate) fam.fn - system.file(C:/Silvano/Incor/Baependi/Dados Baependi/, baep.fam, package=SNPRelate) # Convertendo snpgdsBED2GDS(bed.fn, fam.fn, bim.fn, out.gdsfn=C:/Silvano/Incor/Baependi/Dados Baependi/baep.gds, verbose=TRUE) but isn't work. The error is: Start snpgdsBED2GDS ... Erro em snpgdsBED2GDS(bed.fn, fam.fn, bim.fn, out.gdsfn = C:/Silvano/Incor/Baependi/Dados Baependi/baep.gds, : Cannot open the file . What can I do? What is wrong? Thanks, - 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.
[R] Kinship2 and GenABEL
Hi, I'm using kinship2 to calculate heritabilty, but I would like calculate in GenABEL too. I trying the code: require(kinship2) require(GenABEL) pedig = with(Dados, pedigree(id=IID, dadid=PAT, momid=MAT, sex=SEX, famid=FID, missid=0)) kmat = kinship(pedig) (mod1 = polygenic(altura ~ SEX + idade, data=Dados, kin=kmat)) Erro em intI(i, n = d[1], dn[[1]], give.dn = FALSE) : invalid character indexing How can I calculate heritabilty using GenABEL with kinship matrix of kinship2 package? Thanks, - 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.
[R] Extracting columns
Hi, I have 22 files (A1, A2, ..., A22) with different number of columns, totaling 10,000 columns: c1, c2, c3, ..., c1 I have another file with a list of 100 columns that I need to extract. These 100 columns are distributed in 22 files. How to extract the 100 columns of the 22 files? I have done it manually with the following commands, for example: cromo1 = read.table (~ / cromo1.raw ', head = T) c1 = subset (cromo1, select = c ('c1', 'c50', 'C750')) in this case, I know that the columns c1, c50 and C750 are on cromo1.raw. See who need to apply the commands above 22 times. Is there a way to schedule these operations? - 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.
[R] Interaction
Hi, I'm fitting a model with 3 variables: A, B and SNP. The response variable is Y. I would like fit the following model, in this order: Y ~ A + B + A*B + SNP In general, the R sets of the form: Y ~ A + B + SNP + A*B How do this? - 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.
Re: [R] factor or character
Hi, still doesn't work. Hello, I've just seen the error, you are _not_ searching for colnames in mod5.sig$snps. Corrected: Selec = todos[ , colnames(todos) %in% mod5.sig$snps] Hope this helps, Rui Barradas Em 23-10-2012 21:17, Silvano Cesar da Costa escreveu: Hi Rui, it doesn't work: (mod5.sig = with(mod5, data.frame(snps = SNP[pvalor5e-8], stringsAsFactors=FALSE))) str(mod5.sig) 'data.frame':76 obs. of 1 variable: $ snps: Factor w/ 220 levels rs10058955_A,..: 89 59 88 73 40 35 97 55 87 204 ... Selec = todos[ , colnames(todos) %in% mod5.sig] head(Selec) data frame com 0 colunas e 6 linhas the problem is the same. Thanks, Hello, When creating the data.frame of snps use the option stringsAsFactors = FALSE I believe your error comes from the fact that you are trying to find colnames in a variable coded as integers (a factor, like str shows). Hope this helps, Rui Barradas Em 23-10-2012 19:02, Silvano Cesar da Costa escreveu: Hi, The program below work very well. (snps = c('rs621782_G', 'rs8087639_G', 'rs8094221_T', 'rs7227515_A', 'rs537202_C')) Selec = todos[ , colnames(todos) %in% snps] head(Selec) But, I have a data set with 1.000 columns and I need extract 70 to use (like snps in command above). This 70 snps are in a file. So I create a file to extract them with (mod5.sig = with(mod5, data.frame(snps = SNP[pvalor 5e-8]))) str(mod5.sig) (snps = (mod5.sig)) The structure is: 'data.frame': 76 obs. of 1 variable: $ snps: Factor w/ 220 levels rs10058955_A,..: 89 59 88 73 40 35 97 55 87 204 ... But it doesn't work. The output is: Selec = todos[ , colnames(todos) %in% snps] head(Selec) data frame with 0 columns and 6 rows What's is wrong? 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. - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 - - 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.
[R] factor or character
Hi, The program below work very well. (snps = c('rs621782_G', 'rs8087639_G', 'rs8094221_T', 'rs7227515_A', 'rs537202_C')) Selec = todos[ , colnames(todos) %in% snps] head(Selec) But, I have a data set with 1.000 columns and I need extract 70 to use (like snps in command above). This 70 snps are in a file. So I create a file to extract them with (mod5.sig = with(mod5, data.frame(snps = SNP[pvalor 5e-8]))) str(mod5.sig) (snps = (mod5.sig)) The structure is: 'data.frame': 76 obs. of 1 variable: $ snps: Factor w/ 220 levels rs10058955_A,..: 89 59 88 73 40 35 97 55 87 204 ... But it doesn't work. The output is: Selec = todos[ , colnames(todos) %in% snps] head(Selec) data frame with 0 columns and 6 rows What's is wrong? 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.
Re: [R] factor or character
Hi Rui, it doesn't work: (mod5.sig = with(mod5, data.frame(snps = SNP[pvalor5e-8], stringsAsFactors=FALSE))) str(mod5.sig) 'data.frame': 76 obs. of 1 variable: $ snps: Factor w/ 220 levels rs10058955_A,..: 89 59 88 73 40 35 97 55 87 204 ... Selec = todos[ , colnames(todos) %in% mod5.sig] head(Selec) data frame com 0 colunas e 6 linhas the problem is the same. Thanks, Hello, When creating the data.frame of snps use the option stringsAsFactors = FALSE I believe your error comes from the fact that you are trying to find colnames in a variable coded as integers (a factor, like str shows). Hope this helps, Rui Barradas Em 23-10-2012 19:02, Silvano Cesar da Costa escreveu: Hi, The program below work very well. (snps = c('rs621782_G', 'rs8087639_G', 'rs8094221_T', 'rs7227515_A', 'rs537202_C')) Selec = todos[ , colnames(todos) %in% snps] head(Selec) But, I have a data set with 1.000 columns and I need extract 70 to use (like snps in command above). This 70 snps are in a file. So I create a file to extract them with (mod5.sig = with(mod5, data.frame(snps = SNP[pvalor 5e-8]))) str(mod5.sig) (snps = (mod5.sig)) The structure is: 'data.frame':76 obs. of 1 variable: $ snps: Factor w/ 220 levels rs10058955_A,..: 89 59 88 73 40 35 97 55 87 204 ... But it doesn't work. The output is: Selec = todos[ , colnames(todos) %in% snps] head(Selec) data frame with 0 columns and 6 rows What's is wrong? 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. - 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.
[R] Reading multiple files
Hi, I have 35 data files for reading. I would like get a program for performing reading of 35 files at once. All are of the type: Dados1.raw, Dados2.raw and so on. If the files have the same number of columns, I can read with the following commands: rm(list=ls()) filenames = list.files(path=~/Silvano/Arq, pattern=Dados+.*raw) names = substr(filenames, 1, 7) for(i in names){ filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=)) assign(i, read.delim(filepath, colClasses=c(rep(character, 5), rep(numeric, 5)), sep = )) } It happens that the files have different number of columns. And I can't solve the problem. Any suggestions? - 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.
Re: [R] Reading multiple files
Hi, I didn't notice problems with this. Will your data be read in correctly if you do away with the colClasses argument to read.delim (or read.table)? Jean Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 09:11:33 AM: Hi, I have 35 data files for reading. I would like get a program for performing reading of 35 files at once. All are of the type: Dados1.raw, Dados2.raw and so on. If the files have the same number of columns, I can read with the following commands: rm(list=ls()) filenames = list.files(path=~/Silvano/Arq, pattern=Dados+.*raw) names = substr(filenames, 1, 7) for(i in names){ filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=)) assign(i, read.delim(filepath, colClasses=c(rep(character, 5), rep(numeric, 5)), sep = )) } It happens that the files have different number of columns. And I can't solve the problem. Any suggestions? - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 - 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.
Re: [R] Reading multiple files
Actually the problem occurred in the command: names = substr (filenames, 1, 7) As the file's names are: Dados1.raw, Dados2.raw, ..., Dados11.raw, Dados12.raw, ..., Data 35.raw the program doesn't work. A quick way to make it work is rename the files to: Dados01.raw, Dados02.raw, ..., Dados11.raw, Dados12.raw, ..., Data 35.raw I do not know how to work any other way. Thank you for the suggestions. If your previously posted code worked with files all having the same number of columns, and if your data is read in correctly without the colClasses argument, then I think the following code should work. for(i in names){ filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=)) assign(i, read.table(filepath)) } If not, then my guess is the error (what is the error message???) is due to the file referencing or naming. For example, it's not clear to me why you take the substring of the file name, only to paste on the file type suffix later. Jean Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 04:31:48 PM: Hi, I didn't notice problems with this. Will your data be read in correctly if you do away with the colClasses argument to read.delim (or read.table)? Jean Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 09:11:33 AM: Hi, I have 35 data files for reading. I would like get a program for performing reading of 35 files at once. All are of the type: Dados1.raw, Dados2.raw and so on. If the files have the same number of columns, I can read with the following commands: rm(list=ls()) filenames = list.files(path=~/Silvano/Arq, pattern=Dados+.*raw) names = substr(filenames, 1, 7) for(i in names){ filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=)) assign(i, read.delim(filepath, colClasses=c(rep(character, 5), rep(numeric, 5)), sep = )) } It happens that the files have different number of columns. And I can't solve the problem. Any suggestions? - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 - 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.
Re: [R] Common elements in columns
Hi Arun, it's exactly what I wanted. Thanks a lot, Hi, May be this might help: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) df1$C1[df1$C1%in%df2$C1[df2$C1%in%df3$C1[df3$C1%in%df4$C1]]] #[1] G E H J A.K. - Original Message - From: Silvano Cesar da Costa silv...@uel.br To: r-help@r-project.org Cc: Sent: Sunday, September 2, 2012 7:05 PM Subject: [R] Common elements in columns Hi, I have 4 files with 1 individuals in each file and 10 columns each. One of the columns, say C1, may have elements in common with the other columns C1 of other files. If I have only 2 files, I can do this check with the command: data1[data1 %in% data2] data2[data2 %in% data1] How do I check which common elements in the columns of C1 4 files? Thanks, - 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. - 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.
Re: [R] Common elements in columns
Hi Jim. It was a very elegant way of solving the problem. Thank you, Another way of solving the problem: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) x - list(df1$C1, df2$C1, df3$C1, df4$C1) Reduce(intersect, x) [1] G E H J On Mon, Sep 3, 2012 at 7:01 AM, Silvano Cesar da Costa silv...@uel.br wrote: Hi Arun, it's exactly what I wanted. Thanks a lot, Hi, May be this might help: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) df1$C1[df1$C1%in%df2$C1[df2$C1%in%df3$C1[df3$C1%in%df4$C1]]] #[1] G E H J A.K. - Original Message - From: Silvano Cesar da Costa silv...@uel.br To: r-help@r-project.org Cc: Sent: Sunday, September 2, 2012 7:05 PM Subject: [R] Common elements in columns Hi, I have 4 files with 1 individuals in each file and 10 columns each. One of the columns, say C1, may have elements in common with the other columns C1 of other files. If I have only 2 files, I can do this check with the command: data1[data1 %in% data2] data2[data2 %in% data1] How do I check which common elements in the columns of C1 4 files? Thanks, - 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. - 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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. - 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.
[R] Common elements in columns
Hi, I have 4 files with 1 individuals in each file and 10 columns each. One of the columns, say C1, may have elements in common with the other columns C1 of other files. If I have only 2 files, I can do this check with the command: data1[data1 %in% data2] data2[data2 %in% data1] How do I check which common elements in the columns of C1 4 files? Thanks, - 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.
[R] Pedigrees
I am building several pedigrees and would like to construct the graphs automatically. I used the following program: require(kinship2) pedig = with(Dados, pedigree(id=iid, dadid=fid, momid=mid, sex=sex, famid=famid, missid=0)) for(famid in 1:15){ pedig[famid] - pedig['famid'] pdf(paste(plot, famid, .pdf)) plot(pedig[famid]) dev.off() } Error em `[.pedigreeList`(pedig, famid) : Familiy famid not found but is not working. How to solve the problem? Thanks, - 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.
[R] NULL column
Hi, I have a dataset where the first column has no name. I would like to assign a name to this column to be able to use it something like: Cap - NULL How can I do this? beta0 beta1 pvalorCrom rs17 158.5980 12.252462 9.083193e-1351 rs46 163.3730 3.304276 3.279925e-06 1 rs63 162.7924 2.084678 5.023893e-06 1 rs24 162.4252 1.837208 5.509042e-06 1 How can I do this? Thanks, - 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.
Re: [R] NULL column
Thank you all. Your suggestions solved the problem. If you original read in the data with read.table, use its row.names=NULL argument so it doesn't turn the first character column with no duplicated entries into the row.names. d - read.table(text= + CAP beta0 beta1 pvalorCrom + rs17 158.5980 12.252462 9.083193e-1351 + rs46 163.3730 3.304276 3.279925e-06 1 + rs63 162.7924 2.084678 5.023893e-06 1 + rs24 162.4252 1.837208 5.509042e-06 1 + ,sep=,header=TRUE, row.names=NULL) d CAPbeta0 beta1pvalor Crom 1 rs17 158.5980 12.252462 9.083193e-1351 2 rs46 163.3730 3.304276 3.279925e-061 3 rs63 162.7924 2.084678 5.023893e-061 4 rs24 162.4252 1.837208 5.509042e-061 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Wednesday, August 08, 2012 3:06 PM To: Silvano Cesar da Costa Cc: R help Subject: Re: [R] NULL column HI, Try this: dat1-read.table(text= beta0 beta1 pvalor Crom rs17 158.5980 12.252462 9.083193e-135 1 rs46 163.3730 3.304276 3.279925e-06 1 rs63 162.7924 2.084678 5.023893e-06 1 rs24 162.4252 1.837208 5.509042e-06 1 ,sep=,header=TRUE) dat2-data.frame(new=rownames(dat1),dat1) rownames(dat2)-1:nrow(dat2) dat2 # new beta0 beta1 pvalor Crom #1 rs17 158.5980 12.252462 9.083193e-135 1 #2 rs46 163.3730 3.304276 3.279925e-06 1 #3 rs63 162.7924 2.084678 5.023893e-06 1 #4 rs24 162.4252 1.837208 5.509042e-06 1 A.K. - Original Message - From: Silvano Cesar da Costa silv...@uel.br To: r-help@r-project.org Cc: Sent: Wednesday, August 8, 2012 3:22 PM Subject: [R] NULL column Hi, I have a dataset where the first column has no name. I would like to assign a name to this column to be able to use it something like: Cap - NULL How can I do this? beta0 beta1 pvalor Crom rs17 158.5980 12.252462 9.083193e-135 1 rs46 163.3730 3.304276 3.279925e-06 1 rs63 162.7924 2.084678 5.023893e-06 1 rs24 162.4252 1.837208 5.509042e-06 1 How can I do this? Thanks, - 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. __ 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. - 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.
[R] regression analysis
Hi, I have to do 10,000 linear regression analysis, and the response variable (RESP) is the same for all independent variables (10,000). y ~ x[i] i = 1, ..., 1 For each analysis must extract the p-value and put them in an orderly increasing. I thought an analysis of the type: ana = numeric(1) for(i in 1:1){ mod = lm(RESP~x[i] p-value[i] = summary(mod)$coe[2,4] } Could someone suggest a reading material or any suggestions, I thank you. - 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.
[R] France Model
Hi, I need fit the France model : y = A{1 - exp[-b(t-T) - c(sqrt(t) - sqrt(T))]} parameters: A, b, T, c variable: t (time) resp: y I tried: time = 1:48 resp = rnorm(48, 200, 10) dados = data.frame(resp, time) attach(dados) f = function(x, A, b, T, c) A*(1-exp(-b*(x-T) - c*(sqrt(x) - sqrt(T (mod1 = nls(resp~f(time, A, b, c, T), data=dados, start=c(A=500, b=152, c=100, T=100))) but isn't work. The error is: (mod1 = nls(resp~f(tempo,A,b,c,T), data=dados, +start=c(A=10, b=152, c=10, T=10))) Erro em numericDeriv(form[[3L]], names(ind), env) : Obtido valor faltante ou infinito quando avaliando o modelo Somebody knows some package? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Challenge
Hi, I have the following equation: x1 + x2 + x3 - 2(x4 + x5 + x6) + 3(x7) = N each x_i can take any value: 1, 2, 3, 5, 6, 10, 15 or 30 and each one is different from each other. Which combination of values ??in the formula which leads to the smallest value of N? How can I program this situation? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Longitudinal data
Hi, I'm analyzing a longitudinal data set with 387 cows were observed in 63 days divided into 6 groups, and every 30 days was found to produce milk. Does not aim to model the time using regression. Only compare the groups differ in terms of milk production. There are many missing observations. Because the data are correlated I used the SAS program: proc mixed data=univar method=reml; class RACA GRUPO APELIDO Dias; model Prod = GRUPO / solution DDFM=BW; repeated Dias / type=arh(1) subject=APELIDO r rcorr; lsmeans GRUPO / pdiff adjust=tukey; run ; But, I want use R. What would be the equivalent in R? Thank you. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] Longitudinal data
Hi Uwe, was a great suggestion. Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Uwe Ligges lig...@statistik.tu-dortmund.de To: Silvano silv...@uel.br Cc: r-help@r-project.org Sent: Tuesday, December 27, 2011 1:13 PM Subject: Re: [R] Longitudinal data On 27.12.2011 14:43, Silvano wrote: Hi, I'm analyzing a longitudinal data set with 387 cows were observed in 63 days divided into 6 groups, and every 30 days was found to produce milk. Does not aim to model the time using regression. Only compare the groups differ in terms of milk production. There are many missing observations. Because the data are correlated I used the SAS program: proc mixed data=univar method=reml; class RACA GRUPO APELIDO Dias; model Prod = GRUPO / solution DDFM=BW; repeated Dias / type=arh(1) subject=APELIDO r rcorr; lsmeans GRUPO / pdiff adjust=tukey; run ; See package SASmixed that includes some nice examples how to move from SAS to R. Uwe Ligges But, I want use R. What would be the equivalent in R? Thank you. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. __ 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.
[R] Notation
Hi, what's mean / in command: betareg(inf~Grupo/Sexo, data=dados) it's a effect nested? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Problema with Excel files
Hi, I have a Excel file with three spreadsheets: PlanA, PlanB and PlanC. I'm trying to read the three spreadsheets and then adding them together. But, when I try read the PlanA there is an error message: rm(list=ls()) setwd('C:/Test/Dados/Teste') require(RODBC) Arquivo = odbcConnectExcel('T070206_1347.xls') (Geral = sqlFetch(Arquivo, 'PlanA')) (Lactacao = sqlFetch(Arquivo, 'PlanB')) Erro em as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format I don't know what's happening. Can anyone help me? Thanks a lot, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Fit Gompertz' curve'
Hi, I build a graph taking into account the times: 1, 2,4,6,8,10,12,15,18,21,24,28,32 and 48. Be that the scale of the X axis does not look right. It seems equidistant. (graph attached) What changes have I to do in the following commands so that the scale be correct? interaction.plot(Tempo, Trat, Valor, ylim=c(0, 2), las=1, lty=c(1,2,3,4), lwd=3, bty='l', col=c('red','blue','magenta','green'), ylab=Média de Gases, xlab=Tempo (h), trace.label=Doses) Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Using Function
Hi, I have some simple statistics to calculate for a large number of variables. I created a simple function to apply to variables. I would like the variable name to be placed automatically. I tried the following function but is not working. desc = function(x){ media = mean(x, na.rm=T) desvio = sd(x, na.rm=T) cv = desvio/media*100 saida = cbind(media, desvio, cv) colnames(saida) = c(NULL, 'Média', 'Desvio', 'CV') rownames(saida) = c(x) saida } desc(Idade) Média Desvio CV Idade 44.04961 16.9388 38.4539 How do you get the variable name is placed as the first element? My objective is get something like: rbind( desc(Altura), desc(Idade), desc(IMC), desc(FC), desc(CIRCABD), desc(GLICOSE), desc(UREIA), desc(CREATINA), desc(CTOTAL), desc(CHDL), desc(CLDL), desc(CVLDL), desc(TRIG), desc(URICO), desc(SAQRS), desc(SOKOLOW_LYON), desc(CORNELL), desc(QRS_dur), desc(Interv_QT) ) Thanks a lot, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] Tables and merge
- Original Message - From: Silvano silv...@uel.br To: r-help@r-project.org Sent: Thursday, June 30, 2011 9:07 AM Subject: Tables and merge Hi, I have 21 files which is common variable CODE. Each file refers to a question. I would like to join the 21 files into one, to construct tables for each question by CODE. I tried the command (8 files only): require(foreign) q1 = read.epiinfo('Dados/Q1.rec') q2 = read.epiinfo('Dados/Q2.rec') q3 = read.epiinfo('Dados/Q3.rec') q4 = read.epiinfo('Dados/Q4.rec') q5 = read.epiinfo('Dados/Q5.rec') q6 = read.epiinfo('Dados/Q6.rec') q7 = read.epiinfo('Dados/Q7.rec') q8 = read.epiinfo('Dados/Q8.rec') juntos = merge(q1,q2,q3,q4,q5,q6,q7,q8) But it didn't work. Any suggestions? Thank you. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Pie chart
I made a pie chart and the names of the levels are outside the circle. How do I put the names of the levels within each sector? names(tab13) = paste(c('Regular', 'Bom', 'Excelente'), round(100*prop.table(tab13), dig=1), %) pie(tab13, col=c(LightYellow, lightgreen, 'lightblue', 'white'), clockwise=F, radius=.7) Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Boxplot in order
Hi, I need construct box plot graph, but I want keep Groups order karla = data.frame( Groups = factor(rep(c('CPre','SPre','C7','S7','C14','S14','C21','S21'), 11)), Time = rep(c(0,7,14,21), 11), Resp = valor ) boxplot(Resp~Groups, order=T) doesn't work. How do this? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Hartley's table
Hi, I used the commands below to make Hartley's table, but some values are NA. require(SuppDists) trat = seq(2, 15, 1) gl = seq(2, 40, 1) har = matrix(0, nr=length(gl), nc=length(trat)) for(i in 1:length(gl)) for(j in 1:length(trat)) har[i,j] - qmaxFratio(.95, df=gl[i], k=trat[j]) rownames(har) - gl colnames(har) - trat head(har) The output (head): 2 3 4 5 6 7 2 39.00 87.488567 142.502114 202.378010 266.16460 333.18651 3 15.439182 27.758294 39.503063 50.885084 46.75297 72.83358 4 9.604530 15.457596 20.559223 25.211423 29.54387 33.62982 5 7.146382 10.751785 13.723953 NA 10.14968 20.87902 6 5.819757 8.362843 10.380280 12.108103 13.64260 15.03555 7 4.994909 6.939901 8.439993 9.697305 10.80480 11.79569 8 9101112 13 2 403.07945 475.372389 549.84302 626.22781 704.41272 784.22483 3 83.47794 93.943236 104.24551 114.40008 124.41965 80.84930 4 37.51656 41.237201 44.81356 48.26765 51.61274 54.86066 5NA 2.173131 26.64526NANA 31.62688 6 16.31888 17.514001 18.63614 19.69659 20.70403 21.66528 7 12.6 13.535307 14.31403 15.04529 15.73600 16.39159 1415 2 865.53893 948.24795 3 82.18823 83.40749 4 58.02112 61.10224 5 19.09581 34.64536 6 22.58582 23.46946 7 17.01639 17.61392 What's wrong? Thanks. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] HLM Model
Hi Belle, try this: SAS: proc mixed data=test noclprint noinfo covtest noitprint method=reml; class pair grade team school; model score = trt pair grade school / solution ddfm=bw notest; random int / sub=team solution type=un r; run; R: require(nlme) unstruct - gls(score~trt+pair+grade+school, test, correlation=corSymm(form = ~ 1 |id), weights=varIdent(form = ~ 1|team), method=REML) summary(unstruct) -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Belle ping...@gmail.com To: r-help@r-project.org Sent: Thursday, January 27, 2011 5:43 PM Subject: [R] HLM Model Hi I am trying to convert SAS codes to R, but some of the result are quite different from SAS. When I ran proc mixed, I have an option ddfm=bw followed by the model. How can I show this method in R (I am thinking that this maybe the reason that I can't get the similar results) below is my SAS codes: proc mixed data=test covtest empirical; class pair grade team school; model score = trt pair grade school/ solution covb ddfm=bw ; random int / sub=team solution type=un; run; I have tried both lmer and hglm, but non of them works. Could anyone tell me how can I covert this SAS codes to R? Thanks -- View this message in context: http://r.789695.n4.nabble.com/HLM-Model-tp3242999p3242999.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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.
[R] subset factor?
Hi, I used subset command, like this: grupoP = subset(dados, grupos=='P', select=c(mortos, vivos, doses, percevejos, p)) and the variables in select option are numeric. I tried fit a model with command: ajuste.logit = glm(cbind(mortos,percevejos)~log10(doses), family=binomial(logit), data=grupoP) and the output is: ajuste.logit = glm(cbind(mortos,percevejos)~log10(doses), family=binomial(logit), data=grupoP) Erro em Math.factor(doses) : log10 not meaningful for factors what is wrong with my commands? Why doses aren't numeric? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] subset
Hi, I have a file, like below, and I want create a new data.frame with variables: Grupos Dias Rato Esp.Inter.Trac, but Esp.Inter.Trac will be the mean of med1 med2 and med3 for each Rato. How can I do this? Grupos Dias Rato blocos Esp.Inter.Trac GFC 31 med1 85.99 GFC 32 med1 112.78 GFC 33 med1 105.43 GFC 34 med1 86.18 GFC 35 med1 135.66 GFC 36 med1 76.25 GFC 31 med2 91.08 GFC 32 med2 100.57 GFC 33 med2 131.79 GFC 34 med2 138.46 GFC 35 med2 129.78 GFC 36 med2 107.92 GFC 31 med3 85.80 GFC 32 med3 90.64 GFC 33 med3 67.36 GFC 34 med3 87.28 GFC 35 med3 99.57 GFC 36 med3 90.06 C 31 med1 81.19 C 32 med1 94.74 C 33 med1 49.18 C 34 med1 105.76 C 35 med1 82.71 C 36 med1 80.10 C 31 med2 121.30 C 32 med2 82.77 C 33 med2 99.57 C 34 med2 73.66 C 35 med2 72.89 C 36 med2 76.47 C 31 med3 99.18 C 32 med3 63.60 C 33 med3 52.17 C 34 med3 75.10 C 35 med3 75.38 C 36 med3 55.78 -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] subset
Phil, this is exactly what do I want. Thanks a lot. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Phil Spector spec...@stat.berkeley.edu To: Silvano silv...@uel.br Cc: r-help@r-project.org Sent: Wednesday, December 15, 2010 5:27 PM Subject: Re: [R] subset Silvano - If you always have exactly one med1, one med2, and one med3 for each combination of Grupos, Dias, and Rato, you can use aggregate(Esp.Inter.Trac~Grupos+Dias+ Rato,mean,data=x) Grupos Dias Rato Esp.Inter.Trac 1 C31 100.55667 2 GFC31 87.62333 3 C32 80.37000 4 GFC32 101.33000 5 C33 66.97333 6 GFC33 101.52667 7 C34 84.84000 8 GFC34 103.97333 9 C35 76.99333 10GFC35 121.67000 11 C36 70.78333 12GFC36 91.41000 If there are multiples of any of med1, med2, or med3 within any of the combinations, it would be a little trickier: one = aggregate(Esp.Inter.Trac~Grupos+Dias+Rato+blocos,mean,data=x) two = aggregate(Esp.Inter.Trac~Grupos+Dias+Rato,mean,data=one) That would still assume there was at least one value for each of med1, med2, and med3 for each combination. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Thu, 16 Dec 2010, Silvano wrote: Hi, I have a file, like below, and I want create a new data.frame with variables: Grupos Dias Rato Esp.Inter.Trac, but Esp.Inter.Trac will be the mean of med1 med2 and med3 for each Rato. How can I do this? Grupos Dias Rato blocos Esp.Inter.Trac GFC 31 med1 85.99 GFC 32 med1 112.78 GFC 33 med1 105.43 GFC 34 med1 86.18 GFC 35 med1 135.66 GFC 36 med1 76.25 GFC 31 med2 91.08 GFC 32 med2 100.57 GFC 33 med2 131.79 GFC 34 med2 138.46 GFC 35 med2 129.78 GFC 36 med2 107.92 GFC 31 med3 85.80 GFC 32 med3 90.64 GFC 33 med3 67.36 GFC 34 med3 87.28 GFC 35 med3 99.57 GFC 36 med3 90.06 C 31 med1 81.19 C 32 med1 94.74 C 33 med1 49.18 C 34 med1 105.76 C 35 med1 82.71 C 36 med1 80.10 C 31 med2 121.30 C 32 med2 82.77 C 33 med2 99.57 C 34 med2 73.66 C 35 med2 72.89 C 36 med2 76.47 C 31 med3 99.18 C 32 med3 63.60 C 33 med3 52.17 C 34 med3 75.10 C 35 med3 75.38 C 36 med3 55.78 -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. __ 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.
[R] Tukey's table
Hi, I'm building Tukey's table using qtukey function. It happens that I can't get the values of Tukey's one degree of freedom and also wanted to eliminate the first column. The program is: Trat - c(1:30) # number of treatments gl - c(1:30, 40, 60, 120) # degree freedom tukval - matrix(0, nr=length(gl), nc=length(Trat)) for(i in 1:length(gl)) for(j in 1:length(Trat)) tukval[i,j] - qtukey(.95, Trat[j], gl[i]) rownames(tukval) - gl colnames(tukval) - paste(Trat, , sep=) tukval require(xtable) xtable(tukval) Some suggest? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] step
Hi, how can I change the significance level in test F to select variable in step command? I used step(model0, ~x1+x2+x3+x4, direction=c(forward), test='F', alpha=.05) but it does't work. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] Games
Hi, I want to thank all the suggestions sent, especially that of Hans. Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Hans W Borchers hwborch...@googlemail.com To: r-h...@stat.math.ethz.ch Sent: Friday, August 13, 2010 12:29 PM Subject: Re: [R] Games Silvano silvano at uel.br writes: Hi, I want to build the table of a football league with 11 teams. All play together. So will 55 games. Since there are an odd number of teams in each round a team will not play. The easy solution is moving around a table with one team pausing. # Playing schedule for an odd number of teams n - 5 noTeams - 2*n+1 noGames - n*noTeams teams - paste(T, 1:noTeams, sep=) rounds - numeric(noGames) team1 - team2 - character(noGames) for (i in 1:noTeams) { for (j in 1:n) { k - n*(i-1)+j rounds[k] - i team1[k] - teams[j+1] team2[k] - teams[noTeams-j+1] } teams - c(teams[2:noTeams], teams[1]) } schedule - data.frame(rounds=rounds, team1=team1, team2=team2) Hans Werner The games will be: games = urnsamples(1:11, x = c('A','B','C','D','E','F','G','H','I','J','K'), size=2, replace=F, ordered=FALSE) games As will be five games per round. How to build a table with all the championship rounds, automatically? I thought about something like: game1 = c( sample(11,2) sample(11,2) sample(11,2) sample(11,2) sample(11,2) ) but, isn't work very well. Some suggestion? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. __ 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.
[R] Games
Hi, I want to build the table of a football league with 11 teams. All play together. So will 55 games. Since there are an odd number of teams in each round a team will not play. The games will be: games = urnsamples(1:11, x = c('A','B','C','D','E','F','G','H','I','J','K'), size=2, replace=F, ordered=FALSE) games As will be five games per round. How to build a table with all the championship rounds, automatically? I thought about something like: game1 = c( sample(11,2) sample(11,2) sample(11,2) sample(11,2) sample(11,2) ) but, isn't work very well. Some suggestion? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] Games
Hi, the solution presented below works, but requires some manual work to get the details right. It is still difficult. require(prob) games = urnsamples(1:11, x = c('A','B','C','D','E','F','G','H','I','J','K'), size=2, replace=F, ordered=FALSE) games (round1 = sample(55,5)) (round2 = sample(55,5)) (round3 = sample(55,5)) (round4 = sample(55,5)) (round5 = sample(55,5)) (round6 = sample(55,5)) (round7 = sample(55,5)) (round8 = sample(55,5)) (round9 = sample(55,5)) (round10 = sample(55,5)) (round11 = sample(55,5)) (round = rbind( round1, round2, round3, round4, round5, round6, round7, round8, round9, round10, round11 )) -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: peter dalgaard pda...@gmail.com To: Michael Bedward michael.bedw...@gmail.com Cc: Silvano silv...@uel.br; r-help@r-project.org Sent: Friday, August 13, 2010 10:29 AM Subject: Re: [R] Games On Aug 13, 2010, at 3:10 PM, Michael Bedward wrote: Nice question Silvano ! teams - LETTERS[1:11] matches - combn(teams, 2) draw - data.frame(team1=matches[1,], team2=matches[2,], round=sequence(10:1) + rep(0:9, times=10:1)) Is there a prize :-) Maybe you want to sponsor one, because your solution certainly doesn't work! I see 10 games in the 10th round, all involving team K. That's not how to arrange a tournament! -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ 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.
[R] xtable
Hi, How do I build a table from a regression model adjusted using xtable? Commands are: modelo1 = lm(Y~X1 + X2) influencia = influence.measures(modelo1) require(xtable) xtable(influencia) but it isn't work. Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] xtable with Sweave
Hi, I'm using Sweave to prepare a descriptive report. Are at least 20 tables built with xtable command of kind: echo=F, results=hide= q5 = factor(Q5, label=c(Não, Sim)) (q5.tab = cbind(table(q5))) @ echo=F, results=tex= xtable(q5.tab, align=l|c, caption.placement = top, table.placement='H') @ I'm getting the following message: Too many unprocessed floats in Latex file. How to avoid these messages appearing? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] Table and Sweave
Ista, I have a dataset with 148 observations and 17 variables. I used EpiData to create the database DATANASC SEXO IDADE PESO ESTATURA IMC 1955-01-20F 54.4 136 1.52 58.9 1971-04-20F 38.2 73 1.68 25.9 1919-04-25F 90.2 62 1.58 24.8 1943-07-12F 66.0 65 1.65 23.9 1987-08-07M 21.9 167 1.94 44.4 1953-11-10F 55.6 57 1.50 25.3 1973-08-06F 35.9 49 1.60 19.1 1923-12-09M 85.6 82 1.70 28.4 1947-08-25M 61.8 90 1.75 29.4 1957-08-10F 51.9 98 1.64 36.4 and so on. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Ista Zahn istaz...@gmail.com To: r-help@r-project.org Cc: Silvano silv...@uel.br Sent: Tuesday, May 11, 2010 5:48 PM Subject: Re: [R] Table and Sweave It would be easier to help if you made your example reproducible (what is IDADE and where does it come from?). -Ista On Tuesday 11 May 2010 4:22:27 pm Silvano wrote: Hi, in Latex I get the table using: \begin{table}[H] \centering \renewcommand{\arraystretch}{1.3} \setlength{\tabcolsep}{18pt} \begin{tabular}{cc} \hline IdadeFrequência \\ \hline $18 \vdash 26$11 \\ $26 \vdash 34$ 8 \\ $34 \vdash 42$26 \\ $42 \vdash 50$20 \\ $50 \vdash 58$23 \\ $58 \vdash 66$30 \\ $66 \vdash 74$17 \\ $74 \vdash 82$ 9 \\ $82 \vdash 90$ 2 \\ $90 \vdash 98$ 2 \\ \hline \end{tabular} \end{table} I tried get a similar table using Sweave, but it isn't work. The commands are: = Idade.tb = cut(IDADE, breaks=c(18,26,34,42,50,58,66,74,82,90,98), right=F) cbind(table(Idade.tb)) @ idades, echo=F, results=hide= Idade.tb = cut(IDADE, breaks=c(18,26,34,42,50,58,66,74,82,90,98), right=F) Idade_freq = cbind(table(Idade.tb)) medias.idades = tapply(IDADE, SEXO, mean) @ idade, echo=F, results=verbatim= Idade_freq @ or = xtable(Idade_freq) @ but they are not the way I want. Any suggestions? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. __ 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.
[R] Table and Sweave
Hi, in Latex I get the table using: \begin{table}[H] \centering \renewcommand{\arraystretch}{1.3} \setlength{\tabcolsep}{18pt} \begin{tabular}{cc} \hline IdadeFrequência \\ \hline $18 \vdash 26$11 \\ $26 \vdash 34$ 8 \\ $34 \vdash 42$26 \\ $42 \vdash 50$20 \\ $50 \vdash 58$23 \\ $58 \vdash 66$30 \\ $66 \vdash 74$17 \\ $74 \vdash 82$ 9 \\ $82 \vdash 90$ 2 \\ $90 \vdash 98$ 2 \\ \hline \end{tabular} \end{table} I tried get a similar table using Sweave, but it isn't work. The commands are: = Idade.tb = cut(IDADE, breaks=c(18,26,34,42,50,58,66,74,82,90,98), right=F) cbind(table(Idade.tb)) @ idades, echo=F, results=hide= Idade.tb = cut(IDADE, breaks=c(18,26,34,42,50,58,66,74,82,90,98), right=F) Idade_freq = cbind(table(Idade.tb)) medias.idades = tapply(IDADE, SEXO, mean) @ idade, echo=F, results=verbatim= Idade_freq @ or = xtable(Idade_freq) @ but they are not the way I want. Any suggestions? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Extracting a subset
Hi, I have a dataset with many variables and observations. The variable Group has two levels: C and P, the Month variable has four levels: 0, 1, 2 and 3. I want to extract a subset of the variable Weight, considering only 1 and 3 levels for Months of the Group variable. I tried the command subset but it did not work. Any suggestions? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] Extracting a subset
Hi, I used #-- # Análise do PESO - #-- pesom1 = cbind(PESO[MÊS==1]) pesom3 = cbind(PESO[MÊS==3]) #- Grupo Placebo - pesom1p = pesom1[GRUPO=='P'] pesom3p = pesom3[GRUPO=='P'] t.test(pesom1p, pesom3p, paired=T) #- Grupo Cogumelo - pesom1c = pesom1[GRUPO=='C'] pesom3c = pesom3[GRUPO=='C'] t.test(pesom1c, pesom3c, paired=T) to compare PESO between MÊS (Months) inside GRUPO (t-paired). CICLO was fixed. But, I have two CICLOS, and I would like compare PESO between MÊS==3 (CICLO 3) and MÊS==6 (CICLO 6) inside GRUPO (1 and 2). My file has (part of data): Ciclo Mês Grupo Peso 3 0 1 62.2 3 0 1 67.0 3 0 1 71.5 3 0 2 70.0 3 0 2 71.0 3 0 2 69.5 3 1 1 60.0 3 1 1 51.2 3 1 1 70.0 3 1 2 59.0 3 1 2 56.5 3 1 2 70.0 3 2 1 68.0 3 2 1 69.0 3 2 1 66.0 3 2 2 56.0 3 2 2 53.0 3 2 2 96.0 3 3 1 67.0 3 3 1 70.0 3 3 1 67.0 3 3 2 71.5 3 3 2 70.0 3 3 2 71.0 6 0 1 66.2 6 0 1 65.0 6 0 1 73.5 6 0 2 78.0 6 0 2 71.0 6 0 2 62.5 6 1 1 63.0 6 1 1 51.2 6 1 1 72.0 6 1 2 59.0 6 1 2 57.5 6 1 2 79.0 6 2 1 78.0 6 2 1 66.0 6 2 1 63.0 6 2 2 52.0 6 2 2 54.0 6 2 2 93.0 6 3 1 62.0 6 3 1 71.0 6 3 1 63.0 6 3 2 78.5 6 3 2 75.0 6 3 2 74.0 6 4 1 63.2 6 4 1 62.0 6 4 1 73.5 6 4 2 73.0 6 4 2 72.0 6 4 2 65.5 6 5 1 67.0 6 5 1 57.2 6 5 1 70.0 6 5 2 59.0 6 5 2 56.5 6 5 2 71.0 6 6 1 61.0 6 6 1 61.0 6 6 1 61.0 6 6 2 52.0 6 6 2 53.0 6 6 2 96.0 -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Ivan Calandra ivan.calan...@uni-hamburg.de To: r-help@r-project.org Sent: Monday, May 10, 2010 11:26 AM Subject: Re: [R] Extracting a subset Hi, My first suggestion would be to supply a sample data (maybe using the function dput) showing what you have, what you want to do, and what you've tried (you say that subset() didn't work but we don't know how you've typed it). Then, we'll see! Ivan Le 5/10/2010 14:35, Silvano a écrit : Hi, I have a dataset with many variables and observations. The variable Group has two levels: C and P, the Month variable has four levels: 0, 1, 2 and 3. I want to extract a subset of the variable Weight, considering only 1 and 3 levels for Months of the Group variable. I tried the command subset but it did not work. Any suggestions? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php __ 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. __ 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.
Re: [R] Latex and Stangle()
It worked very well. Thanks Frank and Ruihong, both solutions were great. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Ruihong Huang ruihong.lan...@googlemail.com To: Silvano silv...@uel.br; r-help@r-project.org Sent: Wednesday, May 05, 2010 6:29 PM Subject: Re: [R] Latex and Stangle() Hi Silvano, I think you can enable automatic line breaking of long lines by \lstinputlisting[language=R, breaklines=true]{Relatorio.R} Best, Ruihong On 05/05/2010 11:12 PM, Silvano wrote: Ruihong it very interesting, but the lines was very long. Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Ruihong Huang ruihong.lan...@googlemail.com To: r-help@r-project.org Sent: Wednesday, May 05, 2010 1:09 PM Subject: Re: [R] Latex and Stangle() Hi, I suggest you use the listings package ... \usepackage{listings} \appendix \lstinputlisting[language=R]{Relatorio.R} Best, Ruihong On 05/05/2010 02:21 PM, Silvano wrote: Hi, I'm using the Sweave and I would like include codes of the R in my LaTeX file. I extracts the R code with Stangle (), whose name is Relatorio.R but I can't include it in the Latex file as an appendix. Suggests? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. __ 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. __ 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.
[R] Latex and Stangle()
Hi, I'm using the Sweave and I would like include codes of the R in my LaTeX file. I extracts the R code with Stangle (), whose name is Relatorio.R but I can't include it in the Latex file as an appendix. Suggests? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] About logistic regression
Hi, I have a dichotomous variable (Q1) whose answers are Yes or No. Also I have 2 categorical explanatory variables (V1 and V2) with two levels each. I used logistic regression to determine whether there is an effect of V1, V2 or an interaction between them. I used the R and SAS, just for the conference. It happens that there is disagreement about the effect of the explanatory variables between the two softwares. R: q1 = glm(Q1~grau*genero, family=binomial, data=dados) anova(q1, test=Chisq) Df Deviance Resid. Df Resid. Dev P(|Chi|) NULL 202 277.82 grau 1 4.3537 201 273.46 0.03693 * genero 1 1.4775 200 271.99 0.22417 grau:genero 1 0.0001 199 271.99 0.99031 SAS: proc logistic data=psico; class genero (param=ref ref='0') grau (param=ref ref='0'); model Q1 = grau genero grau*genero / expb; run; Type 3 Analysis of Effects Wald Effect DFChi-Square Pr ChiSq grau 11.6835 0.1945 genero10.7789 0.3775 genero*grau 10.0002 0.9902 The parameters estimates are the same for both. Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) 0.191055 0.310016 0.6160.538 grau 0.562717 0.433615 1.2980.194 genero -0.355358 0.402650 -0.8830.377 grau:genero 0.007052 0.580837 0.0120.990 What am I doing wrong? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Mosaic
Hi, I have this data set: obitoss = c( 5.8,17.4,5.9,17.6,5.8,17.5,4.7,15.8, 3.8,13.4,3.8,13.5,3.7,13.4,3.4,13.6, 4.4,17.3,4.3,17.4,4.2,17.5,4.3,17.0, 4.4,13.6,5.1,14.6,5.7,13.5,3.6,13.3, 6.5,19.6,6.4,19.4,6.3,19.5,6.0,19.7) (dados = data.frame( regiao = factor(rep(c('Norte', 'Nordeste', 'Sudeste', 'Sul', 'Centro-Oeste'), each=8)), ano = factor(rep(c('2000','2001','2002','2003'), each=2)), sexo = factor(rep(c('F','M'), 4)), resp=obitoss)) I would like to make a mosaic to represent the numeric variable depending on 3 variables. Does anyone know how to do? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Hartley's table
Hi, Does anyone know how to generate Hartley's table in R? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Normality in split-plot design
Hi, I would like to test the normality of errors in an split-plot design using R. I used the following program: anava = aov(ganhos ~ Blocos + Trat*Supl + Error(Blocos/Trat)) summary(anava) bartlett.test(ganhos, Trat) bartlett.test(ganhos, Supl) How can I test the normality of the errors? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Split Plot and Tukey
Hi, I did the analysis of variance of a split-plot and the effect of treatment was significant. I would like compare treatment means using Tukey. I can't extract the mean square to apply HSD.test to use in agricolae package. anava = aov(ganhos ~ Blocos + Trat*Supl + Error(Blocos/Trat)) names(anava) summary(anava) require(agricolae) HSD.test(ganhos, Trat, df, MSerror, alpha = 0.05) Thanks -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] About scales in graphics
Hi, I'm building two graphics just changing the scale to show the graphic illusion. The first graph would be 'correct'. atend = c(410,430,450,408,408,405) names(atend) = c('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho') barplot(atend, las=1, xlab='Meses', ylab='Número de atendimentos', col='LightYellow', yaxt='n', space=0.6) axis(2, at=seq(0,450, by=50), las=1) abline(h=0, col='black', lwd=1) How should I do to get the second graph in the range 400 and Y in the columns with values below 400 do not appear on the chart? atend = c(410,430,450,408,408,405) names(atend) = c('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho') barplot(atend, las=1, xlab='Meses', ylab='Número de atendimentos', col='LightYellow',ylim=c(400,450), yaxt='n', space=0.6) axis(2, at=seq(400,450, by=10), las=1) abline(h=400, col='black', lwd=1) Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] About graphics
Hi, I'm building a graph (barplot) in which the X axis label disappears. I tried to use the option mgp of par() and I could not get the desired result. Note that want the axis labels horizontally. caes = c(37,20,19,16,75,103) names(caes) = c(Pinscher, Pastor \n Alemão, Poodle, Rottweiller, SRD, Outros) caess = sort(caes, decreasing=F) par(mar=c(3, 5.7, 1, 1), mgp=c(4.5, .5, 0), las=1) barplot(caess, cex.axis=1, cex.names=1, ylab=Raças dos Cães, xlab=Frequências, bty='l', col=LightYellow, horiz=T, xlim=c(0,120)) abline(v=0) Suggestions? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] About graphics
It was exactly what I needed, thank you. -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Duncan Murdoch murd...@stats.uwo.ca To: Silvano silv...@uel.br Cc: r-help@r-project.org Sent: Friday, February 05, 2010 1:57 PM Subject: Re: [R] About graphics On 05/02/2010 10:48 AM, Silvano wrote: Hi, I'm building a graph (barplot) in which the X axis label disappears. I tried to use the option mgp of par() and I could not get the desired result. Note that want the axis labels horizontally. caes = c(37,20,19,16,75,103) names(caes) = c(Pinscher, Pastor \n Alemão, Poodle, Rottweiller, SRD, Outros) caess = sort(caes, decreasing=F) par(mar=c(3, 5.7, 1, 1), mgp=c(4.5, .5, 0), las=1) You've set margin 1 too small. The barplot() function puts the x axis label quite far from the plot, so you need something like par(mar=c(6.1, 5.7, 1, 1), mgp=c(4.5, .5, 0), las=1) to give room for it. I think it would look better with the label closer, which you can do using mtext(Frequências, side=1, line=3) (and this would work with a smaller margin, but not as small as 3). For example, caes = c(37,20,19,16,75,103) names(caes) = c(Pinscher, Pastor \n Alemão, Poodle, Rottweiller, SRD, Outros) caess = sort(caes, decreasing=F) par(mar=c(4.5, 5.7, 1, 1), mgp=c(4.5, .5, 0), las=1) barplot(caess, cex.axis=1, cex.names=1, ylab=Raças dos Cães, xlab=, bty='l', col=LightYellow, horiz=T, xlim=c(0,120)) mtext(Frequências,side=1, line=3) abline(v=0) barplot(caess, cex.axis=1, cex.names=1, ylab=Raças dos Cães, xlab=Frequências, bty='l', col=LightYellow, horiz=T, xlim=c(0,120)) abline(v=0) Suggestions? -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. __ 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.
[R] Bartlett' test
Hi, I have an experiment with 5 treatments, of which 2 with 10 repetitions and 2 with 7 replications. I conducted the test of Bartlett step-by-step and compared with the value calculated directly by the R and the values are different. Anyone know tell me why? #--- n = length(trat) I = 4 (M = 2.3026*((n-I)*log10(mean(tapply(valor,trat,var))) - (9*log10(vari[1])+9*log10(vari[2])+6*log10(vari[3])+6*log10(vari[4] (C = 1 + 1/(3*(4-1))*((1/9 + 1/9 + 1/6 + 1/6) - 1/(9+9+6+6))) (B = M/C) B 1.748670 qchisq(.05, 3, lower.tail=F)# Valor tabelado [1] 7.814728 #- # Teste de Bartlett de forma direta no R - #- bartlett.test(valor,trat) Bartlett test of homogeneity of variances data: valor and trat Bartlett's K-squared = 0.7845, df = 3, p-value = 0.8532 Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] Tests in Anova
Sarah and Dennis, thank you for help and page reference. Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
[R] Tests in Anova
Hi, how can I make tests like Dunnett and Duncan using R? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.
Re: [R] boxplot, data frame and html
Gregoire, it worked very well, thanks -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Gregoire Pau gregoire@embl.de To: r-help@r-project.org Cc: Silvano silv...@uel.br Sent: Wednesday, October 28, 2009 10:08 AM Subject: Re: [R] boxplot, data frame and html Hello Silvano, 'hwrite' appends HTML elements in a web page. The web page has to be opened before adding elements in it. The following code should work: require(hwriter) p = openPage('T1000.html') hwrite(t1000[,c(1,5,6)], p, bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) hwriteImage('caixa.jpg', p, br=TRUE) hwrite('', p, br=TRUE) closePage(p) Greg --- Gregoire Pau EMBL Research Officer http://www.ebi.ac.uk/~gpau/ Silvano wrote: Hi, I'm trying put in same page: - a data frame with 3 columns and 45 lines; - a box plot; the code is: require(hwriter) hwrite(t1000[,c(1,5,6)], 'T1000.html', bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) p = openPage('T1000.html') hwriteImage('caixa.jpg', p, br=TRUE) hwrite('',p, br=TRUE) closePage(p) but isn't working. What's wrong? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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. __ 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.
[R] boxplot, data frame and html
Hi, I'm trying put in same page: - a data frame with 3 columns and 45 lines; - a box plot; the code is: require(hwriter) hwrite(t1000[,c(1,5,6)], 'T1000.html', bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) p = openPage('T1000.html') hwriteImage('caixa.jpg', p, br=TRUE) hwrite('',p, br=TRUE) closePage(p) but isn't working. What's wrong? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 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.