cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-217062%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EReemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217062%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%C2%A1Hola!%20Estoy%20tratando%20de%20ingresar%20todos%20los%20datos%20de%20mis%20columnas%20en%20una%20matriz%20de%208%20por%2012%20en%20orden%20(completando%20las%20columnas%20primero%20hacia%20abajo).%20Solo%20hay%2072%20valores%20en%20mi%20columna%2C%20por%20lo%20que%20quiero%20que%20los%20valores%20restantes%20que%20no%20est%C3%A9n%20completados%20sean%200.Tengo%20muchos%20problemas%20al%20intentar%20que%20funcione%20el%20siguiente%20c%C3%B3digo.%20%C2%A1Apreciar%C3%ADa%20cualquier%20ayuda!%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%22Example.jmp%22)%3B%3CBR%20%2F%3ERows%20%3D%20nrows(dt)%3B%0Anames%3D%20dt%20%26lt%3B%26lt%3B%20Get%20Column%20Names%20(String)%3B%0ATable%20%3D%5B%5D%3B%0ATable%20%3D%20J(8%2C12%2C0)%3B%0AFor(i%3D1%2C%20i%20%26lt%3B%3D%20ncol(dt)%2Ci%2B%2B%2C%20%0A%20%20%20%20data%20%3D%20column(dt%2C%20names%5Bi%5D)%20%26lt%3B%3CGETVALUES%3E%3C%2FGETVALUES%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-219493%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-219493%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%C2%A1Gracias!%20esto%20funciona%20perfectamente%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217509%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217509%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ENo%20tengo%20su%20ejemplo%2C%20as%C3%AD%20que%20tuve%20que%20usar%20una%20de%20las%20tablas%20de%20datos%20de%20muestra%20de%20JMP.%20Reemplace%20esas%20l%C3%ADneas%20de%20la%20tabla%20de%20datos%20inicial%20con%20las%20suyas%20propias.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0A%2F%2F%20use%20sample%20data%20to%20illustrate%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FFitness.jmp%22%20)%3B%0A%2F%2F%20delete%20non-numeric%20data%20columns%0Adt%20%26lt%3B%26lt%3B%20Delete%20Columns(%20%7B%20%3AName%2C%20%3ASex%20%7D%20)%3B%0A%0A%2F%2F%20make%20empty%20container%0Atable%20%3D%20Associative%20Array()%3B%0A%0A%2F%2F%20get%20each%20data%20column%20and%20create%20(key%2C%20value)%20pair%20(key%20%3D%20col%20name%2C%20value%20%3D%208x12%20matrix)%0AFor(%20c%20%3D%201%2C%20c%20%26lt%3B%3D%20N%20Col(%20dt%20)%2C%20c%2B%2B%2C%0A%20data%20%3D%20Column(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20As%20Matrix%3B%0A%20If(%20N%20Row(%20data%20)%20%26lt%3B%2096%2C%0A%20%20data%20%7C%2F%3D%20J(%2096%20-%20N%20Row(%20data%20)%2C%201%2C%200%20)%3B%0A%20)%3B%0A%20table%5BColumn(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20Name%5D%20%3D%20Transpose(%20Shape(%20data%2C%2012%2C%208%20)%20)%3B%0A)%3B%0A%0AClose(%20dt%2C%20No%20Save%20)%3B%0A%0Adir%20%3D%20Get%20Default%20Directory()%3B%0A%0Acontent%20%3D%20table%20%26lt%3B%26lt%3B%20Get%20Contents%3B%0AFor(%20t%20%3D%201%2C%20t%20%26lt%3B%3D%20N%20Items(%20content%20)%2C%20t%2B%2B%2C%0A%20dt%20%3D%20As%20Table(%20content%5Bt%5D%5B2%5D%20)%3B%0A%20file%20path%20%3D%20dir%20%7C%7C%20content%5Bt%5D%5B1%5D%20%7C%7C%20%22.CSV%22%3B%0A%20dt%20%26lt%3B%26lt%3B%20Save(%20file%20path%20)%3B%0A%20Close(%20dt%2C%20No%20Save%20)%3B%0A%20text%20%3D%20Load%20Text%20File(%20file%20path%20)%3B%0A%20eol%20%3D%20Contains(%20text%2C%20%22%5C!n%22%20)%3B%0A%20text%20%3D%20Munger(%20text%2C%201%2C%20eol%20-%201%2C%20content%5Bt%5D%5B1%5D%20)%3B%0A%20Save%20Text%20File(%20file%20path%2C%20text%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217508%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217508%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EMuchas%20gracias%20por%20tu%20ayuda.%20Te%20lo%20agradezco.%20Pude%20guardar%20el%20archivo%20usando%20su%20c%C3%B3digo%2C%20pero%20actualmente%20la%20primera%20fila%20del%20archivo%20csv%20es%20la%20primera%20l%C3%ADnea%20de%20datos%2C%20no%20hay%20ning%C3%BAn%20nombre%20de%20columna.%20Me%20gustar%C3%ADa%20que%20la%20primera%20celda%20tenga%20el%20nombre%20de%20la%20columna%20y%20justo%20debajo%20los%20datos%20de%208%20por%2012.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217503%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217503%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPor%20favor%20sea%20paciente.%20Tengo%20dificultades%20para%20guardar%20el%20archivo%20CSV%20por%20alg%C3%BAn%20motivo%20desconocido.%20Estoy%20trabajando%20con%20soporte%20t%C3%A9cnico.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMientras%20espero%20que%20respondan%2C%20quiero%20estar%20seguro%20de%20que%20desea%20reemplazar%20la%20primera%20fila%20del%20archivo%20CSV%20(encabezados%20de%20las%20columnas%20de%20datos%20originales)%20con%20solo%20el%20nombre%20de%20la%20columna%20de%20datos%20original.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217350%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217350%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%C2%A1%C2%A1Esto%20funcion%C3%B3!!%20Sin%20embargo%2C%20en%20realidad%20quer%C3%ADa%20mantener%20los%20nombres%20de%20las%20columnas%20(o%20en%20este%20caso%20el%20contenido%20%5Bt%5D%20%5B1%5D)%20en%20el%20archivo%20csv%20como%20primera%20l%C3%ADnea.%20Actualmente%20no%20se%20muestra.%20%C2%BFSabes%20c%C3%B3mo%20puedo%20guardarlo%20en%20la%20primera%20celda%20del%20archivo%20csv%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217348%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217348%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EOk%2C%20esta%20versi%C3%B3n%20actualizada%20del%20script%20deber%C3%ADa%20funcionar%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0Adt%20%3D%20Open(%20%22Example.jmp%22%20)%3B%0A%0Atable%20%3D%20Associative%20Array()%3B%0A%0AFor(%20c%20%3D%201%2C%20c%20%26lt%3B%3D%20N%20Col(%20dt%20)%2C%20c%2B%2B%2C%0A%20data%20%3D%20Column(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20As%20Matrix%3B%0A%20If(%20N%20Row(%20data%20)%20%26lt%3B%2096%2C%0A%20%20data%20%7C%2F%3D%20J(%2096%20-%20N%20Row(%20data%20)%2C%201%2C%200%20)%3B%0A%20)%3B%0A%20table%5BColumn(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20Name%5D%20%3D%20Transpose(%20Shape(%20data%2C%2012%2C%208%20)%20)%3B%0A)%3B%0A%0Acontent%20%3D%20table%20%26lt%3B%26lt%3B%20Get%20Contents%3B%0AFor(%20t%20%3D%201%2C%20t%20%26lt%3B%3D%20N%20Items(%20content%20)%2C%20t%2B%2B%2C%0A%20dt%20%3D%20As%20Table(%20content%5Bt%5D%5B2%5D%20)%3B%0A%20Close(%20dt%2C%20Save(%20content%5Bt%5D%5B1%5D%20%7C%7C%20%22.CSV%22%20)%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELamentablemente%2C%20no%20s%C3%A9%20c%C3%B3mo%20suprimir%20la%20primera%20l%C3%ADnea%20con%20los%20nombres%20de%20los%20encabezados%20en%20los%20archivos%20CSV.%20Quiz%C3%A1s%20alguien%20m%C3%A1s%20lo%20sepa.%20Inmediatamente%20podr%C3%ADamos%20volver%20a%20leer%20el%20archivo%20como%20texto%2C%20eliminar%20la%20primera%20l%C3%ADnea%20y%20guardarlo%20nuevamente.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217337%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217337%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ENecesito%20el%20dise%C3%B1o%20para%20mi%20configuraci%C3%B3n%20y%20un%20archivo%20csv%20es%20el%20%C3%BAnico%20tipo%20de%20archivo%20que%20lee%20el%20dispositivo%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217292%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217292%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EConsulte%20Ayuda%20%26gt%3B%20%C3%8Dndice%20de%20secuencias%20de%20comandos.%20Haga%20clic%20en%20el%20bot%C3%B3n%20desplegable%20y%20seleccione%20Funciones.%20Busque%20la%20funci%C3%B3n%20Como%20tabla().%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217291%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217291%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESospecho%20que%2C%20como%20nuevo%20usuario%20de%20JMP%2C%20es%20posible%20que%20su%20mentalidad%20siga%20siendo%20la%20de%20un%20usuario%20de%20hojas%20de%20c%C3%A1lculo.%20No%20s%C3%A9%20el%20destino%20del%20archivo%20CSV%2C%20pero%20puedes%20hacer%20muchas%20cosas%20en%20JMP%20usando%20un%20dise%C3%B1o%20de%20tabla%20alta.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%C2%BFPor%20qu%C3%A9%20necesitas%20el%20dise%C3%B1o%20de%208x12%3F%20%C2%BFPor%20qu%C3%A9%20es%20necesario%20exportar%20las%20matrices%20como%20archivos%20CSV%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPodr%C3%ADamos%20ayudarle%20a%20utilizar%20JMP%20a%20su%20favor%20si%20supi%C3%A9ramos%20hacia%20d%C3%B3nde%20se%20dirige%20este%20an%C3%A1lisis.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217290%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217290%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPor%20favor%20echa%20un%20vistazo%20a%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJMP-Sample-Data%2FMicro-Titre-Plate-Shapes%2Fta-p%2F21484%22%20target%3D%22_self%22%3E%20esta%20publicaci%C3%B3n%3C%2FA%3E%20.%20Puede%20que%20te%20resulte%20%C3%BAtil%20en%20tu%20trabajo%20con%20experimentos%20sobre%20placas.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217239%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217239%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPuede%20que%20sea%20un%20poco%20redundante%2C%20pero%20aqu%C3%AD%20hay%20una%20forma%20alternativa%20de%20manejar%20esto%20dado%20el%20requisito%20de%20generar%20un%20archivo%20csv.Utiliza%20la%20manipulaci%C3%B3n%20de%20la%20tabla%20de%20datos%20para%20obtener%20los%20datos%20en%20el%20formato%20correcto%20y%20luego%20escribe%20la%20tabla%20de%20datos%20en%20un%20archivo%20csv.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0A%2F%2F%20Create%20some%20sample%20data%0Adt%20%3D%20New%20Table(%20%22Example%22%2C%0A%20add%20rows(%2072%20)%2C%0A%20New%20Column(%20%22c1%22%2C%20formula(%20Random%20Uniform(%201%2C%20500%20)%20)%20)%2C%0A%20New%20Column(%20%22c2%22%2C%20formula(%20Random%20Uniform(%201%2C%20500%20)%20)%20)%2C%0A%20New%20Column(%20%22c3%22%2C%20formula(%20Random%20Uniform(%201%2C%20500%20)%20)%20)%0A)%3B%0Adt%20%26lt%3B%26lt%3B%20run%20formulas%3B%0Adt%3Ac1%20%26lt%3B%26lt%3B%20delete%20property(%20%22formula%22%20)%3B%0Adt%3Ac2%20%26lt%3B%26lt%3B%20delete%20property(%20%22formula%22%20)%3B%0Adt%3Ac3%20%26lt%3B%26lt%3B%20delete%20property(%20%22formula%22%20)%3B%0A%0A%2F%2F%20Get%20the%20list%20of%20columns%0AcolNamesList%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(%20string%2C%20numeric%20)%3B%0A%0A%2F%2F%20Loop%20across%20the%20columns%20and%20process%20them%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Cols(%20dt%20)%2C%20i%2B%2B%2C%0A%20%2F%2F%20Create%20a%20new%20table%20will%20only%20the%20single%20column%0A%20dtTemp%20%3D%20dt%20%26lt%3B%26lt%3B%20subset(invisible%2C%20selected%20rows(%200%20)%2C%20columns(%20Column(%20colNamesList%5Bi%5D%20)%20)%20)%3B%0A%20%2F%2F%20If%20there%20are%20not%2096%20rows%2C%20add%20them%0A%20If(%20N%20Rows(%20dtTemp%20)%20%26lt%3B%2096%2C%0A%20%20rowCount%20%3D%20N%20Rows(%20dt%20)%3B%0A%20%20dtTemp%20%26lt%3B%26lt%3B%20add%20rows(%2096%20-%20rowCount%20)%3B%0A%20%20For(%20k%20%3D%20rowCount%20%2B%201%2C%20K%20%26lt%3B%3D%2096%2C%20k%2B%2B%2C%0A%20%20%20Column(%20dtTemp%2C%20colNamesList%5Bi%5D%20)%5Bk%5D%20%3D%200%0A%20%20)%3B%0A%20)%3B%0A%20%2F%2F%20Create%20a%20sequence%20column%20to%20allow%20for%20proper%20splitting%20of%20the%20data%0A%20dtTemp%20%26lt%3B%26lt%3B%20New%20Column(%20%22sequence%22%2C%0A%20%20formula(%0A%20%20%20x%20%3D%20Mod(%20Row()%2C%208%20)%3B%0A%20%20%20If(%20x%20%3D%3D%200%2C%20x%20%3D%208%20)%3B%0A%20%20%20x%3B%0A%20%20)%0A%20)%3B%0A%20dtTemp%20%26lt%3B%26lt%3B%20run%20formulas%3B%0A%20%0A%20%2F%2F%20Split%20the%20data%20into%208%20columns.....if%20this%20should%20be%2012%20just%20change%20the%20sequence%20formula%20above%0A%20dtSplit%20%3D%20dtTemp%20%26lt%3B%26lt%3B%20Split(invisible%2C%20Split%20By(%20%3Asequence%20)%2C%20Split(%20Column(%20dtTemp%2C%20colNamesList%5Bi%5D%20)%20)%2C%20Sort%20by%20Column%20Property%20)%3B%0A%20dtSplit%20%26lt%3B%26lt%3B%20run%20formulas%3B%0A%20%0A%20%2F%2F%20Close%20the%20un%20needed%20temporary%20data%20table%0A%20Close(%20dtTemp%2C%20nosave%20)%3B%0A%20%0A%20%2F%2F%20Change%20the%20output%20preferences%20to%20get%20rid%20of%20headers%0A%20current_pref%20%3D%20Char(%20Arg(%20Parse(%20(Char(%20Get%20Preferences(%20Export%20settings%20)%20))%20)%2C%201%20)%20)%3B%0A%20%2F%2F%20Set%20prefs%20(comma%20delimited%2C%20no%20headers)%0A%20Pref(%20Export%20Settings(%20End%20Of%20Field(%20Comma%20)%2C%20Export%20Table%20Headers(%200%20)%20)%20)%3B%0A%20%2F%2F%20Save%20csv%20file%0A%0A%20dtSplit%20%26lt%3B%26lt%3B%20save(%20%22%24TEMP%5C%22%20%7C%7C%20colNamesList%5Bi%5D%20%7C%7C%20%22.csv%22%20)%3B%0A%20%0A%20%2F%2FRestore%20oribinal%20prefs%0A%20Eval(%20Parse(%20%22pref(%22%20%7C%7C%20current_pref%20%7C%7C%20%22)%22%20)%20)%3B%0A%20%0A%20%2F%2F%20Close%20the%20un%20necessary%20table%0A%20Close(%20dtSplit%2C%20nosave%20)%3B%0A%20%0A)%3B%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217223%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217223%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EGracias%20por%20su%20ayuda%20e%20inter%C3%A9s.%20El%20m%C3%A9todo%20de%20matriz%20asociativa%20de%20Mark%20Bailey%20ha%20funcionado.%20Ahora%20estoy%20tratando%20de%20descubrir%20c%C3%B3mo%20colocar%20la%20matriz%20asociativa%20en%20una%20tabla%20de%20datos%20para%20poder%20exportarla%20como%20un%20archivo%20CSV.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217219%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217219%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EEntonces%2C%20una%20vez%20que%20tienes%20los%20datos%20en%20las%20matrices%2C%20%C2%BFc%C3%B3mo%20los%20mueves%20a%20las%20ubicaciones%20permanentes%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217217%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217217%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EMe%20disculpo%20por%20la%20confusi%C3%B3n.%20Estoy%20tratando%20de%20almacenar%20cada%20uno%20de%20los%20datos%20de%20mi%20columna%20en%20un%20formato%20de%208%20por%2012%20(que%20es%20el%20tama%C3%B1o%20de%20una%20placa%20de%20microtitulaci%C3%B3n%20con%2096%20pocillos)%2C%20para%20almacenar%20los%20resultados%20de%20mis%20experimentos%20en%20correlaci%C3%B3n%20con%20su%20ubicaci%C3%B3n%20en%20la%20placa.%20.%20Cada%20columna%20representa%20un%20experimento%20diferente.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217216%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217216%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHe%20estado%20siguiendo%20esta%20discusi%C3%B3n%20desde%20el%20principio.Parece%20haber%20evolucionado%20hasta%20convertirse%20en%20un%20ejercicio%20de%20gui%C3%B3n%2C%20sin%20exponer%20cu%C3%A1l%20es%20el%20verdadero%20objetivo%20final.%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5358%22%20target%3D%22_blank%22%3E%40Mark_Bailey%3C%2FA%3E%20ha%20proporcionado%20una%20buena%20soluci%C3%B3n%20con%20el%20uso%20de%20una%20matriz%20asociativa%2C%20pero%20lo%20que%20veo%20que%20falta%20es%20%C2%BFcu%C3%A1l%20es%20la%20verdadera%20raz%C3%B3n%20para%20crear%20estas%20matrices%3FSi%20se%20supiera%20esto%2C%20podr%C3%ADa%20haber%20una%20soluci%C3%B3n%20m%C3%A1s%20sencilla.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217215%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217215%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELos%20nombres%20de%20las%20columnas%20se%20almacenan%20en%20la%20matriz%20asociativa.%20Son%20las%20claves.%20Puede%20verificar%20esta%20afirmaci%C3%B3n%20agregando%20esto%20al%20script%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EShow(%20table%20%26lt%3B%26lt%3B%20Get%20Keys%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ELe%20sugiero%20que%20vea%20Ayuda%20%26gt%3B%20Libros%20%26gt%3B%20Gu%C3%ADa%20de%20secuencias%20de%20comandos%20y%20luego%20busque%20'matriz%20asociativa'.%20Puede%20iterar%20sobre%20los%20pares%20y%20realizar%20muchas%20otras%20tareas%20f%C3%A1cilmente.%20Los%20ejemplos%20de%20la%20gu%C3%ADa%20son%20buenos%2C%20pero%20regrese%20aqu%C3%AD%20si%20tiene%20alguna%20pregunta.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217204%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217204%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%C2%A1%C2%A1Gracias!!%20Esto%20funciona%20bien.%20Sin%20embargo%2C%20el%20nombre%20de%20la%20columna%20no%20se%20almacena.%20%C2%BFSabes%20c%C3%B3mo%20podr%C3%ADa%20solucionar%20eso%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217143%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217143%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%C2%BFSus%20columnas%20de%20datos%20son%20para%20los%20resultados%20de%20una%20placa%20de%20microtitulaci%C3%B3n%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EQuiere%20remodelar%20los%20datos%20de%20cada%20columna%20en%20una%20tabla%20de%208x12.%20Su%20script%20solo%20mantendr%C3%A1%20la%20tabla%20de%20la%20%C3%BAltima%20columna.%20Aqu%C3%AD%20hay%20un%20script%20que%20procesa%20cada%20columna%20de%20datos%20y%20almacena%20el%20resultado%20de%20la%20tabla%20con%20el%20nombre%20de%20la%20columna%20en%20una%20matriz%20asociativa.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0Adt%20%3D%20Open(%20%22Example.jmp%22%20)%3B%0A%0Atable%20%3D%20Associative%20Array()%3B%0A%0AFor(%20c%20%3D%201%2C%20c%20%26lt%3B%3D%20N%20Col(%20dt%20)%2C%20c%2B%2B%2C%0A%20data%20%3D%20Column(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20As%20Matrix%3B%0A%20data%5BLoc(Is%20Missing(%20data%20))%5D%20%3D%200%3B%0A%20table%5BColumn(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20Name%5D%20%3D%20Transpose(%20Shape(%20data%2C%2012%2C%208%20)%20)%3B%0A)%3B%0A%0AShow(%20table%20%26lt%3B%26lt%3B%20Get%20Contents%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESupongo%20que%20tienes%20al%20menos%2096%20filas.%20Si%20hay%20m%C3%A1s%2C%20se%20pierden.%20Si%20hay%20menos%2C%20entonces%20la%20asignaci%C3%B3n%20de%200%20debe%20cambiarse%20a%20una%20concatenaci%C3%B3n%20que%20rellene%20con%200.%20Esta%20versi%C3%B3n%20rellena%20en%20su%20lugar%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0Adt%20%3D%20Open(%20%22Example.jmp%22%20)%3B%0A%0Atable%20%3D%20Associative%20Array()%3B%0A%0AFor(%20c%20%3D%201%2C%20c%20%26lt%3B%3D%20N%20Col(%20dt%20)%2C%20c%2B%2B%2C%0A%20data%20%3D%20Column(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20As%20Matrix%3B%0A%20If(%20N%20Row(%20data%20)%20%26lt%3B%2096%2C%0A%20%20data%20%7C%2F%3D%20J(%2096%20-%20N%20Row(%20data%20)%2C%201%2C%200%20)%3B%0A%20)%0A%20table%5BColumn(%20dt%2C%20c%20)%20%26lt%3B%26lt%3B%20Get%20Name%5D%20%3D%20Transpose(%20Shape(%20data%2C%2012%2C%208%20)%20)%3B%0A)%3B%0A%0AShow(%20table%20%26lt%3B%26lt%3B%20Get%20Contents%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217141%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217141%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%C2%A1Gracias%20por%20su%20ayuda!%20%C2%BFPuedo%20utilizar%20la%20funci%C3%B3n%20Obtener%20como%20matriz%20para%20colocar%20los%20datos%20en%20una%20matriz%20con%20especificaciones%3F%20Necesito%20que%20los%20datos%20de%20la%20columna%20entren%20en%20una%20matriz%20de%208%20por%2012.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217140%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217140%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Egracias%20por%20la%20respuesta%20Jim!%20La%20tabla%20de%20datos%20tiene%205%20columnas%20en%20este%20momento%2C%20pero%20puede%20cambiar%20seg%C3%BAn%20la%20entrada%20del%20usuario.%20B%C3%A1sicamente%20estoy%20tratando%20de%20poner%20una%20columna%20de%20datos%20en%20una%20matriz%20con%2012%20columnas%20y%208%20filas.%3CBR%20%2F%3E%3CBR%20%2F%3E%20(a%20-%201)%20*%20b%20%2B%20b%20no%20parece%20funcionar%20para%20m%C3%AD%2C%20supongo%20que%20porque%20para%20los%20datos%20de%20la%20primera%20columna%20siempre%20ser%C3%A1n%20datos%20%5B0%5D.%20%C2%BFSabes%20qu%C3%A9%20va%20mal%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217074%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217074%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJim%20ofrece%20una%20muy%20buena%20soluci%C3%B3n%2C%20pero%20tampoco%20estoy%20seguro%20de%20lo%20que%20quieres%20hacer%2C%20as%C3%AD%20que%20te%20ofrezco%20otra%20forma%20de%20ilustrar%20otro%20punto.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0A%2F%2F%20open%20example%0Adt1%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0A%0A%2F%2F%20make%20illustrative%20example%20with%20colums%20of%20different%20sizes%20(missing%20values)%0Adt2%20%3D%20dt1%20%26lt%3B%26lt%3B%20Split(%0A%20Split%20By(%20%3Aage%20)%2C%0A%20Split(%20%3Aweight%20)%2C%0A%20Remaining%20Columns(%20Drop%20All%20)%2C%0A%20Sort%20by%20Column%20Property%0A)%3B%0A%0AClose(%20dt1%2C%20No%20Save%20)%3B%0A%0A%2F%2F%20input%20data%20table%20as%20matrix%0Amat%20%3D%20dt2%20%26lt%3B%26lt%3B%20Get%20As%20Matrix%3B%0A%0A%2F%2F%20replace%20missing%20values%20with%20zero%0Amat%5BLoc(Is%20Missing(mat))%5D%20%3D%200%3B%0A%0A%2F%2F%20see%20result%0AShow(%20mat%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EEspero%20eso%20ayude.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217072%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Reemplazo%20de%20valores%20de%20matriz%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217072%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ERealmente%20no%20estoy%20seguro%20de%20entender%20lo%20que%20est%C3%A1s%20tratando%20de%20hacer.Pero%20a%20continuaci%C3%B3n%20se%20muestra%20un%20script%20que%20llenar%C3%A1%20ceros%20despu%C3%A9s%20de%20que%20la%20matriz%20llamada%20datos%20se%20quede%20sin%20valores.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22Example.jmp%22%20)%3B%0ARows%20%3D%20N%20Rows(%20dt%20)%3B%0Anames%20%3D%20dt%20%26lt%3B%26lt%3B%20Get%20Column%20Names(%20String%20)%3B%0ATable%20%3D%20%5B%5D%3B%0ATable%20%3D%20J(%208%2C%2012%2C%200%20)%3B%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Col(%20dt%20)%2C%20i%2B%2B%2C%0A%20data%20%3D%20Column(%20dt%2C%20names%5Bi%5D%20)%20%26lt%3B%26lt%3B%20getValues%3B%0A%20For(%20a%20%3D%201%2C%20a%20%26lt%3B%3D%2012%2C%20a%2B%2B%2C%0A%20%20For(%20b%20%3D%201%2C%20b%20%26lt%3B%3D%208%2C%20b%2B%2B%2C%0A%20%20%20%2F%2F%20I%20believe%20that%20(a%20-%201%20)%20*%20b%20%2B%20b%20will%20be%20equal%20to%20the%20%0A%20%20%20%2F%2F%20row%20number%20of%20the%20data%20matrix%20you%20read%20in.%20%20Once%20it's%20%0A%20%20%20%2F%2F%20value%20is%20greater%20than%20the%20number%20of%20rows%20in%20the%20dt%20data%20%0A%20%20%20%2F%2F%20table%2C%20it%20will%20enter%20zeros.%0A%20%20%20If(%20(a%20-%201)%20*%20b%20%2B%20b%20%26lt%3B%3D%20Rows%2C%0A%20%20%20%20Table%5Ba%2C%20b%5D%20%3D%20data%5B(a%20-%201)%20*%20b%20%2B%20b%5D%2C%0A%20%20%20%20Table%5Ba%2C%20b%5D%20%3D%200%0A%20%20%20)%0A%20%20)%0A%20)%3B%0A)%3B%0APrint(%20Table%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EEstoy%20confundido%20acerca%20de%20lo%20que%20est%C3%A1s%20haciendo%20con%20el%20bucle%20For()%20externo%2C%20yendo%20de%20una%20columna%20a%20otra.%C2%BFCu%C3%A1ntas%20columnas%20hay%20en%20la%20tabla%20de%20datos%20de%20ejemplo%3F%20%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
dg1
dg1
Level III

Replacing Matrix Values

Hi! I am trying to input all my column data into a 8 by 12 matrix in order( filling in the columns first in a downwards manner). There are only 72 values in my column, so I want the remaining values that are not filled to be 0.  I am having a lot of problems trying to get the code below to work. I would appreciate any help!

dt = Open("Example.jmp");
Rows = nrows(dt); names= dt << Get Column Names (String); Table =[]; Table = J(8,12,0); For(i=1, i <= ncol(dt),i++, data = column(dt, names[i]) <<getValues; For(a=1, a <=12, a++, For(b =1, b <=8, b++, Table[a,b] = operation; // i get errors at this portion ); ); //unsure of the correct way to implement the code below operation= For (c =1, c= Rows, c++, DataInput[c] = Data[c]; ); ); Print(Table);
22 REPLIES 22
dg1
dg1
Level III

Re: Replacing Matrix Values

Thank you so much for your help. I appreciate it. I was able to save the file using your code, but currently the first row of the csv file is the first line of data, there is no column name. I would like to have the first cell to have the name of the column and right below that the 8 by 12 data.

Re: Replacing Matrix Values

I don't have your example so I had to use one of the JMP sample data tables. Replace those lines for the initial data table with your own.

 

Names Default to Here( 1 );

// use sample data to illustrate
dt = Open( "$SAMPLE_DATA/Fitness.jmp" );
// delete non-numeric data columns
dt << Delete Columns( { :Name, :Sex } );

// make empty container
table = Associative Array();

// get each data column and create (key, value) pair (key = col name, value = 8x12 matrix)
For( c = 1, c <= N Col( dt ), c++,
	data = Column( dt, c ) << Get As Matrix;
	If( N Row( data ) < 96,
		data |/= J( 96 - N Row( data ), 1, 0 );
	);
	table[Column( dt, c ) << Get Name] = Transpose( Shape( data, 12, 8 ) );
);

Close( dt, No Save );

dir = Get Default Directory();

content = table << Get Contents;
For( t = 1, t <= N Items( content ), t++,
	dt = As Table( content[t][2] );
	file path = dir || content[t][1] || ".CSV";
	dt << Save( file path );
	Close( dt, No Save );
	text = Load Text File( file path );
	eol = Contains( text, "\!n" );
	text = Munger( text, 1, eol - 1, content[t][1] );
	Save Text File( file path, text );
);
dg1
dg1
Level III

Re: Replacing Matrix Values

Thank you! this works perfectly

Recommended Articles