Consider the following data:
datatest = Join[RandomReal[{2, 3}, {5, 2}], Table[{"something" <> ToString[i], "another" <> ToString[i]}, {i, 1, 5, 1}], RandomReal[{0, 1}, {5, 1}], 2]; The description of its columns is given by
meanings = {"val_x", "val_y", "Something", "Something", "mom_x"}; I would like to multiply the columns containing "val_" by 0.01, the columns containing "mom_" by 0.001, and leave unchanged the other columns. In reality, the true data contains hundreds of such columns and thousands of rows, so it would be good to have an automatic way of doing this using patterns. I may define the transformation rule, say, If[StringContainsQ[str,"val_"]==True,0.01], but I do not know how to apply this rule to the list in the form transformation&/@datatest. Could you please help me?






{0.01, 0.01, 1, 1, 0.001} # & /@ datatest? or{#1/100, #2/100, #3, #4, #5/1000} & @@@ datatest$\endgroup$datatestis made of hundreds of columns. I need a pattern of the transformation. $\endgroup$f = If[StringContainsQ[#, "val_"], 0.01, If[StringContainsQ[#, "mom_"], 0.001, 1]] &and(f /@ meanings) # & /@ datatest? $\endgroup$