- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
clone a column
Hi All,
I want to clone a column in the data table (make a new identical column in all but it’s name). Is there a more sleek (and robust) way of doing this or do I need to extract the values and all properties and assign them to the new column as such:
dt3 = Open( "$SAMPLE_DATA/Cars.jmp" );
// add a column property
dt3:Make << Set Property(
"Value Colors",
{"Acura" = -13977687, "Audi" = -3780931, "BMW" = -4222943, "Buick" = -
13596966, "Cadillac" = -2211217, "Chevrolet" = -10562780, "Chrysler" = -
13156647, "Daihatsu" = -2078390, "Dodge" = -13182413, "Eagle" = -9549600,
"Ford" = -2334147, "Geo" = -13772446, "Honda" = -9282864, "Hyundai" = -
6995852, "Infiniti" = -1524612, "Isuzu" = -9458080, "Jeep" = -14452073,
"Lexus" = -6391856, "Lincoln" = -2745505, "Mazda" = -10199751, "Mercedes" =
-7150697, "Mercury" = -10513726, "Mitsubishi" = -8381519, "Nissan" = -
3502441, "Oldsmobile" = -3615440, "Peugeot" = -13925307, "Plymouth" = -
11502354, "Pontiac" = -7449196, "Renault" = -9229791, "Saab" = -4074344,
"Saturn" = -13050224, "Subaru" = -12565885, "Suzuki" = -2068529, "Toyota" =
-4494272, "Volkswagen" = -11824110, "Volvo" = -8734293, "Yugo" = -13849421}
) << color cell by value;
// clone the column
clone_column = dt3:Make << Get script;
clone_column;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: clone a column
Let's work it out in the order in which the expression will be evaluated.
dt3:Make << Get script
The message will result in JMP returning the JSL code that would create the same column.
Eval(dt3:Make << Get script)
The JSL code is evaluated resulting in a new data column that is a copy of the original :Make column. The Eval() function will also return a reference to that new column.
Eval(dt3:Make << Get script) << set name("Clone");
Finally, send the new column the message to change the name of the new column using the object reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: clone a column
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: clone a column
No, that interpretation is completely wrong.
Scripting JMP usually involves using built-in JMP objects like data tables, data columns, or analysis platforms. You use these objects by sending a message to the object that indicates the desired action. The general form is shown here in both versions: using the actual JMP function and using the equivalent operator.
Send( object, message );
object << message;
The object is represented by a reference value. The message is represented by name. This example is interpreted in the following way:
dt3:Make << Get Script
Send the message Get Script to the object referred to as dt3:Make. This reference is uses the form table:column. A reference to a data table was previously stored in the variable dt3. The reference to the column is by name.
The message Get Script may be sent to any JMP object. The 'getter' method behind this message is over-ridden by each object to return the script that will re-produce the original object. That is, it returns the code that will clone the object. So you can always use the same message to get the unique code for any object.
- « Previous
-
- 1
- 2
- Next »