I have a column name Substance "x". I need to sum the column but I am having an issue with the quotes. How do I use the column x with the quotes? I have tried :substance \!"X\!". That does not work.
Try :Name("substance \!"X\!""), or column(dt, "substance \!"X\!""), where dt points to your table.
This code will work. I've only included the first two columns you want to add.
dt = current data table();
for (i = 1, i <= nrows(dt), i++,
Column(dt, "Total Sum" )[i] = Column(dt, "Dimer [Cl5Si2-O-Si2Cl5]" )[i]
+ Column(dt, "Silicon Tetrachloride(SiCl4)" )[i];
);
Try :Name("substance \!"X\!""), or column(dt, "substance \!"X\!""), where dt points to your table.
As @pmroz points out, the Name() function is used to handle names that have special characters in them.
On the same subject. The compiler likes the syntax, but I am getting the following error.
My Code is:
Thank you in advance.
Wayne
This code will work. I've only included the first two columns you want to add.
dt = current data table();
for (i = 1, i <= nrows(dt), i++,
Column(dt, "Total Sum" )[i] = Column(dt, "Dimer [Cl5Si2-O-Si2Cl5]" )[i]
+ Column(dt, "Silicon Tetrachloride(SiCl4)" )[i];
);
I used your suggestion and still get the error it "Cannot convert argument to a number [or matrix]{1} in access or evaluation of 'Add'. I have checked all of my columns and they are all numeric. Any idea why I would get this error?
Or add empty square brackets after the Column() function if you want to use For Each Row() to iterate.
For Each Row( Column("Total Sum")[] = Column("Dimer [Cl5Si2-O-Si2Cl5]")[] + Column("Silicon Tetrachloride(SiCl4)")[] + Column("Trichlorosilane(SiHCl3)")[] + Column("Hexane")[] + Column("Hexachlorodisiloxane(Si2Cl6O)")[] + Column("Substance \!"X\!"")[] + Column("HCDS")[] + Column("Mixed Dimer [Cl5Si2-O-SiCl3]")[] + Column("OCTS")[]
+ Column("GC Column Product")[] );