Author |
Topic  |
|
razva
Germany
Posts |
Posted - 10/18/2005 : 6:17:34 PM
|
Origin Version (Select Help-->About Origin): 7.5 sr5 Operating System:win xp pro
is there a way to use labtalk for copying certain rows into a new dataset and perform a transposal of these rows into columns? it will be also good for me to have in the end an extra column with every cell containing the label(12 characters) of the corresponding columns in the initial worksheet.
thank you
|
|
Mike Buess
USA
3037 Posts |
Posted - 10/19/2005 : 10:48:06 AM
|
Easier to duplicate the wks, transpose the duplicate and pick out the columns (formerly rows) that you want. Much depends on how you intend to specify the row numbers. The following example copies rows 2, 4 and 6...
tmp={2,4,6}; // create a dataset of row numbers get tmp -e nrows; // how many rows to copy? %F=%H; // save name of active wks win -d; // duplicate doc -e W {%W=%H}; // find name of new wks win -a %W; // activate new wks menu -e 36466; // execute Edit > Transpose win -t D; // create new wks repeat wks.ncols {del col(1)}; // remove all columns loop (i,1,nrows) { wks.addCol(); // create a col jj=tmp[i]; // get ith row number copy %(%W,jj) %(%H,i); // copy col }; del tmp; // delete row-number dataset
# Create ColNames column wks.addCol(ColNames); // create col for names loop (i,1,%F!wks.ncols) { %A=%F!wks.col$(i).name$; // get col name %H!cell(i,wks.ncols)$=%A; // add to col };
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/19/2005 3:16:34 PM |
 |
|
razva
Germany
Posts |
Posted - 10/19/2005 : 12:19:44 PM
|
many thanks. but there is a new problem I did not think of it. I have now a column with the labels of the previous columns in the form of "hineg*T***De" first * being a number between 0 and 13 in steps of 1 and the *** being a number from 0 to 180 in steps of 22.5 (the digits are not displayed in this case). How should I sort the name column in such a way the connection with the corresponding rows in all other columns to remain unaffected? If Origin can make this, I can split the labels column to have different criteria for sorting (e.g. hineg*T***De to be split in "hineg" "*" "T" "***" and "De"). If you have a better solution, please help me.
razvan |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/19/2005 : 1:00:41 PM
|
I don't quite understand the problem. There should already be a one-to-one correspondence in the sense that every value in each row of the final wks was taken from the original column named in the ColName column. If you want to adjust the text in the ColName column or split it into two columns, please give more detail. Why not post the first few names in the ColName column and then show us what you want to do with them.
...On closer reflection it looks like your column names are composed of two variables. I think you want to create two columns in the final wks, one column for each variable, and parse each column name into the two columns for sorting purposes. That can be done but it would still help to see a few sample column names and learn what numbers you want to extract from them. "hineg*T***De" is too fuzzy for my addled brain. :)
Ok, here's a first attempt using 'g', 'D' and 'T' as token separators. Replace the lines under # Create ColNames column in my last script with the following.
wks.addCol(Var1); wks.addCol(Var2); loop (i,1,%F!wks.ncols) { %A=%F!wks.col$(i).name$; %A=%[%A,#2,g]; // keep all right of 'g' %A=%[%A,#1,D]; // keep all left of 'D' %H_Var1[i]=%[%A,#1,T]; // number left of 'T' is var1 vv=%[%A,#2,T]; // number right of 'T' is var2 if( vv>180 ) vv/=10; // restore decimal point %H_Var2[i]=vv; };
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/19/2005 1:01:23 PM
Edited by - Mike Buess on 10/19/2005 2:23:34 PM
Edited by - Mike Buess on 10/19/2005 3:21:41 PM
Edited by - Mike Buess on 10/19/2005 4:02:08 PM |
 |
|
|
Topic  |
|
|
|