[R] HTML nsmall vector format problem
Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] HTML nsmall vector format problem
John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] HTML nsmall vector format problem
Hi Tom Thanks for the reply. I see what you are saying - that format does not format using an nsmall vector, though the documentation (of HTML.data.frame) and the example suggest nsmall uses a vector. Even if I went through and changed the columns with a loop the HTML.data.frame would reformat them according to its formatting so I would still get all the columns with one value of nsmall. Specifically I want 0 for my first three columns and 4 for the remaining columns in my data frame. (I would also like to control the widths but I guess I may run into the same problem). I could reprocess the HTML output but that makes generating the HTML a bit redundant! Regards John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tshort Sent: 09 June 2006 11:54 To: r-help@stat.math.ethz.ch Subject: Re: [R] HTML nsmall vector format problem John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4 791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] HTML nsmall vector format problem
John, you can use format ahead of time (this converts to character columns, so HTML won't reformat), and then use HTML: z=format(iris[1:2,1:2],nsmall=3) z[,2]=format(iris[1:2,2],nsmall=1) HTML(z,file=) - Tom -Original Message- From: john seers (IFR) [mailto:[EMAIL PROTECTED] Sent: Friday, June 09, 2006 7:19 AM To: Short, Tom; r-help@stat.math.ethz.ch Subject: RE: [R] HTML nsmall vector format problem Hi Tom Thanks for the reply. I see what you are saying - that format does not format using an nsmall vector, though the documentation (of HTML.data.frame) and the example suggest nsmall uses a vector. Even if I went through and changed the columns with a loop the HTML.data.frame would reformat them according to its formatting so I would still get all the columns with one value of nsmall. Specifically I want 0 for my first three columns and 4 for the remaining columns in my data frame. (I would also like to control the widths but I guess I may run into the same problem). I could reprocess the HTML output but that makes generating the HTML a bit redundant! Regards John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tshort Sent: 09 June 2006 11:54 To: r-help@stat.math.ethz.ch Subject: Re: [R] HTML nsmall vector format problem John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4 791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] HTML nsmall vector format problem
Hi Tom Excellent! Exactly what I need. I see what you mean now. Thanks very much for your help. John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: Short, Tom [mailto:[EMAIL PROTECTED] Sent: 09 June 2006 12:36 To: john seers (IFR); r-help@stat.math.ethz.ch Subject: RE: [R] HTML nsmall vector format problem John, you can use format ahead of time (this converts to character columns, so HTML won't reformat), and then use HTML: z=format(iris[1:2,1:2],nsmall=3) z[,2]=format(iris[1:2,2],nsmall=1) HTML(z,file=) - Tom -Original Message- From: john seers (IFR) [mailto:[EMAIL PROTECTED] Sent: Friday, June 09, 2006 7:19 AM To: Short, Tom; r-help@stat.math.ethz.ch Subject: RE: [R] HTML nsmall vector format problem Hi Tom Thanks for the reply. I see what you are saying - that format does not format using an nsmall vector, though the documentation (of HTML.data.frame) and the example suggest nsmall uses a vector. Even if I went through and changed the columns with a loop the HTML.data.frame would reformat them according to its formatting so I would still get all the columns with one value of nsmall. Specifically I want 0 for my first three columns and 4 for the remaining columns in my data frame. (I would also like to control the widths but I guess I may run into the same problem). I could reprocess the HTML output but that makes generating the HTML a bit redundant! Regards John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tshort Sent: 09 June 2006 11:54 To: r-help@stat.math.ethz.ch Subject: Re: [R] HTML nsmall vector format problem John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4 791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html