Last active
November 4, 2015 13:25
-
-
Save kmader/55ea701c9a49592f7ff6 to your computer and use it in GitHub Desktop.
KNIME Shape Node Histogram Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(reshape2) | |
library(plyr) | |
library(dplyr) | |
cd.df<- knime.in %>% | |
select(Label,starts_with("CentroidDistance")) %>% | |
melt(id.vars="Label") %>% | |
ddply(.(Label), | |
function(in.df) mutate(in.df, | |
norm.value=value/sum(value), | |
norm.vis=max(norm.value)-min(norm.value), | |
std.vis=(max(value)-min(value))/mean(value) | |
) | |
) %>% | |
mutate(vcnt=as.numeric(variable),lcnt=as.numeric(Label)) %>% | |
subset(!is.na(norm.value)) | |
knime.in.clean<-knime.in %>% select(-contains("CentroidDistance")) | |
names(knime.in.clean)<-names(knime.in.clean) %>% llply(function(cname) gsub("\\s",".",cname)) | |
comb.df<-knime.in.clean %>% merge(cd.df) | |
comb.df %>% summary | |
ggplot(comb.df %>% mutate(volgrp=cut_number(std.vis,4)), | |
aes(x=vcnt,weight=norm.value,color=lcnt))+ | |
geom_density(aes(group=Label))+ | |
facet_wrap(~volgrp)+ | |
theme_bw(20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(reshape2) | |
library(plyr) | |
library(dplyr) | |
knime.out<- knime.in %>% | |
select(Label,starts_with("CentroidDistance")) %>% | |
ddply(.(Label), | |
function(raw.df) | |
{ | |
in.df<-raw.df %>% melt(id.vars="Label") | |
mutate(in.df, | |
norm.value=value/sum(value), | |
norm.vis=max(norm.value)-min(norm.value), | |
std.vis=(max(value)-min(value))/mean(value) | |
)[1,,drop=F] | |
}) %>% | |
subset(!is.na(norm.value)) %>% | |
mutate(vis.class=cut_number(std.vis,4)) %>% | |
select(-variable,-value,-norm.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment