I've encountered very strange issue. I definied a function that loads data from online source and returns a dataframe after some transformations. However, I realised that the data in two columns of the output has decimal delimiter ",", which causes R to interpret this columns as factors.
What I've tried to do was to tranform data within function, by adding two additional lines to the function body:
data_table$usd <- as.numeric(sub(",", ".", data_table$usd))
data_table$eur <- as.numeric(sub(",", ".", data_table$eur))
But this turns out to overwrite whole output (data_table) with numerical vector (output of last line of code I guess). On the other hand, when I execute the same exact code outside of a function, it works as I expect, which makes me even more confused.
Any ideas, why the code inside function cannot transform single columns, but overwrites whole dataframe?