Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graphs inside a log file

    Dear all,

    I have read around that there is some trouble in adding graphs in log files (or whichever other format which combines text&images in stata results): for example, that you can do something close with HTML
    http://www.stata.com/statalist/archi.../msg00498.html

    I would like to know which is the state of the art of this matter or it is better to develop it with another program like R.

    Thank you in advance

    Joan Marc

  • #2
    joan marc at the risk of stepping into a flame war, I'd say the question you ask appears to be biased on face. You're absolutely free to develop with the R language, and Roger Newson has even developed a program for passing commands back and forth between Stata and R

    [CODE]
    ssc desc rsource
    [CODE]

    I've not been able to start working on any parsers just yet, but I'd venture to say that the HTML support in Stata is a bit more robust than that provided by the interfaces to which I believe you are referring. For example, if you install libhtml (available from SSC) and describe the contents of the library:

    Code:
    ssc inst libhtml
    libhtml, replace lib c
    mata:
    mata d using libhtml
    You would see a segment of the output like:

    Code:
           6,476   auto classdef scalar        img()
               64   auto string scalar           ::getAlign()
               64   auto string scalar           ::getAlt()
               64   auto string scalar           ::getBorder()
               64   auto string scalar           ::getClassArgs()
               92   auto string scalar           ::getClose()
               64   auto string scalar           ::getCrossorigin()
               64   auto string scalar           ::getHeight()
               64   auto string scalar           ::getHspace()
               64   auto string scalar           ::getIsmap()
               64   auto string scalar           ::getLongdesc()
               92   auto string scalar           ::getOpene()
               92   auto string scalar           ::getOpens()
               64   auto string scalar           ::getSrc()
               64   auto string scalar           ::getUsemap()
               64   auto string scalar           ::getVspace()
               64   auto string scalar           ::getWidth()
              260   auto void                    ::new()
            1,080   auto string scalar           ::print()
              372   auto class scalar            ::setAlign()
              188   auto class scalar            ::setAlt()
              192   auto class scalar            ::setBorder()
              140   auto class scalar            ::setClassArgs()
              284   auto class scalar            ::setCrossorigin()
              192   auto class scalar            ::setHeight()
              192   auto class scalar            ::setHspace()
              192   auto class scalar            ::setIsmap()
              192   auto class scalar            ::setLongdesc()
              188   auto class scalar            ::setSrc()
              192   auto class scalar            ::setUsemap()
              192   auto class scalar            ::setVspace()
              192   auto class scalar            ::setWidth()
    Which describes each of the accessor methods for the img class (e.g., <img ...>...</img>). The library is a mapping of the W3C HTML standards and with few exceptions the classes have identical names to the tag elements. In this case you could create an image tag with the necessary information with something like:

    Code:
    mata:
    graph = img()
    : graph.setSrc("../relative/Path/to/GraphOutput/mygraph.png").setWidth("900px").setHeight("600px").print()
      \x0a<img height="600px" src="../relative/Path/to/GraphOutput/mygraph.png" width="900px"></img>\x0a
    You don't need to call the print method immediately, but calling it handles placing the appropriate attributes in the correct locations, and in other cases (bold text for example):

    Code:
    : boldtext = strong()
    
    : boldtext.setClassArgs("This text would show up in bold type face in an HTML document.").print()
      \x0a<strong>This text would show up in bold type face in an HTML document.</strong>\x0a
    you can accomplish the same functionality with a consistent interface. R does integrate with a lot of other tools already, but if you know the current tool why not spend some of your development efforts to help build similar capacity for this user community?

    Comment

    Working...
    X