I am new to R. I want to generate a frequency table from raw data (decimals) like:
x
V1
1 10.10
2 46.65
3 53.60
4 38.50
5 45.95
6 12.25
7 59.60
8 23.30
9 11.05
10 58.35
11 40.20
12 11.05
13 10.45
14 26.45
15 13.25
16 21.15
17 35.00
18 29.05
19 25.40
20 47.20
21 42.45
22 57.30
23 55.65
24 56.50
25 26.95
26 59.65
27 32.10
28 29.00
29 34.75
30 21.65
into something like this:
Class Frequency
(10.00 - 19.99) 6
(20.00 - 29.99) 8
(30.00 - 39.99) 4
(40.00 - 49.99) 5
(50.00 - 59.99) 7
I use the code below:
factorx<-factor(cut(x, breaks=nclass.Sturges(x)))
but I get something like this:
Error in cut.default(x, breaks = nclass.Sturges(x)) : 'x' must be numeric
How should I make 'x' numeric?
As requested:
h <- dput(x) structure(list(V1 = c(10.1, 46.65, 53.6, 38.5, 45.95, 12.25, 59.6, 23.3, 11.05, 58.35, 40.2, 11.05, 10.45, 26.45, 13.25, 21.15, 35, 29.05, 25.4, 47.2, 42.45, 57.3, 55.65, 56.5, 26.95, 59.65, 32.1, 29, 34.75, 21.65)), .Names = "V1", class = "data.frame", row.names = c(NA, -30L))