Using vectors inside dataframe columns in R

I am programming a classificator in R, I have cases that can have multiple classes, so I would like to have both classes in the same row and the column somthing$classes, as a vector. What I mean, is that the column something$classes, of the something...
more »

2017-03-15 09:03 (1) Answers

Function to subset and adjust vector

The function is supposed to take a vector and winsorize values at the 1st and 99th percentile (replacing values larger 99th percentile with the 99th percentile, vice versa for values lower than the 1st percentile). I can run the function without any ...
more »

2017-03-12 21:03 (1) Answers

Insertion Sort - Handling empty list

I'm trying to implement insertion sort using stl and vectors. I came up with this solution so far: void insertionSort(vector<int> &v, int splitIndex); int main() { //vector<int> x = {55,33,99,11,22,44}; //vector<int> ...
more »

2017-02-26 13:02 (2) Answers

Crashing after using operator new[] in c++

I have a class Vector with array and size fields. When each of two arrays v1 and v2 have more than one element there is a problem with allotment of memory for this arrys in operator of copying. How can I fix it ? Here is a code: #include<iostrea...
more »

2017-02-26 13:02 (1) Answers

Memory usage for lazy datatypes

I've written a program that analyzes and performs operations on data from a file. My first implementation uses Data.ByteString to read the contents of the file. This contents is then converted to a Vector of samples, using Data.Vector.Unboxed. I then...
more »

2017-02-18 19:02 (2) Answers

Python: random matrix from array

I would like to generate from a vector that for simplicity we can call "serie1" another vector of dimension 1000x1 where each element of this new vector is the sum of j random elements of the vector "serie1". I was thinking about creating a random m...
more »

2017-02-15 11:02 (3) Answers

Monadic concatMap for Data.Vector?

I'm looking for something from the Data.Vector package which works like concatMap but works with monads. concatMap has type... (a -> Vector b) -> Vector a -> Vector b but I'm looking for something with type... (Monad m) => (a -> ...
more »

2017-02-14 20:02 (1) Answers

C++ Find N-th highest element of a map

I have a string vector std::vector<string> list and I am trying to find N-th highest repeated element of the vector. I got a map include elements of the vector and repetition number of them. std::map<std::string , int> mapa; for(int i ...
more »

2017-02-11 14:02 (1) Answers

Replicate alternating vector values

I can't figure out how to produce a vector from 3 to 50 where the even numbers are replicated twice and the uneven numbers once, such that the vector would be 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, ..., 50, 50 ...
more »

2017-02-09 21:02 (3) Answers

If-Else/Function Debugging

R beginner here. I'm trying to create a function that converts values for a list in R using if-else. I'm pretty sure I'm violating some cardinal rule(s) with syntax/logic in R and I've read several manuals/online help tools for functions and if/else ...
more »

2017-02-06 05:02 (2) Answers

C++ Invalid Comparator sorting Vector of Structs

I'm trying to Sort a std::vector containing custom structures, each of which has its own vector of int values. The key is that I want to sort based on the ordering of the internal int vector... i.e. {1, 1, 2, 3, 4} is less than {1, 2, 2, 3, 4} becau...
more »

2017-02-05 15:02 (1) Answers

Performance of DIM1 Repa Array vs Vector

I've written a program to process a large amount of data samples using Repa. Performance is key for this program. A large part of the operations require parallel maps/folds over a multi-dimensional arrays and Repa is perfect for this. However, there ...
more »

2017-01-25 14:01 (1) Answers

ByteString to Vector conversion

I have a ByteString that is containing the representation of Floats. Each Float is represented by 3 bytes in the ByteString. I need to do some processing on the Float values, so I would like to perform that processing on an Vector of Float values. ...
more »

2017-01-25 10:01 (2) Answers

Selectively sort vector c++

I have the following vector: vector<unsigned> vec = {5, 6, 5, 4, 1, 3, 0, 4} Now I want to sort this vector lexicographically by odd indices (and if odd indices are equal, then by the even indices). Such that the sorted vector "vec" is: ...
more »

2017-01-24 14:01 (4) Answers