編寫 For 循環腳本以將值跨行相乘你好,
我對 JMP 中的腳本編寫相當陌生,並且瀏覽了許多 jmp 論壇來尋找解決方案,但尚未成功修改針對我的特定問題的解決方案。
我有一個腳本,它生成一個列數未知的表,並希望將行中的每個值(生成的表中只有一行)乘以生成的列(第1 列* 第2 列* 第3 列* 等)。 我簡化了示例的表格,實際的表格可以有更多的列。
我的循環將每一行乘以下一行,但沒有給出所有行相互相乘的最終答案。 我也只想要所有值相乘的最終產品,不需要每個增量值的產品。 很感謝任何形式的幫助。
New Table( "tsp",
Add Rows( 1 ),
New Column( "Row 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.975] )
),
New Column( "Row 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.985] )
),
New Column( "Row 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.983] )
),
New Column( "Row 4",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.839] )
),
);
Ncol = N col(tsp);
For( i = 1, i <= Ncol, i++,
For( j = i + 1, j <= Ncol, j++,
RTP = Eval( Column( i ) << Get Name ) || " * " || Eval( Column( i+=1 ) << Get Name );
New Column( RTP, Numeric , seteachvalue( Column( i )[] * Column( i+=1 )[]) );
)
);
質量和工藝工程回复:編寫 For 循環腳本以跨行乘以值nvm 我發現錯誤,末尾的括號包含 1,而它應該是空的,我的代碼應該是
tsp << New Column("RTP", numeric, continuous, Format(Percent, 1));
for each row(:RTP= Product( i = 2, N Col( tsp), Column( tsp, i )[] ))回复:編寫 For 循環腳本以跨行乘以值我嘗試將其放入 For Each Row 中,以應對需要使用此公式迭代多行的情況,但它似乎不起作用,並且我不確定我的錯誤是什麼..我得到了正確的值在“RTP ”中第一行“A”(86.9%),然後所有其餘行顯示相同的值(75.5%),而它們應該都不同......
New Table( "tsp",
Add Rows( 5 ),
New Column( "Site",
Character,
"Nominal",
Set Selected,
Set Values( {"A", "B", "C", "D", "E"} )
),
New Column( "Row 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values(
[0.974, 0.872, 0.927,
0.974, 0.9033]
)
),
New Column( "Row 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values(
[0.968, 0.902, 0.931, .,
0.962]
)
),
New Column( "Row 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values(
[0.944, 0.968, 0.987, ., .]
)
),
New Column( "Row 4",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.9847, 0.9471, ., ., .] )
),
New Column( "Row 5",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.990, 0.994, ., ., .] )
)
);tsp << New Column("RTP", numeric, continuous, Format(Percent, 1));
for each row(:RTP= Product( i = 2, N Col( tsp), Column( tsp, i )[1] ));
回复:編寫 For 循環腳本以跨行乘以值New Table() 之後您所需要的只是:
Product( i = 1, N Col( dt ), Column( dt, i )[1] );
回复:編寫 For 循環腳本以跨行乘以值先生,您真是太棒了!非常感謝你它工作完美! 我絕對把事情複雜化了哈哈。你太有幫助了!
回复:編寫 For 循環腳本以跨行乘以值你工作太辛苦了。以下是我相信你想要的
names default to here( 1 );
dt = New Table( "tsp",
Add Rows( 1 ),
New Column( "Row 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.975] )
),
New Column( "Row 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.985] )
),
New Column( "Row 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.983] )
),
New Column( "Row 4",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0.839] )
),
);
Ncol = N Col( dt ); // or NCol = N Col( data table("tsp"));
value = 1;
For( i = 1, i <= Ncol, i++,
value = Column( dt, i )[1] * value
);
Show( value );