我试图分别打印所有三列的归一化值。为此,我使用了for循环,相反,我仅获得具有打印功能的最后一列,而没有列没有打印功能。如何获得所有输出分开??
library(tibble)
data_frame<-tibble(c1=rnorm(50,4,2),
c2=rnorm(50,4,2),
c3=rnorm(50,4,2))
normalize<-function(l)
{
(l-min(l))/(max(l)-min(l))
}
for (i in length(data_frame))
{
normalize(data_frame[i])
}
答案 0 :(得分:1)
尝试$(document).ready(function(){
$(window).on("scroll",function(){
var wn = $(window).scrollTop();
if(wn > 100){
$(".semplice-navbar").css("border-bottom-color:","rgba(0,0,0,1)");
}
else{
$(".semplice-navbar").css("border-bottom-color:","rgba(0,0,0,0)");
}
mutate_all
或
library(dplyr)
normalize <- function(x) (x - min(x)) / (max(x) - min(x))
data_frame %>% mutate_all( normalize )
或者如果您不介意覆盖data_frame:
replace(data_frame, TRUE, lapply(data_frame, normalize))