[R] Save the result of map.market function to HTML file?

valerio orfano ingorfano at hotmail.com
Thu Jun 4 09:52:43 CEST 2015


Belowe My code:

treemap.R
------------------------------------
library(portfolio)
library(sendmailR)
setwd("C:/Users/Administrator/Desktop")
data_all <- read.csv("prova_data.txt", sep='\t', stringsAsFactors = FALSE)
distinctstorage <- unique(data_all$Storage)
stor_var <- "Storage001"

filename <- paste(stor_var,".png",sep='')

png(filename)
print (stor_var)
data = data_all[data_all$Storage == stor_var,]
capacity <- data[data$Id == 'Capacity','size']
data <- data[data$Id != 'Capacity',]
storage <- data$Storage[1]
disk_used <- sum(data$size)
data$col <- seq(1,nrow(data),1)
col_free <- max(data$col + 1)
space_free <- capacity - disk_used
if (space_free < 1000)
{
col_free <- -17
}
data = rbind(data,c('Free',storage,free_space,col_free))
data$col <- as.numeric(data$col)
data$size <- as.numeric(data$size)
map.market(id = data$Id, area = data$size, group = data$Storage, color = data$col, lab=c(TRUE,TRUE), main="Test Map")
dev.off()



Script.R
———————————————
library(prettyR)
setwd("C:/Users/Administrator/Desktop")
htmlize("treemap.R","treemap")

Belowe the error i get

 htmlize("treemap.R","treemap")
Error in .geometry(width, height, units, res) : 
  object 'NAStorage001.png' not found


[[elided Hotmail spam]]

rgds valerio

On 04 Jun 2015, at 02:12, Jim Lemon <drjimlemon at gmail.com> wrote:

> Hi valerio,
> Any chance of letting me know how "it didn't work out"? For example
> your code and the resulting error message.
> 
> Jim
> 
> 
> On Wed, Jun 3, 2015 at 10:32 PM, valerio orfano <ingorfano at hotmail.com> wrote:
[[elided Hotmail spam]]
>> 
>> any other help?
>> 
>> rgds valerio
>> On 03 Jun 2015, at 02:29, Jim Lemon <drjimlemon at gmail.com> wrote:
>> 
>>> Hi valerio,
>>> This is a guess, but try running your code with "htmlize" (prettyR).
>>> Change the "pdf" call to:
>>> 
>>> png("C:/Users/Administrator/Desktop/treemap1.png")
>>> map.market(id = data1$Id, area = data1$size, group = data1$Storage,
>>> color = data1$col, lab=c(TRUE,TRUE), main="Test Map")
>>> dev.off()
>>> png("C:/Users/Administrator/Desktop/treemap2.png")
>>> map.market(id = data2$Id, area = data2$size, group = data2$Storage,
>>> color = data2$col, lab=c(TRUE,TRUE), main="Test Map")
>>> dev.off()
>>> png("C:/Users/Administrator/Desktop/treemap3.png")
>>> map.market(id = data3$Id, area = data3$size, group = data3$Storage,
>>> color = data3$col, lab=c(TRUE,TRUE), main="Test Map")
>>> dev.off()
>>> 
>>> as I think you are producing three images.
>>> 
>>> # assume the code above is in a file "vo.R" in the R working directory
>>> library(prettyR)
>>> htmlize("vo.R")
>>> 
>>> This should produce a file "vo.html" with the plots in it.
>>> 
>>> Jim
>>> 
>>> On Wed, Jun 3, 2015 at 1:49 AM, valerio orfano <ingorfano at hotmail.com> wrote:
>>>> HI All,
>>>> 
>>>> i need to call the tree map function in R to display my multiple disks usage, using ‘portfolio' library. I need furthermore to generate multiple page each showing the treemap of each disk. It works fine if use pdf file , but my boss wants to save the result into an html file. Any help? I’ve tried with R2HTML library without success. The output of map.market is a ‘gTree' object. Any help is appreciated.
>>>> 
>>>> library(portfolio)
>>>> data1 <- read.csv("C:/Users/Administrator/Desktop/prova_data1.txt", sep='\t', stringsAsFactors = FALSE)
>>>> data2 <- read.csv("C:/Users/Administrator/Desktop/prova_data2.txt", sep='\t', stringsAsFactors = FALSE)
>>>> data2 <- read.csv("C:/Users/Administrator/Desktop/prova_data3.txt", sep='\t', stringsAsFactors = FALSE)
>>>> pdf("C:/Users/Administrator/Desktop/treemap.pdf")
>>>> map.market(id = data1$Id, area = data1$size, group = data1$Storage, color = data1$col, lab=c(TRUE,TRUE), main="Test Map")
>>>> map.market(id = data2$Id, area = data2$size, group = data2$Storage, color = data2$col, lab=c(TRUE,TRUE), main="Test Map")
>>>> map.market(id = data3$Id, area = data3$size, group = data3$Storage, color = data3$col, lab=c(TRUE,TRUE), main="Test Map")
>>>> dev.off()
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>> 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.
>> 



More information about the R-help mailing list