[R] HTML nsmall vector format problem

john seers (IFR) john.seers at bbsrc.ac.uk
Fri Jun 9 13:18:42 CEST 2006



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 john.seers at bbsrc.ac.uk                         
e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ 
 
Web sites:

www.ifr.ac.uk   
www.foodandhealthnetwork.com


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of tshort
Sent: 09 June 2006 11:54
To: r-help at 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
1        5.100       3.500
2        4.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> <tr><td class=firstcolumn>1</td><td
> class=cellinside>5.100</td><td class=cellinside>3.500</td></tr>
>  <tr><td class=firstcolumn>2</td><td class=cellinside>4.900</td><td
> class=cellinside>3.000</td></tr>
> 
> My understanding of how nsmall works, as a vector, the output should
be
> something like:
>  
> </tr> <tr><td class=firstcolumn>1</td><td
class=cellinside>5.100</td><td
> class=cellinside>3.5</td></tr>
>  <tr><td class=firstcolumn>2</td><td class=cellinside>4.900</td><td
> class=cellinside>3.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 john.seers at bbsrc.ac.uk                         
> 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 at 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 at 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



More information about the R-help mailing list