Turn String Into Int Javascript Array Reduce Function In R