This is not a the best solution: these examples pass all the columns to a single function which returns multiple columns. This is more complex than it needs to be and it will trigger more compilation than needed. The best way is to use .=>, and it works fine in combination with ByRow.
Yes, I saw. Thank you.
I am trying to understand the various ways of acting on the elements of the dataframe.
For example, I saw here that it is possible to use a vector of triples cols => function => target_cols
transform(df,[oddcol[i]=>ByRow(f[i])=>oddcol[i] for i in 1:length(oddcol)])
I made several tests to achieve the required transformation, including the 3 reported here.
I would have expected (due to a sort of symmetry between input and output) the third to give the same result, but it doesn’t work.
I mean, src => fun => r"x" doesn’t have an intuitive meaning. r"x" is a selector that only makes sense in the context of a given data frame, which is why we need names(df, r"x").
I think the asymmetry is logical, as dest is only about the output of fun rather than the data frame as a whole. Think of the first example, with AsTable. The AsTable knows nothing about the input data frame, only the output of fun.
You can also add the keyword argument renamecols = false to get the same names as the input.