Skip to content

Commit f07ddb6

Browse files
Convert character names to indices in ivn if necessary
1 parent ceac3f9 commit f07ddb6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

R/ccdrAlgorithm-main.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ ccdr.run <- function(data,
110110
data_matrix <- data$data
111111
ivn_list <- data$ivn
112112

113+
### If ivn_list contains character names, convert to indices
114+
if("character" %in% sparsebnUtils::list_classes(ivn_list)){
115+
ivn_list <- lapply(ivn_list, function(x){
116+
idx <- match(x, names(data_matrix))
117+
if(length(idx) == 0) NULL # return NULL if no match (=> observational)
118+
else idx
119+
})
120+
}
121+
113122
### Call the CCDr algorithm
114123
ccdr_call(data = data_matrix,
115124
ivn = ivn_list,

0 commit comments

Comments
 (0)