Displaying 2 results from an estimated 2 matches for "norm_valu".
Did you mean:
norm_value
2024 Dec 10
1
Heat maps containing two types of variables
...long <- pivot_longer(dat,2:4,names_to="variable",values_to="value")
normalize <- function(x) { y <- (x-min(x))/(max(x)-min(x)) }
dat_norm <- mutate(dat,across(2:4,normalize))
dat_long_norm <-
pivot_longer(dat_norm,2:4,names_to="variable",values_to="norm_value")
dat_long <- inner_join(dat_long,dat_long_norm,by=c("date","variable"))
heatmap <- ggplot(dat_long, aes(x = date, y = variable,fill=norm_value))
+
geom_tile() +
geom_text(aes(label = as.character(value)),
color = "black", size = 2.5) +
labs(...
2011 Jun 03
0
ragged data.frame? using plyr
...letters[1:10],value=rnorm(1000),day=c(rep(1,100),rep(2,100),rep(3,100),rep(4,100),rep(5,100)))
I want to "normalise" it using the following function (unless you have
a better idea...):
adj.values<-function(dframe){
value_mean<-mean(dframe$value)
value_sd<-sd(dframe$value)
norm_value<-(dframe$value-value_mean)/value_sd
score_scale<-100
score_offset<-1000
scaled_value<-norm_value*score_scale+score_offset
names(scaled_value)<-dframe$id
return(scaled_value)
}
score_out<-ddply(dat,.(day),adj.values)
Gives me my data.frame all nice and pretty and ready...