Re: Haciendo coincidir los valores y codificándolos.Aquí hay una manera de resolver su primera pregunta. Estoy usando operaciones matriciales en un intento de reducir el número de comparaciones que tendrías que hacer, si marchas hacia abajo cada columna para cada fila haciendo una comparación para cada celda. Otros pueden tener mejores maneras de hacer esto:
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 2 ),
New Column( "Jan", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11111, 33333] ) ),
New Column( "Feb", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [22222, 33333] ) ),
New Column( "March", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11111, 44444] ) ),
New Column( "April", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11111, 55555] ) ),
New Column( "May", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11111, 11111] ) ),
New Column( "June", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [22222, 33333] ) ),
New Column( "July", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11111, 22222] ) ),
New Column( "August",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [22222, 11111] ),
Set Display Width( 51 )
)
);
For( k = 1, k <= N Rows( dt ), k++,
theRow = dt[k, 0];
compare = theRow[1];
theRow = theRow - compare;
theLoc = Loc( theRow );
theRow = theRow + 1;
For( i = 1, i <= N Rows( theLoc ), i++,
theRow[theLoc[i]] = 0
);
theRow[1] = compare;
dt[k, 0] = theRow;
);
Con respecto a su segunda pregunta ... Estoy un poco confundido sobre lo que está hablando. ¿Podría por favor mostrar un ejemplo simple de cómo se ven sus datos ahora y cómo querría que terminen?
Re: Haciendo coincidir los valores y codificándolos.Bienvenido @ Apurva14
Echa un vistazo a esta solución.
por favor, háganos saber si está en la dirección correcta
New Table( "Untitled",
Add Rows( 4 ),
New Column( "Jan",
Set Values( [11111, 33333, 44444, 55555] )
),
New Column( "Feb ",
Set Values( [22222, 33333, 11111, 55555] )
),
New Column( "March",
Set Values( [11111, 44444, 22222, 11111] )
),
New Column( "April ",
Set Values( [11111, 55555, 33333, 33333] )
),
New Column( "May ",
Set Values( [11111, 11111, 44444, 55555] )
),
New Column( "June",
Set Values( [22222, 33333, 44444, 55555] )
),
New Column( "July ",
Set Values( [11111, 22222, 22211, 55555] )
),
New Column( "August",
Set Values( [22222, 1111, 44444, 22222] )
)
);
// here is where the work starts
dt = Current Data Table();
cols = dt << get column names( string );
ncols = N Items( cols );
For( i = 1, i <= ncols, i++,
Eval( Parse( "dt << new column (cols[i+1], Formula(" || Char( cols[1] ) || " ==" || Char( cols[i + 1] ) ) )
);
mejor,
Ron
Re: Haciendo coincidir los valores y codificándolos.Con respecto a su segunda pregunta intente lo siguiente:
New Table( "Untitled",
Add Rows( 4 ),
New Column( "Jan", Set Values( [11111, 33333, 44444, 55555] ) ),
New Column( "Feb ", Set Values( [22222, 33333, 11111, 55555] ) ),
New Column( "March", Set Values( [11111, 44444, 22222, 11111] ) ),
New Column( "April ", Set Values( [11111, 55555, 33333, 33333] ) ),
New Column( "May ", Set Values( [11111, 11111, 44444, 55555] ) ),
New Column( "June", Set Values( [22222, 33333, 44444, 55555] ) ),
New Column( "July ", Set Values( [11111, 22222, 22211, 55555] ) ),
New Column( "August", Set Values( [22222, 1111, 44444, 22222] ) )
);
// here is where the work starts
dt = Current Data Table();
dt2 = dt << Stack(
columns( :Jan, :Feb, :March, :April, :May, :June, :July, :August ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
dt3 = dt2 << Summary(
Group( :Data ),
Freq( "None" ),
Weight( "None" )
);
dt2 << Update(
With( dt3 ),
Match Columns( :Data = :Data )
);
dt3 << close window (no save);
dt2 << Sort( By( :N Rows ), Order( Ascending ) , replace table);
// at this point the unique values should be at the top of the table
mejor,
Ron
Coincidencia de valores y su codificación.Así que tengo muchos valores iguales (por ejemplo, -12345) en varias columnas por meses. Quería mantener los valores en la primera columna como números y codificar el resto si está presente o ausente como 0 y 1.
Una cosa más acerca de los datos que tengo es que algunos valores son únicos, pero no están en la primera columna, cómo pueden apilarse unos sobre otros y aún codificarlos por mes.
esto es lo que parecen mis datos
Enero Feb Marzo Abril Mayo Junio Julio Agosto 11111 22222 11111 11111 11111 22222 11111 22222 33333 33333 44444 55555 11111 33333 22222 1111 y así sucesivamente
di por ejemplo
111111 0 1 1 0 1 0Quiero que se vea como estos !!
Cualquier ayuda es apreciada.