0

I am trying to divide a dataframe col into 10 equal no of groups.

I have tried like this way:

Code:

data$test<-as.numeric(cut2(data$age_201512, g=10))
res_count_table_10<-aggregate(data$final_res~data$test,data,sum)

Output is :

enter image description here
I have tried to count the test variable

table(data$test)

enter image description here

How can divide into equal 10 groups?? I have tried the same with Excel VBA using (total no.of rows/10) as number of rows in a group..

Output enter image description here

I can able to calculate information value in using above group in R. But unable to group with equal no. of rows.

Can any one help me on this? thanks in advance....

I might not be able to clear you..I need a extra column which hold the group number..like I did data$test.

Subhasish1315
  • 938
  • 1
  • 10
  • 25

1 Answers1

-1

You could try split_var() from the sjmisc-package, which splits a vector into equal sized groups (i.e. each group has approximately the same n). Or group_var() from the same package, which groups vectors into groups with equal range (1-5, 6-10, 11-15...).

Daniel
  • 7,252
  • 6
  • 26
  • 38