I've tried to convert my results got from my paired t.tests into one table to Microsoft Word. However, I found no luck in doing so. Found errors such as 'Error: (converted from warning) package ‘flextable’ was built under R version 4.2.3'. I did update my R recently so I don't see that the program could be out of date.
Here is my code that I done thus far:
##t test for test the effect of the presence of edges on the marks of predation by birds
library(tidyverse)
# Filter out only the "Edge" and "Center" variables in the "Position within the plot"
filtered_data <- subset(Yes, `Position within the plot` %in% c("Edge", "Center"))
print(result <- t.test(`Amount of bird markings per caterpillar` ~ `Position within the plot`, data = filtered_data, paired = TRUE))
##t test for test the effect of the absense of edges on the marks of predation by birds
# Filter out only the "Edge" and "Center" variables in the "Position within the plot"
filtered_datan <- subset(no, `Position within the plot` %in% c("Edge", "Center"))
print(resultn <- t.test(`Amount of bird markings per caterpillar` ~ `Position within the plot`, data = filtered_datan, paired = TRUE))
I've tried stargazer
and tidy
from packages such as tidyverse
and broom
. I even took the long route:
result <- data.frame(
statistic = result$statistic,
df = result$parameter,
p_value = result$p.value,
conf_int_lower = result$conf.int[1],
conf_int_upper = result$conf.int[2],
mean_difference = result$estimate
)
# Export the t-test results to a CSV file
write.csv(result, file = "t_test_results.csv", row.names = FALSE)
tab_model(model, file = "t_test_results.doc", show.se = TRUE, show.std = TRUE, show.stat = TRUE, show.ci = 0.95, show.est = TRUE)
library(flextable)
# Read the CSV file generated from the t-test results
result <- read.csv("t_test_results.csv")
# Convert the data frame to a flextable
ft <- flextable(result)
# Set column names (optional)
colnames(ft) <- c("Statistic", "df", "p-value", "Conf. Int. Lower", "Conf. Int. Upper", "Mean Difference")