Skip to content
Advertisement

Tag: r

Sort by custom function in R

In python, I can do something like It gives me [1, 5, 99, 100, -5, -7, -100] It is sorted by positive/negative number and abs value. How can I do the same thing in R? Without splitting into positive and negative numbers? a = c(1,100,5,-5,-7,99,-100) Answer Use the order() function: Created on 2022-03-22 by the reprex package (v2.0.1) Another possibility

Why is this task faster in Python than Julia?

I ran the following code in RStudio: It reads a huge NASA CSV file, converts it to a dataframe, converts each element to string, and adds them to a vector. RStudio took 4 min and 15 seconds. So I decided to implement the same code in Julia. I ran the following in VS Code: The result was good. The Julia

Creating a series of Quarters

Let say I have a date Now starting from mydate, I want to create an array of 10 quarters e.g. 2020-Q1, 2020-Q2, … [total 10 values] Is there any direct way to achieve this? In R, this is pretty straightforward, as I can use seq() function to generate the same. Any pointer will be very helpful Answer it doesnt give

How to adjust the numerical precision for integers

I’m trying to work with big numbers in R, in my opinion they aren’t even that big. I asked R to return me the module of the division of 6001532020609003100 by 97, I got answer 1; when doing the same calculation in Python I got answer 66. Can someone tell me what’s going on? Answer R doesn’t have the same

Advertisement