Zellwerte löschenHallo,
Ich habe eine ähnliche Tabelle wie unten gezeigt:
1. Die Tabelle hat numerische Spalten x_1, x_2, x3, ...
2. Ich möchte einen bestimmten Wert, zum Beispiel 8, aus allen Zeilen der Spalten x_1, x_2, x_3, ... löschen. (Erforderliche O/P-Tabelle siehe auch unten.)
Eingabetabelle
| A |
B |
C |
x_1 |
x_2 |
x_3 |
x_4 |
x_5 |
x_6 |
E |
| |
|
|
1 |
8 |
2 |
7 |
2 |
2 |
|
| |
|
|
2 |
8 |
8 |
8 |
8 |
8 |
|
| |
|
|
8 |
8 |
2 |
5 |
3 |
8 |
|
Erforderliche Ausgabetabelle
| A |
B |
C |
x_1 |
x_2 |
x_3 |
x_4 |
x_5 |
x_6 |
E |
| |
|
|
1 |
. |
2 |
7 |
2 |
2 |
|
| |
|
|
2 |
. |
. |
. |
. |
. |
|
| |
|
|
. |
. |
2 |
5 |
3 |
. |
|
Mein Skript ist beigefügt...
Vielen Dank im Voraus für die Hilfe/das Feedback 
dt = Current Data Table ();
for (i=1, i<=6, i++, //iterate through columns loop
temp = "x_" || char (i); //column name
dt << Go To (temp); //select column
dt << Select Where (temp==8);// Select rows where value is 8 ***PROBLEM*** Not selecting rows :(
//After selecting rows where value is 8 for a specific column, I want to delect the value...May be use Empty() ??
);
Betreff: Zellenwerte löschenHier ist eine sehr kleine Änderung gegenüber dem vorherigen Skript, die das tut, was Sie wollen
names default to here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
// set some height rows to missing
dt:height[6] = .;
dt:height[14] = .;
r = loc(ismissing(dt[0, 4]));
// set the values in column 5(wieght) to missing
// for the rows found(located) in column 4
dt[r, 5] = .;Betreff: Zellenwerte löschenInteressant.Ich habe ein etwas anderes Bedürfnis nach so etwas.
Angenommen, ich habe zwei Spalten A und B.A soll Datum/Uhrzeit haben und B hat einen Schlüsselwert.Ich habe Zeilen, in denen Datum/Uhrzeit fehlen, aber Spalte B einen Schlüssel hat.
Wie kann ich den Schlüsselwert löschen, wenn Datum/Uhrzeit fehlen?
Betreff: Zellenwerte löschenDas Abonnieren von Datentabellen ist ebenfalls eine Option, falls es für Ihre Situation schneller ist.
dt = open("$SAMPLE_DATA/Big Class.jmp");
r = loc(dt[0, 4]==61)
dt[r, 4] = .;Betreff: Zellenwerte löschenVielen Dank!
Ich habe darüber nachgedacht, eine Schleife zu verwenden, um iterativ auf Zeilen zuzugreifen und sie dann zu ändern, aber das ist eine sehr schöne Art, JSL zu verwenden 
<SPAN class="token function">Column</SPAN><SPAN class="token punctuation">(</SPAN> dt<SPAN class="token punctuation">,</SPAN> ColList<SPAN class="token punctuation">[</SPAN>i<SPAN class="token punctuation">]</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">[</SPAN>dt <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN> get rows where<SPAN class="token punctuation">(</SPAN> <SPAN class="token function">As Column</SPAN><SPAN class="token punctuation">(</SPAN> dt<SPAN class="token punctuation">,</SPAN> ColList<SPAN class="token punctuation">[</SPAN>i<SPAN class="token punctuation">]</SPAN> <SPAN class="token punctuation">)</SPAN> <SPAN class="token operator">==</SPAN> <SPAN class="token number">8</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">]</SPAN> <SPAN class="token operator">=</SPAN> <SPAN class="token punctuation">.</SPAN><SPAN class="token punctuation">;</SPAN>
Betreff: Zellenwerte löschenSie gehen das Problem richtig an, Sie haben lediglich einige Syntaxprobleme.Unten finden Sie eine funktionierende Version Ihres Codes
Names Default To Here( 1 );
dt = Current Data Table();
// Select the columns to be evaluated
// ColList = {"x_1","x_2","x_3","x_4","x_5","x_6"};
// or if there is a programmatic way to get the list,
// do something like below
ColList = dt << get column names( numeric, string );
// Loop backwards through the list so the "i" index
// maintains it's proper reference
For( i = N Items( ColList ), i >= 1, i--,
If( Left( ColList[i], 2 ) != "x_",
ColList = Remove( ColList, i, 1 )
)
);
// Loop across ColList and set the values qualified
// values to missing
For( i = 1, i <= N Items( ColList ), i++,
// The line below takes advantage of a JMP feature where
// you can change specific values in a column in one statement
// by just using a matrix of the rows you want to change
// Column A[5,6,9,22] = 4;
// This would set a column named "Column A"'s rows 5,6,9 and 22
// to the value of 4
// In your case, you want to eliminate the cell value, so the
// line sets the value to a missing value, which in JMP is "."
Column( dt, ColList[i] )[dt << get rows where( As Column( dt, ColList[i] ) == 8 )] = .;
);