Hi: I am going through some of the xtable examples and I can't make the one below work. I need to create a longtable on the fly keeping the column headers for all the pages and I thought this example could give some ideas on how to do it. I am using Sweave and xtable to create my tables and graphics. I wonder if someone could tell me what's wrong. Thanks ## Not run: \begin{small} \setlongtables \begin{longtable}{ <<results=tex,fig=FALSE>>cat(paste(c('c', rep('cc', 34/2-1), 'c'), collapse='@{\hspace{2pt}}')) @ } \hline \endhead \hline \endfoot <<results=tex,fig=FALSE>>library(xtable) set.seed(2345) res <- matrix(sample(0:9, size=34*90, replace=TRUE), ncol=34, nrow=90) xres <- xtable(res) digits(xres) <- rep(0, 35) addtorow <- list() addtorow$pos <- list() addtorow$pos[[1]] <- c(seq(4, 40, 5), seq(49, 85, 5)) addtorow$pos[[2]] <- 45 addtorow$command <- c('\vspace{2mm} \n', '\newpage \n') print(xres, add.to.row=addtorow, include.rownames=FALSE, include.colnames=FALSE, only.contents=TRUE, hline.after=NULL) @ \end{longtable} \end{small} ## End(Not run) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA
Unfortunately a little long Try this (I have used Miktex 2.7 on win XP and R 2.8 for this) I have not gone into the detail of the first chunk I just created the header strings in R and copied to make the Sweave file lines With a little thought it can be done I suppose ## Sweave script \documentclass[10pt,a4paper,landscape]{article} \usepackage[T1]{fontenc} \usepackage{textcomp} \usepackage{times} \usepackage[left=0.5in,right=0.5in,top=1.0in,bottom=1.0in,includefoot]{geometry} \usepackage{dcolumn} \usepackage{booktabs} \usepackage{longtable} \setlength{\parindent}{0pt} % BEGIN DOCUMENT \begin{document} \begin{small} \begin{longtable}[34]{rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr} % if want different first 1 \toprule \addlinespace[5pt] 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 & 27 & 28 & 29 & 30 & 31 & 32 & 33 & 34 \\ \addlinespace[3pt] \midrule \addlinespace[5pt] \endfirsthead % all table headers (if not first different use \toprule instead on the next line) \midrule \addlinespace[5pt] 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 & 27 & 28 & 29 & 30 & 31 & 32 & 33 & 34 \\ \addlinespace[3pt] \midrule \addlinespace[5pt] \endhead % last footer \addlinespace[5pt] \bottomrule \endlastfoot % other footers \addlinespace[5pt] \multicolumn{33}{r}{Continued next page}\\ \addlinespace[3pt] \midrule \endfoot % <<results=tex, echo=F>> library(xtable) set.seed(2345) res <- matrix(sample(0:9, size=34*90, replace=TRUE), ncol=34, nrow=90) x <- apply(res,1,function(x) paste(paste(x,collapse= " & "), "\\\\ \n") ) for (j in seq_along(x) ) cat(x[j]) @ \end{longtable} \end{small} % END DOCUMENT \end{document} # end Sweave Regards Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email (home): mackay at northnet.com.au At 06:30 9/01/2009, you wrote:>Hi: >I am going through some of the xtable examples and I can't make the one >below work. I need to create a longtable on the fly keeping the column >headers for all the pages and I thought this example could give some ideas >on how to do it. I am using Sweave and xtable to create my tables and >graphics. I wonder if someone could tell me what's wrong. Thanks > >## Not run: >\begin{small} >\setlongtables >\begin{longtable}{ ><<results=tex,fig=FALSE>>>cat(paste(c('c', rep('cc', 34/2-1), 'c'), collapse='@{\hspace{2pt}}')) >@ >} >\hline >\endhead >\hline >\endfoot ><<results=tex,fig=FALSE>>>library(xtable) >set.seed(2345) >res <- matrix(sample(0:9, size=34*90, replace=TRUE), ncol=34, nrow=90) >xres <- xtable(res) >digits(xres) <- rep(0, 35) >addtorow <- list() >addtorow$pos <- list() >addtorow$pos[[1]] <- c(seq(4, 40, 5), seq(49, 85, 5)) >addtorow$pos[[2]] <- 45 >addtorow$command <- c('\vspace{2mm} \n', '\newpage \n') >print(xres, add.to.row=addtorow, include.rownames=FALSE, >include.colnames=FALSE, only.contents=TRUE, hline.after=NULL) >@ >\end{longtable} >\end{small} >## End(Not run) > > >Felipe D. Carrillo >Supervisory Fishery Biologist >Department of the Interior >US Fish & Wildlife Service >California, USA > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
Dear ALL suppose "x=7.5",and i need of only integer part of variable "x" that is "7" only then what command i can use in R. THANKS Zahid Khan Lecturer in Statistics Department of Mathematics Hazara University Mansehra. [[alternative HTML version deleted]]
?floor -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of zahid khan Sent: Wednesday, January 14, 2009 8:34 AM To: r-help at stat.math.ethz.ch Subject: [R] help Dear ALL suppose "x=7.5",and i need of only integer part of variable "x" that is "7" only then what command i can use in R. THANKS Zahid Khan Lecturer in Statistics Department of Mathematics Hazara University Mansehra. [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ================================== P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S. News & World Report (2008). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use\...{{dropped:13}}
Hi r-help-bounces at r-project.org napsal dne 14.01.2009 14:34:14:> Dear ALL > suppose "x=7.5",and i need of only integer part of variable "x" that is"7"> only then what command i can use in R.If you looked at help page for integer you would quickly find links to trunc, round, floor, ceiling which could be used to get some kind of integer value, depending on what you want to do with them. probably trunc(x) Regards Petr> THANKS > > Zahid Khan > Lecturer in Statistics > Department of Mathematics > Hazara University Mansehra. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Be careful there if the original data contains negative numbers. As per ?floor: takes a single numeric argument x and returns a numeric vector containing the largest integers not greater than the corresponding elements of x. Thus: x <- seq(-2, 2, 0.25)> x[1] -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 [12] 0.75 1.00 1.25 1.50 1.75 2.00> floor(x)[1] -2 -2 -2 -2 -1 -1 -1 -1 0 0 0 0 1 1 1 1 2 Compare that with using trunc(): takes a single numeric argument x and returns a numeric vector containing the integers formed by truncating the values in x toward 0.> trunc(x)[1] -2 -1 -1 -1 -1 0 0 0 0 0 0 0 1 1 1 1 2 Note that each returns a numeric (not integer) data type, albeit rounded to the appropriate whole integer value. In R code, that is typically a non-issue. HTH, Marc Schwartz on 01/14/2009 08:55 AM Nutter, Benjamin wrote:> ?floor > > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of zahid khan > Sent: Wednesday, January 14, 2009 8:34 AM > To: r-help at stat.math.ethz.ch > Subject: [R] help > > Dear ALL > suppose "x=7.5",and i need of only integer part of variable "x" that is > "7" only then what command i can use in R. > THANKS >
hi everyone, Please help me to calculate copula in R . I already have the data but I don't know how to manipulate it..please do reply...I really need your help.
Hi, All, I want to construct a pareto chart for my data. My data has two columns: modules and defects(each module has several defects). Now I use pareto.chart to create a chart for defects which y axis is cumulative percentage of defect, and x axis is value of defect. That is not what I want. I need the x axis be percentage of modules. Is there any way that I can change the scale of x axis, that make x axis be percent scale for modules, like 0% to 100% modules. So that I can directly read the chart, is that 20% modules contains 80% defect. Or, is there any function that I can use to achive it directly? Thank you in advanced! Hedy
Since we have no idea what your data looks like, you can create a plot and then apply your own axis. You might also be able to rescale the x-axis data to be a percentage to start with. It is all doable depending on what you input looks like and what you want your output to look like. That is the beauty of R. On Mon, Jan 26, 2009 at 11:33 PM, Huihua Lu <hlu3 at mix.wvu.edu> wrote:> Hi, All, > > I want to construct a pareto chart for my data. My data has two > columns: modules and defects(each module has several defects). Now I > use pareto.chart to create a chart for defects which y axis is > cumulative percentage of defect, and x axis is value of defect. That > is not what I want. I need the x axis be percentage of modules. Is > there any way that I can change the scale of x axis, that make x axis > be percent scale for modules, like 0% to 100% modules. So that I can > directly read the chart, is that 20% modules contains 80% defect. Or, > is there any function that I can use to achive it directly? > Thank you in advanced! > > Hedy > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Hi everybody! I´m with a problem that probably is easy for you but I really don´t know how to solve. On the following script: for(j in 1:length(limiares)) { excessos<-limiares[j]-estacao[estacao<limiares[j]] par.ests<-gpd(-(estacao),threshold=-limiares[j],method=c("pwm"))$par.est GOF.test<-ks.test(excessos,"pgpd",xi=par.ests[1],beta=par.ests[2])$p.value tabs[j,]<-c(par.ests,gpd(-(estacao),threshold=-limiares[j],method=c("pwm"))$par.ses,GOF.test,length(excessos)) } I´ve found the error for some values of i: Erro em ks.test(excessos, "pgpd", xi = par.ests[1], beta = par.ests[2]) : NA/NaN/Inf em chamada de função externa (argumento 1) *My question is: This warning stop the "for" and I don´t want it, is there some way to continue the "for", and for the cases where the function cannot calculate the ks.test for the i just leave a NA as answer???* Thank you *very much*!!! Alexandra Almeida -- Alexandra R M de Almeida [[alternative HTML version deleted]]
Hi everybody! I´m with a problem that probably is easy for you, but I really don´t know how to solve. On the following script: for(j in 1:length(limiares)) { excessos<-limiares[j]-estacao[estacao<limiares[j]] par.ests<-gpd(-(estacao),threshold=-limiares[j],method=c("pwm"))$par.est GOF.test<-ks.test(excessos,"pgpd",xi=par.ests[1],beta=par.ests[2])$p.value tabs[j,]<-c(par.ests,gpd(-(estacao),threshold=-limiares[j],method=c("pwm"))$par.ses,GOF.test,length(excessos)) } I´ve found the error for some values of i: Erro em ks.test(excessos, "pgpd", xi = par.ests[1], beta = par.ests[2]) : NA/NaN/Inf em chamada de função externa (argumento 1) *My question is: This warning stop the "for" and I don´t want it, is there some way to continue the "for", and for the cases where the function cannot calculate the ks.test for the i just leave a NA as answer???* Thank you *very much*!!! Alexandra Almeida -- Alexandra R M de Almeida [[alternative HTML version deleted]]