Skip to content

Commit

Permalink
convert treemap when only one level deep
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Oct 15, 2015
1 parent e8c1ad0 commit 8ad4ed3
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions R/converters.R
Expand Up @@ -18,17 +18,25 @@ convert_treemap <- function( treemap, rootname = "root" ){
}
),stringsAsFactors = F)

treemap$pathString <- apply(
treemap[,1:(attrPos-1)]
,MARGIN = 1
,function(row){
paste0(
c( rootname, row[which(!is.na(row))] )
,sep = "/~>/" # assume this will not exist
,collapse=""
)
}
)
if(attrPos > 2){
treemap$pathString <- apply(
treemap[,1:(attrPos-1)]
,MARGIN = 1
,function(row){
paste0(
c( rootname, row[which(!is.na(row))] )
,sep = "/~>/" # assume this will not exist
,collapse=""
)
}
)
} else {
treemap$pathString <- paste(
rootname
,treemap[,1]
,sep = "/~>/"
)
}

dt <- as.Node(
treemap[,-(1:(attrPos-1))]
Expand Down

0 comments on commit 8ad4ed3

Please sign in to comment.