@@ -121,7 +121,7 @@ k_sample <- function(data, x, y,
121121 } else {
122122 paste(" Repeated measures ANOVA with" , sphericity , " correction" )
123123 },
124- alternative = as.character( NA ) ,
124+ alternative = NA_character_ ,
125125 estimate = es [[2L ]],
126126 conf.level = es [[" CI" ]],
127127 conf.low = es [[" CI_low" ]],
@@ -130,7 +130,13 @@ k_sample <- function(data, x, y,
130130 n_obs = length(y_var ) / length(x_lvl )
131131 )
132132
133- if (lbl ) return (lablr(test , markdown )) else return (test )
133+ if (lbl ) {
134+ test <- lablr(test , markdown )
135+ }
136+
137+ class(test ) <- c(" writR" , " list" )
138+
139+ return (test )
134140 } else {
135141
136142 test <- stats :: oneway.test(
@@ -148,7 +154,7 @@ k_sample <- function(data, x, y,
148154 df.error = test $ parameter [[" denom df" ]],
149155 p.value = test $ p.value ,
150156 method = if (var.equal ) " Fisher's ANOVA" else " Welch's ANOVA" ,
151- alternative = as.character( NA ) ,
157+ alternative = NA_character_ ,
152158 estimate = es [[1L ]],
153159 conf.level = es [[" CI" ]],
154160 conf.low = es [[" CI_low" ]],
@@ -157,7 +163,13 @@ k_sample <- function(data, x, y,
157163 n_obs = length(y_var )
158164 )
159165
160- if (lbl ) return (lablr(test , markdown )) else return (test )
166+ if (lbl ) {
167+ test <- lablr(test , markdown )
168+ }
169+
170+ class(test ) <- c(" writR" , " list" )
171+
172+ return (test )
161173 }
162174 }
163175 # Non-parametric statistics
@@ -183,10 +195,10 @@ k_sample <- function(data, x, y,
183195 " x" = x ,
184196 statistic = test $ statistic ,
185197 df = as.double(test $ parameter ),
186- df.error = as.double( NA ) ,
198+ df.error = NA_real_ ,
187199 p.value = test $ p.value ,
188200 method = test $ method ,
189- alternative = as.character( NA ) ,
201+ alternative = NA_character_ ,
190202 estimate = es [[1L ]],
191203 conf.level = es [[" CI" ]],
192204 conf.low = es [[" CI_low" ]],
@@ -195,7 +207,13 @@ k_sample <- function(data, x, y,
195207 n_obs = length(y_var ) / length(x_lvl )
196208 )
197209
198- if (lbl ) return (lablr(test , markdown )) else return (test )
210+ if (lbl ) {
211+ test <- lablr(test , markdown )
212+ }
213+
214+ class(test ) <- c(" writR" , " list" )
215+
216+ return (test )
199217 # Kruskal-Wallis rank-sum test for independent samples
200218 } else {
201219 test <- stats :: kruskal.test(
@@ -214,10 +232,10 @@ k_sample <- function(data, x, y,
214232 " x" = x ,
215233 statistic = test $ statistic ,
216234 df = as.double(test $ parameter ),
217- df.error = as.double( NA ) ,
235+ df.error = NA_real_ ,
218236 p.value = test $ p.value ,
219237 method = test $ method ,
220- alternative = as.character( NA ) ,
238+ alternative = NA_character_ ,
221239 estimate = es [[1L ]],
222240 conf.level = es [[" CI" ]],
223241 conf.low = es [[" CI_low" ]],
@@ -226,7 +244,13 @@ k_sample <- function(data, x, y,
226244 n_obs = length(y_var )
227245 )
228246
229- if (lbl ) return (lablr(test , markdown )) else return (test )
247+ if (lbl ) {
248+ test <- lablr(test , markdown )
249+ }
250+
251+ class(test ) <- c(" writR" , " list" )
252+
253+ return (test )
230254 }
231255 }
232256 # Robust statistics
@@ -258,7 +282,7 @@ k_sample <- function(data, x, y,
258282 df.error = as.double(test $ df2 ),
259283 p.value = test $ p.value ,
260284 method = " one-way repeated measures ANOVA for trimmed means" ,
261- alternative = as.character( NA ) ,
285+ alternative = NA_character_ ,
262286 estimate = es [[1L ]],
263287 conf.level = 0.95 ,
264288 conf.low = es [[2L ]],
@@ -267,7 +291,13 @@ k_sample <- function(data, x, y,
267291 n_obs = length(y_var ) / length(x_lvl )
268292 )
269293
270- if (lbl ) return (lablr(test , markdown )) else return (test )
294+ if (lbl ) {
295+ test <- lablr(test , markdown )
296+ }
297+
298+ class(test ) <- c(" writR" , " list" )
299+
300+ return (test )
271301 # one-way ANOVA for trimmed means
272302 } else {
273303 test <- WRS2 :: t1way(
@@ -284,7 +314,7 @@ k_sample <- function(data, x, y,
284314 df.error = as.double(test $ df2 ),
285315 p.value = test $ p.value ,
286316 method = " one-way ANOVA for trimmed means" ,
287- alternative = as.character( NA ) ,
317+ alternative = NA_character_ ,
288318 estimate = test $ effsize ,
289319 conf.level = 0.95 ,
290320 conf.low = test $ effsize_ci [[1L ]],
@@ -293,7 +323,13 @@ k_sample <- function(data, x, y,
293323 n_obs = length(y_var )
294324 )
295325
296- if (lbl ) return (lablr(test , markdown )) else return (test )
326+ if (lbl ) {
327+ test <- lablr(test , markdown )
328+ }
329+
330+ class(test ) <- c(" writR" , " list" )
331+
332+ return (test )
297333 }
298334 }
299335}
0 commit comments