cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-21013%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3ESub%C3%ADndice%20de%20tabla%20de%20datos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-21013%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CP%3ESiempre%20ha%20podido%20sub%C3%ADndices%20de%20columnas%20en%20una%20tabla%20de%20datos%20como%20vectores%20unidimensionales.En%20JMP%2013%20puede%20suscribir%20una%20tabla%20de%20datos%20como%20una%20matriz%20bidimensional.Aqu%C3%AD%20hay%20algunos%20ejemplos%20usando%20clase%20grande.(El%20%C3%BAltimo%20ejemplo%20muestra%20el%20sub%C3%ADndice%20de%20la%20columna).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2212872_pastedImage_0.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%2212872_pastedImage_0.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%2212872_pastedImage_0.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%2212872_pastedImage_0.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%2212872_pastedImage_0.png%22%20style%3D%22width%3A%20309px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F3783iDDC99E8545969843%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2212872_pastedImage_0.png%22%20alt%3D%2212872_pastedImage_0.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%22%24SAMPLE_DATA%5CBig%20class.jmp%22)%3B%0A%0A%2F%2F%20fetch%20a%20scalar%3B%20neither%20subscript%20is%20a%20matrix%0Adt%5B%204%2C%20%22height%22%5D%3B%20%2F%2F%2066%0A%0A%2F%2F%20fetch%20a%20matrix%20if%20either%20is%20a%20matrix%2C%20even%20if%201x1%0Adt%5B%20%5B4%5D%2C%20%22height%22%5D%3B%20%2F%2F%20%5B66%5D%0Adt%5B%204%2C%20%7Bheight%7D%5D%3B%20%2F%2F%20%5B66%5D%0A%0A%2F%2F%20fetch%20a%20list%20if%20character%20columns%20are%20involved.%26nbsp%3B%0A%2F%2F%20notice%20the%20matrix%20is%20reversing%20the%20order%0Adt%5B%204%3A%3A2%2C%20%22name%22%5D%3B%20%2F%2F%20%7B%22JACLYN%22%2C%20%22JANE%22%2C%20%22LOUISE%22%7D%0A%0A%2F%2F%20fetch%20an%20entire%20dimension%20using%200%20for%20a%20subscript%0Adt%5B%201%2C0%20%5D%3B%20%2F%2F%20%7B%22KATIE%22%2C%2012%2C%20%22F%22%2C%2059%2C%2095%7D%0A%0A%2F%2F%20fetch%20by%20column%20names%0Adt%5B%5B1%2C3%2C5%5D%2C%7Bheight%2Cweight%7D%5D%3B%20%2F%2F%20%5B59%2095%2C%26nbsp%3B%2055%2074%2C%2052%2064%5D%0A%0A%2F%2F%20fetch%20by%20column%20numbers%20in%20matrix%20or%20list%0Adt%5B%5B1%2C3%2C5%5D%2C%5B2%204%205%5D%5D%3B%20%2F%2F%20%5B12%2059%2095%2C%2012%2055%2074%2C%26nbsp%3B%2012%2052%2064%5D%0Adt%5B%5B1%2C3%2C5%5D%2C%7B2%2C4%2C5%7D%5D%3B%20%2F%2F%20%5B12%2059%2095%2C%2012%2055%2074%2C%26nbsp%3B%2012%2052%2064%5D%0A%0A%2F%2F%20assignments%20work%20too.%26nbsp%3B%20first%2C%20fetch%20a%20copy%0Acopydt%20%3D%20dt%5B0%2C0%5D%3B%20%2F%2F%20make%20a%20list%20of%20the%20table's%20data%0A%0A%2F%2F%20Clear%20the%20table%0Adt%5B0%2C0%5D%20%3D%20.%3B%20%2F%2F%20all%20rows%20and%20cols%20are%20missing%0A%0A%2F%2F%20restore%20the%20table%0Adt%5B0%2C0%5D%20%3D%20copydt%3B%0A%0A%2F%2F%20reverse%20two%20columns%2C%20top%20to%20bottom%20and%20left%20to%20right%0A%2F%2F%20(do%20it%20again%20to%20repair%20the%20table!)%0Adt%5B1%3A%3Anrows(dt)%2C%7Bname%2Csex%7D%5D%20%3D%20dt%5Bnrows(dt)%3A%3A1%2C%7Bsex%2Cname%7D%5D%3B%0A%0A%2F%2F%20set%20from%20a%20matrix%0Adt%5B2%3A%3A3%2C%7Bage%2Cheight%2Cweight%7D%5D%20%3D%20%5B22%2070%20190%2C%2023%2073%20200%20%5D%3B%0A%0A%0A%2F%2F%20column%20subscripting%20still%20works...%0Adt%3Aname%5B4%3A%3A7%5D%3B%20%2F%2F%20%7B%22JACLYN%22%2C%20%22LILLIE%22%2C%20%22TIM%22%2C%20%22JAMES%22%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEl%20sub%C3%ADndice%20de%20la%20tabla%20de%20datos%20hace%20que%20sea%20m%C3%A1s%20f%C3%A1cil%20trabajar%20con%20una%20tabla%20que%20antes%3B%20puede%20intercambiar%20filas%20o%20columnas%20con%20una%20declaraci%C3%B3n%20%C3%BAnica%20(ligeramente%20complicada)%2C%20o%20copiar%20bloques%20de%20una%20tabla%20a%20otra%2C%20o%20extraer%20una%20matriz%20de%20un%20subconjunto%20de%20la%20tabla%20utilizando%20una%20matriz%20de%20filas%20y%20una%20lista%20de%20columnas%20que%20identifican%20el%20subconjunto.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-68721%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3ERe%3A%20Sub%C3%ADndice%20de%20tabla%20de%20datos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-68721%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CP%3EEntiendo.%20Gracias.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-21016%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3ERe%3A%20Sub%C3%ADndice%20de%20tabla%20de%20datos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-21016%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CP%3EBueno%20saber.%C2%A1Gracias!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-21015%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3ERe%3A%20Sub%C3%ADndice%20de%20tabla%20de%20datos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-21015%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CP%3E%C2%A1Guau!Otra%20mejora%20inesperada%20de%20JSL.%C2%A1Esto%20es%20incre%C3%ADble!%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEsto%20puede%20ser%20incluso%20mejor%20que%20la%20mejora%20de%20la%20velocidad%20de%20las%20listas.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-21014%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3ERe%3A%20Sub%C3%ADndice%20de%20tabla%20de%20datos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-21014%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Fpeople%2FCraige%40JMP%22%20target%3D%22_blank%22%3ECraige%40JMP%3C%2FA%3E%3C%2FP%3E%3CP%3E%C2%A1Fant%C3%A1stico!%2C%20Esto%20abre%20muchas%20posibilidades%20para%20la%20%22programaci%C3%B3n%20de%20tablas%20de%20datos%22%2C%20o%20m%C3%A1s%20bien%20la%20programaci%C3%B3n%20basada%20en%20matrices.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Craige_Hales
Super User
Data table subscripting

You've always been able to subscript columns in a data table as one dimensional vectors.  In JMP 13 you can subscript a data table as a two dimensional array.  Here are some examples using big class.   (The very last example shows the column subscripting.)

 

12872_pastedImage_0.png

 

 

 

dt = Open("$SAMPLE_DATA\Big class.jmp");

// fetch a scalar; neither subscript is a matrix
dt[ 4, "height"]; // 66

// fetch a matrix if either is a matrix, even if 1x1
dt[ [4], "height"]; // [66]
dt[ 4, {height}]; // [66]

// fetch a list if character columns are involved. 
// notice the matrix is reversing the order
dt[ 4::2, "name"]; // {"JACLYN", "JANE", "LOUISE"}

// fetch an entire dimension using 0 for a subscript
dt[ 1,0 ]; // {"KATIE", 12, "F", 59, 95}

// fetch by column names
dt[[1,3,5],{height,weight}]; // [59 95,  55 74, 52 64]

// fetch by column numbers in matrix or list
dt[[1,3,5],[2 4 5]]; // [12 59 95, 12 55 74,  12 52 64]
dt[[1,3,5],{2,4,5}]; // [12 59 95, 12 55 74,  12 52 64]

// assignments work too.  first, fetch a copy
copydt = dt[0,0]; // make a list of the table's data

// Clear the table
dt[0,0] = .; // all rows and cols are missing

// restore the table
dt[0,0] = copydt;

// reverse two columns, top to bottom and left to right
// (do it again to repair the table!)
dt[1::nrows(dt),{name,sex}] = dt[nrows(dt)::1,{sex,name}];

// set from a matrix
dt[2::3,{age,height,weight}] = [22 70 190, 23 73 200 ];


// column subscripting still works...
dt:name[4::7]; // {"JACLYN", "LILLIE", "TIM", "JAMES"}

 

 

The data table subscripting makes it easier to work with a table than before; you can swap rows or columns with a single (slightly complicated) statement, or copy blocks from one table to another, or extract a matrix from a subset of the table using a matrix of rows and a list of columns that identify the subset.

Last Modified: Jun 25, 2019 5:11 PM
Comments