FIXED: Rounding errors
parent
1871414592
commit
a5474df9b3
15
report.html
15
report.html
|
@ -1519,13 +1519,16 @@ ordered from wish.com</h2>
|
||||||
valid_percent <- round(p * 100, digits = rounded_digits)
|
valid_percent <- round(p * 100, digits = rounded_digits)
|
||||||
na_percent <- round(na_count / length(data) * 100, digits = rounded_digits)
|
na_percent <- round(na_count / length(data) * 100, digits = rounded_digits)
|
||||||
|
|
||||||
percent <- round(frequency/total_count*100, digits = rounded_digits)
|
percent_raw <- frequency/total_count*100
|
||||||
|
percent <- round(percent_raw, digits = rounded_digits)
|
||||||
cumulative_percent <- round(cumsum(p) * 100, digits = rounded_digits)
|
cumulative_percent <- round(cumsum(p) * 100, digits = rounded_digits)
|
||||||
freq_table <- cbind(frequency, percent, valid_percent, cumulative_percent)
|
freq_table <- cbind(frequency, percent, percent_raw, valid_percent, cumulative_percent)
|
||||||
|
|
||||||
valid_percent_sum <- sum(as.data.frame(freq_table)$percent)
|
valid_percent_sum <- round(sum(as.data.frame(freq_table)$percent_raw), digits = rounded_digits)
|
||||||
Valid_Total <- c(valid_count, valid_percent_sum, 100, NaN)
|
Valid_Total <- c(valid_count, valid_percent_sum, 100, NaN)
|
||||||
|
|
||||||
|
freq_table <- subset(freq_table, select = -c(percent_raw))
|
||||||
|
|
||||||
NAs <- c(na_count, na_percent, NaN, NaN)
|
NAs <- c(na_count, na_percent, NaN, NaN)
|
||||||
Total <- c(total_count, 100, NaN, NaN)
|
Total <- c(total_count, 100, NaN, NaN)
|
||||||
print(rbind(freq_table, Valid_Total, NAs, Total))
|
print(rbind(freq_table, Valid_Total, NAs, Total))
|
||||||
|
@ -2420,7 +2423,7 @@ age <- 2021 - birthyears</code></pre>
|
||||||
## 48 1 0.94 0.94 98.11
|
## 48 1 0.94 0.94 98.11
|
||||||
## 49 1 0.94 0.94 99.06
|
## 49 1 0.94 0.94 99.06
|
||||||
## 50 1 0.94 0.94 100.00
|
## 50 1 0.94 0.94 100.00
|
||||||
## Valid_Total 106 99.98 100.00 NaN
|
## Valid_Total 106 100.00 100.00 NaN
|
||||||
## NAs 0 0.00 NaN NaN
|
## NAs 0 0.00 NaN NaN
|
||||||
## Total 106 100.00 NaN NaN</code></pre>
|
## Total 106 100.00 NaN NaN</code></pre>
|
||||||
<pre class="r"><code># with NA
|
<pre class="r"><code># with NA
|
||||||
|
@ -2449,7 +2452,7 @@ freq(2021 - litdata$D7)</code></pre>
|
||||||
## 48 1 0.32 0.94 98.11
|
## 48 1 0.32 0.94 98.11
|
||||||
## 49 1 0.32 0.94 99.06
|
## 49 1 0.32 0.94 99.06
|
||||||
## 50 1 0.32 0.94 100.00
|
## 50 1 0.32 0.94 100.00
|
||||||
## Valid_Total 106 33.89 100.00 NaN
|
## Valid_Total 106 33.87 100.00 NaN
|
||||||
## NAs 207 66.13 NaN NaN
|
## NAs 207 66.13 NaN NaN
|
||||||
## Total 313 100.00 NaN NaN</code></pre>
|
## Total 313 100.00 NaN NaN</code></pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
11
report.rmd
11
report.rmd
|
@ -45,13 +45,16 @@ freq <- function(data, rounded_digits = 2) {
|
||||||
valid_percent <- round(p * 100, digits = rounded_digits)
|
valid_percent <- round(p * 100, digits = rounded_digits)
|
||||||
na_percent <- round(na_count / length(data) * 100, digits = rounded_digits)
|
na_percent <- round(na_count / length(data) * 100, digits = rounded_digits)
|
||||||
|
|
||||||
percent <- round(frequency/total_count*100, digits = rounded_digits)
|
percent_raw <- frequency/total_count*100
|
||||||
|
percent <- round(percent_raw, digits = rounded_digits)
|
||||||
cumulative_percent <- round(cumsum(p) * 100, digits = rounded_digits)
|
cumulative_percent <- round(cumsum(p) * 100, digits = rounded_digits)
|
||||||
freq_table <- cbind(frequency, percent, valid_percent, cumulative_percent)
|
freq_table <- cbind(frequency, percent, percent_raw, valid_percent, cumulative_percent)
|
||||||
|
|
||||||
valid_percent_sum <- sum(as.data.frame(freq_table)$percent)
|
valid_percent_sum <- round(sum(as.data.frame(freq_table)$percent_raw), digits = rounded_digits)
|
||||||
Valid_Total <- c(valid_count, valid_percent_sum, 100, NaN)
|
Valid_Total <- c(valid_count, valid_percent_sum, 100, NaN)
|
||||||
|
|
||||||
|
freq_table <- subset(freq_table, select = -c(percent_raw))
|
||||||
|
|
||||||
NAs <- c(na_count, na_percent, NaN, NaN)
|
NAs <- c(na_count, na_percent, NaN, NaN)
|
||||||
Total <- c(total_count, 100, NaN, NaN)
|
Total <- c(total_count, 100, NaN, NaN)
|
||||||
print(rbind(freq_table, Valid_Total, NAs, Total))
|
print(rbind(freq_table, Valid_Total, NAs, Total))
|
||||||
|
|
Loading…
Reference in New Issue