构建正确循环的挑战你好,
我对编码不熟悉,并且在构建功能脚本方面面临挑战
dt = current data table();
//declaring and initializing variables//
lt_min = 1;
lt_max = 50;
RSquare_th = 0.9999;
count = 0;
//loop
while (count < 0.99999,
//calculate x for each y value
dt << New Column ("x", Numeric, formula(:y/ (:y + :avg_num)));
//plot bivariate
biv = dt << Bivariate(
Y( :x ),
X( :average_temp),
Fit Line( {Line Color( {212, 73, 88} )} ));
Bivariate_report = biv << report;
pt = Bivariate_report [Table Box(1)];
pt << Make Combined Data Table();
pt = Bivariate_report [Table Box(3)];
pt << Make Combined Data Table();
);
//get rsquare
rsquare << send (Bivariate Fit);
rsquare << send(Get Gen RSquare Test);
//check Rsq
if (rsquare < RSquare_th,
//increment light by 1
lt_min = lt_min +1,
count = count +1,
//update data table
dt << New Column("light", Numeric, formula(lt_min)),
//exit loop if RSQ >= threshold
print("Search Completed. RSQ >= threshold"),
);
自动化和脚本编写回复:构建正确循环的挑战在编辑器中使用 ctrl-M 来格式化 jsl:
dt = Current Data Table();
//declaring and initializing variables//
lt_min = 1;
lt_max = 50;
RSquare_th = 0.9999;
count = 0;
//loop
While( count < 0.99999,
//calculate x for each y value
dt << New Column( "x", Numeric, formula( :y / (:y + :avg_num) ) );
//plot bivariate
biv = dt << Bivariate(
Y( :x ),
X( :average_temp ),
Fit Line( {Line Color( {212, 73, 88} )} )
);
Bivariate_report = biv << report;
pt = Bivariate_report[Table Box( 1 )];
pt << Make Combined Data Table();
pt = Bivariate_report[Table Box( 3 )];
pt << Make Combined Data Table();
);
//get rsquare
rsquare << Send( Bivariate Fit );
rsquare << Send( Get Gen RSquare Test );
//check Rsq
If(
rsquare < RSquare_th,
//increment light by 1
lt_min = lt_min + 1,
count = count + 1,
//update data table
dt << New Column( "light", Numeric, formula( lt_min ) ),
//exit loop if RSQ >= threshold
Print( "Search Completed. RSQ >= threshold" ),
);
缩进将有助于理解循环正在运行的代码。 特别是,请注意 count=count+1 不在循环内,因此它不会终止。
编辑: if 语句也需要工作,请参阅如果秘密