[R] problem with my base_df function ?
    varin sacha 
    v@r|n@@ch@ @end|ng |rom y@hoo@|r
       
    Wed Apr 16 18:11:34 CEST 2025
    
    
  
R-experts,
The R script here below.
How to solve my problem ? 
Best,
##############################
# Load packages
 
install.packages("remotes")
remotes::install_github("bd2kccd/r-causal")
 
# Install 'gssr' from 'ropensci' universe
install.packages('gssr', repos =
 c('https://kjhealy.r-universe.dev', 'https://cloud.r-project.org'))
 
# Also recommended: install 'gssrdoc' as well
install.packages('gssrdoc', repos =
 c('https://kjhealy.r-universe.dev', 'https://cloud.r-project.org'))
 
library(dplyr)
library(gssr)
set.seed(123)
# Load dataset
data("gss_panel06_long")
 
# Filter one wave, remove variables with high NA, and keep usable types
base_df <- gss_panel06_long %>%
  filter(year == 2006) %>%
  select_if(~ is.numeric(.) || is.factor(.)) %>%
  select_if(~ sum(is.na(.)) < 0.1 * n()) %>%
  na.omit()
 
# Sample sizes to test
sample_sizes <- c(30, 50, 100, 300, 500)
 
# Set plotting layout
par(mfrow = c(2, 3))  # 2 rows, 3 columns
 
# Loop through sample sizes
for (n in sample_sizes) {
  df_sample <- sample_n(base_df, n)
  result <- gfci(data = df_sample, test = "kci", score = "sem-bic")
  plot(result, main = paste("n =", n))
}
#################################
 
    
    
More information about the R-help
mailing list