News for hackers. Stuff that matters.
Re:Why I use R by stoops on Monday January 06, 2020 @06:21AM (#21968275)
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.

Re:Why I use R by ksevastyanenko on Monday January 06, 2020 @06:32AM (#21968325)
In R you'd typically want to operate over vectors (rows or columns, with columns being the faster option) rather than on individual values. This requires a bit of a mental shift when you come to R from a C/Cuda background or even python.

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.

Re:Why I use R by anthony_doan on Monday January 06, 2020 @06:33AM (#21968332)
You use one of the family of `apply` function.
Re:Why I use R by mpjdem on Monday January 06, 2020 @08:33AM (#21968961)
If you need i,j indices to solve your problem you should probably not be using a data.frame but a matrix type.
Re:Why I use R by anthony_doan on Monday January 06, 2020 @10:12AM (#21969681)
If he/she chose to use dataframe then the data is probably multiple type. Matrix data structure can only have one type.