|
|
|
|
|
by stoops
2361 days ago
|
|
How do I apply a function to every element of a data frame where that function takes as input the i,j indices of the element along with its value? This is a problem I struggled on for weeks in college. Eventually having to hack something together that relied on modifying the underlying data frame. I've not return to R since as python has always had better libraries and easier to deploy. |
|
You can find the man pages right in R console - look up `?lapply` for column-wise operations and `?apply` for row-wise.
When it comes to data.frame transformations you are typically better off using packages from `hadleyverse` - check https://github.com/hadley/reshape and https://tidyr.tidyverse.org/
Of course, what's important is not the technology used, but the problem solved. Fantastic that python works for you.