[R] [R-pkgs] WriteXLS Version 3.0.0 Released

Marc Schwartz marc_schwartz at me.com
Wed Jul 24 14:27:56 CEST 2013


On Jul 23, 2013, at 5:40 PM, cognizio <geoff at uyleman.com> wrote:

> Great summary! It works great without the heavy PERL library. I am running
> the YAML package I thought I needed to support WRITEXLS. Do I need it or is
> YAML not a dependency? 
> 
> Other question is on your last point: 'WRITEXLS COMMENT:' now shows up
> across the first row of the data output in the XLS. How do I modify these
> values? 
> 
> Thx!
> 
> Cog  


Hi,

There is no direct dependency on YAML.

The comments that appear in the first row in Excel are based upon the use of the ?comment function, which adds a 'comment' attribute to the columns of the data frame. If that attribute is present on one or more columns, an Excel comment will be created for the columns that have it.

There is an example of this in ?WriteXLS:

    # Example using comment()
    # Commented cells with have a small red triangle in the
    # upper right hand corner of the cell. Click on the cell
    # or place the cursor over the cell to see the pop-up
    # containing the comment text.
    # Create an XLSX (Excel 2007) file
    # Adjust the column widths
    # Bold the header row
    comment(iris$Sepal.Length) <- "Length of the sepals (cm)"
    comment(iris$Sepal.Width) <- "Width of the sepals (cm)"
    comment(iris$Petal.Length) <- "Length of the petals (cm)"
    comment(iris$Petal.Width) <- "Width of the petals (cm)"
    comment(iris$Species) <- "Species of the flowers"
    WriteXLS("iris", "iriscomments.xlsx", AdjWidth = TRUE, BoldHeaderRow = TRUE)


The 'comment' attribute is not seen when printing the data frame, but can be seen when using ?str to print the structure of the data frame:

> str(iris)
'data.frame':	150 obs. of  5 variables:
 $ Sepal.Length: atomic  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
  ..- attr(*, "comment")= chr "Length of the sepals (cm)"
 $ Sepal.Width : atomic  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
  ..- attr(*, "comment")= chr "Width of the sepals (cm)"
 $ Petal.Length: atomic  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
  ..- attr(*, "comment")= chr "Length of the petals (cm)"
 $ Petal.Width : atomic  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
  ..- attr(*, "comment")= chr "Width of the petals (cm)"
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "comment")= chr "Species of the flowers"



Regards,

Marc Schwartz



More information about the R-help mailing list