Subscribe Bookmark RSS Feed

how to script a new normalized column

rchertzy

Community Trekker

Joined:

Jun 23, 2011

Is there an elegant way to normalize values into a new column using the mean of one group? I have dose response data, with a control group (dose==0) and want to create a new column where each measurement is divided by the control group mean. Each dose has multiple measurements. I can use Distribution with Where to output only the control group mean but then I insert manually that mean into the formula for the new column. I tried putting the Where command into the New Column function and it was rejected (too many parameters). Here is my Distribution script:

New Window( "Distribution",
V List Box(
Distribution(
Continuous Distribution(
Column( :Name( "Brain ChE" ) ),
Histogram( 0 ),
Vertical( 1 ),
Outlier Box Plot( 0 )
),
Where( :Name( "Dose mg/kg" ) == 0 )
),
)
);
2 REPLIES
mpb

Super User

Joined:

Jun 23, 2011

Don't know if this is "elegant", but you can manually make a column with a formula to do what you want. Assuming the grouping column which identifies your groups has a "c" for the control group:

:Y / Col Mean(If(:Group == "c", :Y, Empty()))

In scripting you can create a new column and make the new column have this formula. See page 124 of the scripting docs for examples of creating a new column with a formula.
rchertzy

Community Trekker

Joined:

Jun 23, 2011

Yes! It is elegant in the math sense of very efficient coding.
For data with numerical values (as I have) for the controls, here is my revision of your one-liner, where dose=0 identifies the control group.
:Brain / Col Mean( If( :dose == 0, :Brain, Empty() ) )