I want to show table which can display n number of top records and n number of bottom records if the table is very long.
df <- nycflights13::flights
funct <- function(data, var){
var_lab(data[[var]])<-"Table 1"
t1<- expss::cro_cpct(data[[var]])
t1
}
funct(data=df,var="distance")
i just want to give a parameter like by which it can trim table like below, for example if i give new paramter n = 10 then it should show first 10 records and bottom 10 records and trim the rest of records without changing the original percentage values
Row label | dist | #total |
---|---|---|
Table 1 | 85 | 6.9% |
94 | 7.6% | |
66 | 5.3% | |
57 | 4.6% | |
88 | 7.1% | |
35 | 2.8% | |
55 | 4.4% | |
30 | 2.4% | |
98 | 7.9% | |
……. | ………. | |
58 | 4.7% | |
47 | 3.8% | |
68 | 5.5% | |
37 | 3.0% | |
65 | 5.2% | |
38 | 3.1% | |
79 | 6.4% | |
93 | 7.5% | |
87 | 7.0% | |
59 | 4.8% | |
Total | 1239 |