-2

I have a data frame with a column "discount" with values from 0 to 1. I want to count the rows based on grouped values for discount e.g discount 0-0.09 xxx books, 0.1 - 0.19 xxx books, etc

                                             title price sPrice  discount
1                                Ανίκητοι ηττημένοι 16.31  23.30 0.3000000
2               Η πολιτική ως κάλεσμα και επάγγελμα 10.80  12.00 0.1000000
3                              Η αρπαγή της Ευρώπης  8.95  17.90 0.5000000
4                    Το τέλος του κόκκινου ανθρώπου 11.94  19.90 0.4000000
5             Εξηγώντας την Αναρχία στον μπαμπά μου 10.39  14.84 0.2998652
6                    Είναι ο καπιταλισμός, ηλίθιε..  9.90  11.00 0.1000000
7     Η τραγωδία της πολιτικής των μεγάλων δυνάμεων 25.20  36.00 0.3000000
8                       Ώρα Ελλάδος, Βουκουρέστι... 10.50  15.00 0.3000000
9  Αποικιοκρατία. Η ευρωπαϊκή επέκταση μετά το 1763  7.85  11.21 0.2997324
10                                Δόξα και αδιέξοδα  5.32  13.30 0.6000000

so, i want to count the books with discount from 0-0.09, 0.1-0.19 ... till 0.9-1

  • Please use `dput` to show a small reproducible example and expected output – akrun Dec 20 '19 at 18:07
  • There are a lot of questions on SO already on 1) cutting continuous variables into bins, and 2) counting observations by group. What research have you done, and what have you tried that didn't work? – camille Dec 21 '19 at 05:02

1 Answers1

0

Well I made it using cut function

all.books$discount<-cut(all.books$discount,breaks = seq(0,1,by=0.1),right = FALSE)

after that, I used the summary(all.books$discount) and got the results i was looking for