Mydata is as under.
dat=" salary ex
1 1856 1799
2 1856 1800
3 1858 1800
4 1858 1801
5 1862 1803
6 1862 1805
7 1862 1810
8 1865 1805
9 1865 1808
10 1865 1815
11 1865 1820
12 1870 1810
13 1870 1830
14 1880 1840
15 1880 1845
16 1880 1851
17 1880 1853
18 1880 1855
19 1885 1850
20 1885 1852
21 1885 1857
22 1885 1860
23 1898 1855
24 1898 1858
25 1898 1861
26 1898 1863
27 1898 1866
28 1898 1867
29 1898 1890
30 1902 1850
31 1902 1853
32 1902 1869
33 1902 1872
34 1902 1873
35 1915 1850
36 1915 1859
37 1915 1863
38 1915 1868
39 1915 1875
40 1915 1898
"
data<-read.table(text=dat,header=TRUE)
I want to get the result ,the header is salary,the rownames is ex. I only can get the "total column"
rev(table(cut(data[,2],breaks=seq(1795,1905,10),right=F)))
How can I get the other data by some code,not by hand?
why is there a strange output in my R console ?
options(digits=15)
options(scipen=30)
data$sal.cat <- cut(data$salary, breaks=seq(1855, 1915, by=10), right=FALSE)
data$sal.cat
## [1] [1.85e+03,1.86e+03) [1.85e+03,1.86e+03)
at last ,i solve it myself,
data$sal.cat <- cut(data$salary, breaks=seq(1855, 1915, by=10), right=FALSE,dig.lab=5)
but can set the dig.lab=5
in options,to get the same output with no dig.lab=5
in my cut function?