Hi everybody,
I would like to create a list containing each "X4" colum from each of the 5 imputed datasets (imputation made with the amelia()
package) contained in the my_data_im$imputations
list. I'm getting the following output:
> list_im_prep_A <- lapply(my_data_im$imputations, function(x) x %>% select("X4")) Error in UseMethod("select") : no applicable method for 'select' applied to an object of class "logical"
Sometimes i get the error and sometimes i don't... Any idea for solving this issue?
Thanks in advance!
### my code
library("tcltk")
library("Rcpp")
library("readxl")
library("carData")
library("car")
library("dplyr")
library("tidyr")
library("broom")
library("ggplot2")
library("Amelia")
library("tidyverse")
library("ggpubr")
library("rstatix")
library(wrapr)
theme_local <- theme_minimal
### setwd("C:\\Users\\Desktop\\Article ")
### my_data <- read_excel("DATA.xlsx")
my_data <- wrapr::build_frame(
"ID" , "1", "2", "3", "4" , "5" |
"P1" , 100, 100, 100, 40 , 60 |
"P2" , 100, 60 , 80 , 80 , 40 |
"P3" , 100, 100, 100, 100 , 100 |
"P4" , 40 , 90 , 60 , 40 , 0 |
"P5" , 60 , 80 , 80 , 80 , 0 |
"P6" , 100, 100, 100, 100 , 25 |
"P7" , 90 , 100, 80 , NA_real_, 50 |
"P8" , 80 , 100, 100, 80 , 75 |
"P9" , 25 , 90 , 98 , 95 , 90 |
"P10", 26 , 35 , 40 , 50 , 35 |
"P11", 100, 100, 100, 80 , 30 )
my_data_im <- amelia(data.frame(my_data), m = 5, idvars = "ID", emburn = c(0, 1000), bound = rbind(c(5, 0, 100)))
list_im_prep_A <- lapply(my_data_im$imputations, function(x) x %>% select("X4"))