Applying predict on a new baked dataframe returns error replacement has 8 rows, data has 7.

bm_workflow <- workflow() %>% 
  add_model(bm_final) %>% 
  add_recipe(project_rec)

bm_fit <-
  bm_workflow %>% 
  fit(X_match_2122)

baked_proj_2223 <- bake(project_rec %>% prep(), new_data = X_proj_2223)
baked_proj_2223
projection_xgd <- predict(bm_fit, baked_proj_2223)

The Error:

Error in `$<-.data.frame`(`*tmp*`, "call_text", value = c("stats::predict(bm_fit, baked_proj_2223)", : 
replacement has 8 rows, data has 7

The baked_proj_2223 itself only has 6 rows. Why does it mention 7 and 8 rows of data? Help?

Here's the baked_proj_2223 data:

> dput(baked_proj_2223)
structure(list(gf = c(-0.301527798578953, -1.07688499492483, 
0.473829397766927, -0.301527798578953, -0.301527798578953, 1.24918659411281
), ga = c(0.321715341622074, 1.76943437892141, -0.402144177027592, 
-1.12600369567726, -1.12600369567726, -0.402144177027592), poss = c(0.926739113127463, 
1.26544579406745, -1.86759100462743, -0.0893809296924966, -0.428087610632483, 
-1.02082430227746), sca = c(0.763744791727585, 0.182868471258718, 
0.086055751180573, -0.301195129132005, -0.688446009444584, -0.39800784921015
), pass_live = c(0.93384779891044, 0.807462382516546, -0.077235532240713, 
-0.835548030604078, -0.330006365028501, -0.203620948634607), 
    pass_dead = c(1.41936602895667, -1.64646459358974, -1.64646459358974, 
    0.397422488107869, -1.64646459358974, 1.41936602895667), 
    drib = c(-0.98652850054361, -0.98652850054361, 1.74539657788485, 
    -0.303547230936495, -0.303547230936495, -0.98652850054361
    ), sh = c(2.21499546414996, -0.775248412452487, 0.221499546414996, 
    4.20849138188493, -0.775248412452487, -0.775248412452487), 
    fld_24 = c(-0.987375508236473, 0.123421938529559, 1.23421938529559, 
    0.123421938529559, -0.987375508236473, -0.987375508236473
    ), def = c(-0.733562332109848, -0.733562332109848, -0.733562332109848, 
    -0.733562332109848, -0.733562332109848, -0.733562332109848
    ), gca = c(-1.04824843731092, -1.04824843731092, 0.667067187379677, 
    -0.190590624965622, -0.190590624965622, 1.52472499972497), 
    pass_live_1 = c(-0.870158690466653, -0.870158690466653, 0.210038304595399, 
    0.210038304595399, -0.330060192935627, 2.3704322947195), 
    pass_dead_1 = c(-0.602700475566316, -0.602700475566316, -0.602700475566316, 
    -0.602700475566316, -0.602700475566316, -0.602700475566316
    ), drib_1 = c(-0.51946248164932, -0.51946248164932, 4.15569985319456, 
    -0.51946248164932, 1.81811868577262, -0.51946248164932), 
    sh_1 = c(-0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138
    ), fld_1 = c(-0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138
    ), def_1 = c(-0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138
    ), crd_y = c(1.59230063975608, 1.59230063975608, 0.875765351865847, 
    0.875765351865847, 0.875765351865847, 0.875765351865847), 
    crd_r = c(0, 0, 0, 0, 0, 0), x2crd_y = c(0, 0, 0, 0, 0, 0
    ), fls = c(-0.798390438361124, 0.820880309864254, -0.191163907776607, 
    0.820880309864254, 0.618471466336082, 1.63051568397694), 
    fld_37 = c(0.967515647939031, -0.898407387371957, -1.20939455992379, 
    -2.14235607757928, -1.20939455992379, -0.276433042268295), 
    off = c(0.362636074659104, -0.230768411146702, -0.230768411146702, 
    -0.824172896952509, -0.230768411146702, 0.95604056046491), 
    crs = c(0.0186441843684164, 0.68983482163141, -1.32373709015757, 
    -0.820344112210325, -0.149153474947332, -1.15593943084182
    ), int = c(-1.09375330687331, -2.82073221246274, -0.402961744637535, 
    -0.402961744637535, -0.0575659635196482, 1.66941294206979
    ), tkl_w = c(-1.65574608825599, -0.0704572803513183, 0.880716004391483, 
    -2.28986161141785, -1.33868832667505, -0.387515041932252), 
    p_kwon = c(-0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516
    ), p_kcon = c(-0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138
    ), og = c(-0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516
    ), recov = c(0.692060766043713, -0.0435943789633834, -0.337856436966222, 
    0.348755031707068, 1.28058488204939, -0.730205847636674), 
    won = c(-0.297095667974791, 0.505062635557145, 0.237676534379833, 
    2.51045839438699, 0.505062635557145, -0.831867870329415), 
    xgd = c(0.0999999999999999, -1, 0.2, -0.5, 0.5, 0.5)), row.names = c(NA, 
-6L), class = c("tbl_df", "tbl", "data.frame"))

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Reprex Guide

Thanks for the reply. I've paste the dput data.

this is insufficient ... we lack bm_fit

Have you considered trying to reproduce the logic of your workflow but not on your own data, but on inbuilt R data, you might spot the issue yourself, it would also make it easier to support you when discussing your code.

I've tried to add the dput for bm_fit, but I've got a warning: "Body is limited to 32000 characters; you entered 70955."

maybe I can put it here, the bm_fit:

list(pre = structure(list(actions = list(recipe = structure(list(
    recipe = structure(list(var_info = structure(list(variable = c("gf", 
    "ga", "poss", "sca", "pass_live", "pass_dead", "drib", "sh", 
    "fld_24", "def", "gca", "pass_live_1", "pass_dead_1", "drib_1", 
    "sh_1", "fld_1", "def_1", "crd_y", "crd_r", "x2crd_y", "fls", 
    "fld_37", "off", "crs", "int", "tkl_w", "p_kwon", "p_kcon", 
    "og", "recov", "won", "xgd"), type = c("numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"
    ), role = c("predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "outcome"), source = c("original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original")), row.names = c(NA, -32L), class = c("tbl_df", 
    "tbl", "data.frame")), term_info = structure(list(variable = c("gf", 
    "ga", "poss", "sca", "pass_live", "pass_dead", "drib", "sh", 
    "fld_24", "def", "gca", "pass_live_1", "pass_dead_1", "drib_1", 
    "sh_1", "fld_1", "def_1", "crd_y", "crd_r", "x2crd_y", "fls", 
    "fld_37", "off", "crs", "int", "tkl_w", "p_kwon", "p_kcon", 
    "og", "recov", "won", "xgd"), type = c("numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"
    ), role = c("predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "outcome"), source = c("original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original")), row.names = c(NA, -32L), class = c("tbl_df", 
    "tbl", "data.frame")), steps = list(structure(list(terms = structure(list(
        ~all_predictors()), .Names = "", class = c("quosures", 
    "list")), role = NA, trained = FALSE, means = NULL, sds = NULL, 
        na_rm = TRUE, skip = FALSE, id = "normalize_N0E9e", case_weights = NULL), class = c("step_normalize", 
    "step"))), template = structure(list(gf = c(3L, 1L, 1L, 1L, 
    2L, 4L, 0L, 1L, 3L, 1L, 0L, 3L, 0L, 1L, 1L, 3L, 0L, 0L), 
        ga = c(1L, 0L, 1L, 1L, 0L, 2L, 0L, 4L, 2L, 1L, 1L, 2L, 
        4L, 3L, 1L, 0L, 4L, 1L), poss = c(56L, 57L, 64L, 52L, 
        50L, 46L, 66L, 31L, 43L, 54L, 66L, 61L, 28L, 45L, 36L, 
        65L, 56L, 61L), sca = c(17, 31, 38, 18, 31, 23, 40, 7, 
        22, 19, 17, 34, 4, 21, 9, 17, 21, 11), pass_live = c(11, 
        25, 27, 10, 19, 15, 32, 5, 19, 14, 15, 26, 4, 17, 8, 
        14, 13, 7), pass_dead = c(1, 1, 2, 3, 2, 1, 2, 0, 2, 
        2, 1, 3, 0, 3, 1, 1, 3, 1), drib = c(4, 1, 3, 1, 2, 4, 
        4, 2, 0, 1, 1, 2, 0, 0, 0, 0, 1, 0), sh = c(0, 1, 4, 
        1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 2, 1), fld_24 = c(1, 
        1, 0, 2, 3, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 2, 2, 1), def = c(0, 
        2, 2, 1, 4, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1), gca = c(6, 
        2, 2, 2, 3, 6, 0, 2, 6, 1, 0, 6, 0, 2, 1, 5, 0, 0), pass_live_1 = c(6, 
        2, 2, 2, 0, 4, 0, 1, 5, 0, 0, 1, 0, 2, 1, 3, 0, 0), pass_dead_1 = c(0, 
        0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0), drib_1 = c(0, 
        0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), sh_1 = c(0, 
        0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0), fld_1 = c(0, 
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0), def_1 = c(0, 
        0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), crd_y = c(0, 
        1, 1, 4, 3, 3, 0, 1, 2, 2, 2, 0, 2, 4, 0, 1, 2, 4), crd_r = c(0, 
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), x2crd_y = c(0, 
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), fls = c(10, 
        10, 12, 13, 9, 21, 4, 15, 11, 15, 11, 7, 9, 12, 13, 5, 
        14, 24), fld_37 = c(9, 10, 12, 14, 14, 15, 7, 9, 13, 
        13, 5, 11, 5, 10, 12, 8, 14, 15), off = c(0, 4, 1, 7, 
        1, 2, 2, 1, 0, 4, 2, 3, 2, 2, 2, 3, 3, 4), crs = c(16, 
        15, 15, 12, 9, 9, 20, 5, 2, 11, 20, 17, 2, 8, 3, 4, 15, 
        13), int = c(13, 16, 15, 12, 18, 18, 14, 18, 16, 17, 
        19, 14, 19, 11, 18, 18, 22, 13), tkl_w = c(10, 15, 11, 
        13, 9, 9, 12, 8, 11, 6, 18, 12, 14, 11, 14, 6, 14, 9), 
        p_kwon = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
        0, 1, 0, 0), p_kcon = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
        0, 0, 0, 1, 0, 0, 0, 0), og = c(0, 0, 0, 0, 0, 0, 0, 
        0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), recov = c(130, 91, 
        105, 92, 92, 100, 83, 46, 55, 74, 106, 77, 75, 74, 62, 
        62, 80, 88), won = c(26, 28, 26, 24, 18, 8, 17, 6, 13, 
        10, 32, 8, 13, 17, 20, 16, 15, 13), xgd = c(-0.2, 1.4, 
        1.5, 1, 1.4, 1.1, 2.4, -2.1, -0.2, 0.5, 0.3, 0.1, -2.2, 
        0, -1.4, 0.9, -2, 0.3)), row.names = c(NA, -18L), class = c("tbl_df", 
    "tbl", "data.frame")), levels = NULL, retained = NA, requirements = list(
        bake = structure(logical(0), .Names = character(0)))), class = "recipe"), 
    blueprint = structure(list(intercept = FALSE, allow_novel_levels = FALSE, 
        composition = "tibble", ptypes = NULL, fresh = TRUE, 
        recipe = NULL, extra_role_ptypes = NULL), class = c("default_recipe_blueprint", 
    "recipe_blueprint", "hardhat_blueprint"))), class = c("action_recipe", 
"action_pre", "action"))), mold = list(predictors = structure(list(
    gf = c(1.24918659411281, -0.301527798578953, -0.301527798578953, 
    -0.301527798578953, 0.473829397766927, 2.02454379045869, 
    -1.07688499492483, -0.301527798578953, 1.24918659411281, 
    -0.301527798578953, -1.07688499492483, 1.24918659411281, 
    -1.07688499492483, -0.301527798578953, -0.301527798578953, 
    1.24918659411281, -1.07688499492483, -1.07688499492483), 
    ga = c(-0.402144177027592, -1.12600369567726, -0.402144177027592, 
    -0.402144177027592, -1.12600369567726, 0.321715341622074, 
    -1.12600369567726, 1.76943437892141, 0.321715341622074, -0.402144177027592, 
    -0.402144177027592, 0.321715341622074, 1.76943437892141, 
    1.04557486027174, -0.402144177027592, -1.12600369567726, 
    1.76943437892141, -0.402144177027592), poss = c(0.334002421482487, 
    0.418679091717483, 1.01141578336246, -0.00470425945749995, 
    -0.174057599927493, -0.51276428086748, 1.18076912383245, 
    -1.78291433439243, -0.76679429157247, 0.164649081012493, 
    1.18076912383245, 0.75738577265747, -2.03694434509742, -0.597440951102477, 
    -1.35953098321745, 1.09609245359746, 0.334002421482487, 0.75738577265747
    ), sca = c(-0.39800784921015, 0.957370231883874, 1.63505927243089, 
    -0.301195129132005, 0.957370231883874, 0.182868471258718, 
    1.82868471258718, -1.3661350499916, 0.086055751180573, -0.204382409053861, 
    -0.39800784921015, 1.24780839211831, -1.65657321022603, -0.0107569688975716, 
    -1.17250960983531, -0.39800784921015, -0.0107569688975716, 
    -0.978884169679018), pass_live = c(-0.582777197816289, 1.18661863169823, 
    1.43938946448602, -0.709162614210183, 0.428306133334863, 
    -0.077235532240713, 2.07131654645549, -1.34108969617965, 
    0.428306133334863, -0.203620948634607, -0.077235532240713, 
    1.31300404809212, -1.46747511257355, 0.175535300547075, -0.961933446997972, 
    -0.203620948634607, -0.330006365028501, -1.08831886339187
    ), pass_dead = c(-0.624521052740937, -0.624521052740937, 
    0.397422488107869, 1.41936602895667, 0.397422488107869, -0.624521052740937, 
    0.397422488107869, -1.64646459358974, 0.397422488107869, 
    0.397422488107869, -0.624521052740937, 1.41936602895667, 
    -1.64646459358974, 1.41936602895667, -0.624521052740937, 
    -0.624521052740937, 1.41936602895667, -0.624521052740937), 
    drib = c(1.74539657788485, -0.303547230936495, 1.06241530827773, 
    -0.303547230936495, 0.379434038670619, 1.74539657788485, 
    1.74539657788485, 0.379434038670619, -0.98652850054361, -0.303547230936495, 
    -0.303547230936495, 0.379434038670619, -0.98652850054361, 
    -0.98652850054361, -0.98652850054361, -0.98652850054361, 
    -0.303547230936495, -0.98652850054361), sh = c(-0.775248412452487, 
    0.221499546414996, 3.21174342301744, 0.221499546414996, 0.221499546414996, 
    0.221499546414996, -0.775248412452487, -0.775248412452487, 
    -0.775248412452487, 0.221499546414996, -0.775248412452487, 
    0.221499546414996, -0.775248412452487, 0.221499546414996, 
    -0.775248412452487, -0.775248412452487, 1.21824750528248, 
    0.221499546414996), fld_24 = c(0.123421938529559, 0.123421938529559, 
    -0.987375508236473, 1.23421938529559, 2.34501683206162, 0.123421938529559, 
    0.123421938529559, -0.987375508236473, 0.123421938529559, 
    -0.987375508236473, -0.987375508236473, 0.123421938529559, 
    -0.987375508236473, -0.987375508236473, -0.987375508236473, 
    1.23421938529559, 1.23421938529559, 0.123421938529559), def = c(-0.733562332109848, 
    1.15274080760119, 1.15274080760119, 0.209589237745671, 3.03904394731223, 
    0.209589237745671, 0.209589237745671, -0.733562332109848, 
    -0.733562332109848, 0.209589237745671, -0.733562332109848, 
    0.209589237745671, -0.733562332109848, -0.733562332109848, 
    -0.733562332109848, -0.733562332109848, -0.733562332109848, 
    0.209589237745671), gca = c(1.52472499972497, -0.190590624965622, 
    -0.190590624965622, -0.190590624965622, 0.238238281207027, 
    1.52472499972497, -1.04824843731092, -0.190590624965622, 
    1.52472499972497, -0.619419531138271, -1.04824843731092, 
    1.52472499972497, -1.04824843731092, -0.190590624965622, 
    -0.619419531138271, 1.09589609355233, -1.04824843731092, 
    -1.04824843731092), pass_live_1 = c(2.3704322947195, 0.210038304595399, 
    0.210038304595399, 0.210038304595399, -0.870158690466653, 
    1.29023529965745, -0.870158690466653, -0.330060192935627, 
    1.83033379718848, -0.870158690466653, -0.870158690466653, 
    -0.330060192935627, -0.870158690466653, 0.210038304595399, 
    -0.330060192935627, 0.750136802126425, -0.870158690466653, 
    -0.870158690466653), pass_dead_1 = c(-0.602700475566316, 
    -0.602700475566316, -0.602700475566316, -0.602700475566316, 
    1.56702123647242, 1.56702123647242, -0.602700475566316, -0.602700475566316, 
    1.56702123647242, -0.602700475566316, -0.602700475566316, 
    1.56702123647242, -0.602700475566316, -0.602700475566316, 
    -0.602700475566316, 1.56702123647242, -0.602700475566316, 
    -0.602700475566316), drib_1 = c(-0.51946248164932, -0.51946248164932, 
    -0.51946248164932, -0.51946248164932, 1.81811868577262, 1.81811868577262, 
    -0.51946248164932, 1.81811868577262, -0.51946248164932, -0.51946248164932, 
    -0.51946248164932, 1.81811868577262, -0.51946248164932, -0.51946248164932, 
    -0.51946248164932, -0.51946248164932, -0.51946248164932, 
    -0.51946248164932), sh_1 = c(-0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, 2.74873708374511, -0.343592135468138, 
    2.74873708374511, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138), fld_1 = c(-0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    2.74873708374511, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, 2.74873708374511, -0.343592135468138, 
    -0.343592135468138), def_1 = c(-0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, 2.74873708374511, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    2.74873708374511, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138), crd_y = c(-1.27384051180487, -0.55730522391463, 
    -0.55730522391463, 1.59230063975608, 0.875765351865847, 0.875765351865847, 
    -1.27384051180487, -0.55730522391463, 0.159230063975609, 
    0.159230063975609, 0.159230063975609, -1.27384051180487, 
    0.159230063975609, 1.59230063975608, -1.27384051180487, -0.55730522391463, 
    0.159230063975609, 1.59230063975608), crd_r = c(0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), x2crd_y = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), fls = c(-0.393572751304779, 
    -0.393572751304779, 0.0112449357515651, 0.213653779279737, 
    -0.595981594832952, 1.83292452750512, -1.60802581247381, 
    0.618471466336082, -0.191163907776607, 0.618471466336082, 
    -0.191163907776607, -1.0007992818893, -0.595981594832952, 
    0.0112449357515651, 0.213653779279737, -1.40561696894564, 
    0.41606262280791, 2.44015105808963), fld_37 = c(-0.587420214820126, 
    -0.276433042268295, 0.345541302835368, 0.967515647939031, 
    0.967515647939031, 1.27850282049086, -1.20939455992379, -0.587420214820126, 
    0.656528475387199, 0.656528475387199, -1.83136890502745, 
    0.0345541302835367, -1.83136890502745, -0.276433042268295, 
    0.345541302835368, -0.898407387371957, 0.967515647939031, 
    1.27850282049086), off = c(-1.41757738275832, 0.95604056046491, 
    -0.824172896952509, 2.73625401788233, -0.824172896952509, 
    -0.230768411146702, -0.230768411146702, -0.824172896952509, 
    -1.41757738275832, 0.95604056046491, -0.230768411146702, 
    0.362636074659104, -0.230768411146702, -0.230768411146702, 
    -0.230768411146702, 0.362636074659104, 0.362636074659104, 
    0.95604056046491), crs = c(0.857632480947158, 0.68983482163141, 
    0.68983482163141, 0.186441843684165, -0.31695113426308, -0.31695113426308, 
    1.52882311821015, -0.988141771526074, -1.49153474947332, 
    0.0186441843684164, 1.52882311821015, 1.02543014026291, -1.49153474947332, 
    -0.484748793578829, -1.32373709015757, -1.15593943084182, 
    0.68983482163141, 0.354239502999913), int = c(-1.09375330687331, 
    -0.0575659635196482, -0.402961744637535, -1.43914908799119, 
    0.633225598716125, 0.633225598716125, -0.748357525755422, 
    0.633225598716125, -0.0575659635196482, 0.287829817598239, 
    0.978621379834012, -0.748357525755422, 0.978621379834012, 
    -1.78454486910908, 0.633225598716125, 0.633225598716125, 
    2.01480872318767, -1.09375330687331), tkl_w = c(-0.387515041932252, 
    1.19777376597242, -0.0704572803513183, 0.563658242810549, 
    -0.704572803513186, -0.704572803513186, 0.246600481229615, 
    -1.02163056509412, -0.0704572803513183, -1.65574608825599, 
    2.14894705071522, 0.246600481229615, 0.880716004391483, -0.0704572803513183, 
    0.880716004391483, -1.65574608825599, 0.880716004391483, 
    -0.704572803513186), p_kwon = c(-0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, 4.00693842672377, -0.235702260395516, 
    -0.235702260395516), p_kcon = c(-0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    2.74873708374511, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138, -0.343592135468138, 2.74873708374511, 
    -0.343592135468138, -0.343592135468138, -0.343592135468138, 
    -0.343592135468138), og = c(-0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    4.00693842672377, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516, -0.235702260395516, -0.235702260395516, 
    -0.235702260395516), recov = c(2.31050208505933, 0.397798708040875, 
    1.08441017671417, 0.446842384374681, 0.446842384374681, 0.839191795045133, 
    0.00544929737042309, -1.80916672698042, -1.36777363997616, 
    -0.435943789633835, 1.13345385304797, -0.288812760632416, 
    -0.386900113300029, -0.435943789633835, -1.02446790563951, 
    -1.02446790563951, -0.141681731630996, 0.250667679039455), 
    won = c(1.17352788850042, 1.44091398967774, 1.17352788850042, 
    0.906141787323113, 0.103983483791177, -1.23294702209538, 
    -0.029709566797479, -1.5003331232727, -0.564481769152103, 
    -0.965560920918071, 1.97568619203236, -1.23294702209538, 
    -0.564481769152103, -0.029709566797479, 0.371369584968489, 
    -0.163402617386135, -0.297095667974791, -0.564481769152103
    )), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
-18L)), outcomes = structure(list(xgd = c(-0.2, 1.4, 1.5, 1, 
1.4, 1.1, 2.4, -2.1, -0.2, 0.5, 0.3, 0.1, -2.2, 0, -1.4, 0.9, 
-2, 0.3)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
-18L)), blueprint = structure(list(intercept = FALSE, allow_novel_levels = FALSE, 
    composition = "tibble", ptypes = list(predictors = structure(list(
        gf = integer(0), ga = integer(0), poss = integer(0), 
        sca = numeric(0), pass_live = numeric(0), pass_dead = numeric(0), 
        drib = numeric(0), sh = numeric(0), fld_24 = numeric(0), 
        def = numeric(0), gca = numeric(0), pass_live_1 = numeric(0), 
        pass_dead_1 = numeric(0), drib_1 = numeric(0), sh_1 = numeric(0), 
        fld_1 = numeric(0), def_1 = numeric(0), crd_y = numeric(0), 
        crd_r = numeric(0), x2crd_y = numeric(0), fls = numeric(0), 
        fld_37 = numeric(0), off = numeric(0), crs = numeric(0), 
        int = numeric(0), tkl_w = numeric(0), p_kwon = numeric(0), 
        p_kcon = numeric(0), og = numeric(0), recov = numeric(0), 
        won = numeric(0)), class = c("tbl_df", "tbl", "data.frame"
    ), row.names = integer(0)), outcomes = structure(list(xgd = numeric(0)), class = c("tbl_df", 
    "tbl", "data.frame"), row.names = integer(0))), fresh = TRUE, 
    recipe = structure(list(var_info = structure(list(variable = c("gf", 
    "ga", "poss", "sca", "pass_live", "pass_dead", "drib", "sh", 
    "fld_24", "def", "gca", "pass_live_1", "pass_dead_1", "drib_1", 
    "sh_1", "fld_1", "def_1", "crd_y", "crd_r", "x2crd_y", "fls", 
    "fld_37", "off", "crs", "int", "tkl_w", "p_kwon", "p_kcon", 
    "og", "recov", "won", "xgd"), type = c("numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"
    ), role = c("predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "outcome"), source = c("original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original")), row.names = c(NA, -32L), class = c("tbl_df", 
    "tbl", "data.frame")), term_info = structure(list(variable = c("gf", 
    "ga", "poss", "sca", "pass_live", "pass_dead", "drib", "sh", 
    "fld_24", "def", "gca", "pass_live_1", "pass_dead_1", "drib_1", 
    "sh_1", "fld_1", "def_1", "crd_y", "crd_r", "x2crd_y", "fls", 
    "fld_37", "off", "crs", "int", "tkl_w", "p_kwon", "p_kcon", 
    "og", "recov", "won", "xgd"), type = c("numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"
    ), role = c("predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "predictor", "predictor", "predictor", 
    "predictor", "predictor", "outcome"), source = c("original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original", "original", "original", "original", "original", 
    "original")), row.names = c(NA, -32L), class = c("tbl_df", 
    "tbl", "data.frame")), steps = list(structure(list(terms = structure(list(
        ~all_predictors()), .Names = "", class = c("quosures", 
    "list")), role = NA, trained = TRUE, means = c(gf = 1.38888888888889, 
    ga = 1.55555555555556, poss = 52.0555555555556, sca = 21.1111111111111, 
    pass_live = 15.6111111111111, pass_dead = 1.61111111111111, 
    drib = 1.44444444444444, sh = 0.777777777777778, fld_24 = 0.888888888888889, 
    def = 0.777777777777778, gca = 2.44444444444444, pass_live_1 = 1.61111111111111, 
    pass_dead_1 = 0.277777777777778, drib_1 = 0.222222222222222, 
    sh_1 = 0.111111111111111, fld_1 = 0.111111111111111, def_1 = 0.111111111111111, 
    crd_y = 1.77777777777778, crd_r = 0, x2crd_y = 0, fls = 11.9444444444444, 
    fld_37 = 10.8888888888889, off = 2.38888888888889, crs = 10.8888888888889, 
    int = 16.1666666666667, tkl_w = 11.2222222222222, p_kwon = 0.0555555555555556, 
    p_kcon = 0.111111111111111, og = 0.0555555555555556, recov = 82.8888888888889, 
    won = 17.2222222222222), sds = c(gf = 1.28972814686292, ga = 1.3814835257889, 
    poss = 11.8096282863364, sca = 10.3292211931741, pass_live = 7.91230530018898, 
    pass_dead = 0.978527638786601, drib = 1.46416899628192, sh = 1.0032626514091, 
    fld_24 = 0.900254139862666, def = 1.06027496741928, gca = 2.33193235252055, 
    pass_live_1 = 1.85151413042499, pass_dead_1 = 0.460888598962477, 
    drib_1 = 0.427792631946499, sh_1 = 0.323380833381777, fld_1 = 0.323380833381777, 
    def_1 = 0.323380833381777, crd_y = 1.39560467837445, crd_r = 1, 
    x2crd_y = 1, fls = 4.94049559579058, fld_37 = 3.21556671226796, 
    off = 1.68519117047466, crs = 5.95955869752795, int = 2.89522934172346, 
    tkl_w = 3.15399943219726, p_kwon = 0.235702260395516, p_kcon = 0.323380833381777, 
    og = 0.235702260395516, recov = 20.3899885725061, won = 7.47982034665945
    ), na_rm = TRUE, skip = FALSE, id = "normalize_N0E9e", case_weights = NULL), class = c("step_normalize", 
    "step"))), retained = FALSE, requirements = list(bake = structure(logical(0), .Names = character(0))), 
        tr_info = structure(list(nrows = 18L, ncomplete = 18L), class = "data.frame", row.names = c(NA, 
        -1L)), orig_lvls = list(gf = list(values = NA, ordered = NA), 
            ga = list(values = NA, ordered = NA), poss = list(
                values = NA, ordered = NA), sca = list(values = NA, 
                ordered = NA), pass_live = list(values = NA, 
                ordered = NA), pass_dead = list(values = NA, 
                ordered = NA), drib = list(values = NA, ordered = NA), 
            sh = list(values = NA, ordered = NA), fld_24 = list(
                values = NA, ordered = NA), def = list(values = NA, 
                ordered = NA), gca = list(values = NA, ordered = NA), 
            pass_live_1 = list(values = NA, ordered = NA), pass_dead_1 = list(
                values = NA, ordered = NA), drib_1 = list(values = NA, 
                ordered = NA), sh_1 = list(values = NA, ordered = NA), 
            fld_1 = list(values = NA, ordered = NA), def_1 = list(
                values = NA, ordered = NA), crd_y = list(values = NA, 
                ordered = NA), crd_r = list(values = NA, ordered = NA), 
            x2crd_y = list(values = NA, ordered = NA), fls = list(
                values = NA, ordered = NA), fld_37 = list(values = NA, 
                ordered = NA), off = list(values = NA, ordered = NA), 
            crs = list(values = NA, ordered = NA), int = list(
                values = NA, ordered = NA), tkl_w = list(values = NA, 
                ordered = NA), p_kwon = list(values = NA, ordered = NA), 
            p_kcon = list(values = NA, ordered = NA), og = list(
                values = NA, ordered = NA), recov = list(values = NA, 
                ordered = NA), won = list(values = NA, ordered = NA), 
            xgd = list(values = NA, ordered = NA)), last_term_info = structure(list(
            variable = c("crd_r", "crd_y", "crs", "def", "def_1", 
            "drib", "drib_1", "fld_1", "fld_24", "fld_37", "fls", 
            "ga", "gca", "gf", "int", "off", "og", "p_kcon", 
            "p_kwon", "pass_dead", "pass_dead_1", "pass_live", 
            "pass_live_1", "poss", "recov", "sca", "sh", "sh_1", 
            "tkl_w", "won", "x2crd_y", "xgd"), type = c("numeric", 
            "numeric", "numeric", "numeric", "numeric", "numeric", 
            "numeric", "numeric", "numeric", "numeric", "numeric", 
            "numeric", "numeric", "numeric", "numeric", "numeric", 
            "numeric", "numeric", "numeric", "numeric", "numeric", 
            "numeric", "numeric", "numeric", "numeric", "numeric", 
            "numeric", "numeric", "numeric", "numeric", "numeric", 
            "numeric"), role = list("predictor", "predictor", 
                "predictor", "predictor", "predictor", "predictor", 
                "predictor", "predictor", "predictor", "predictor", 
                "predictor", "predictor", "predictor", "predictor", 
                "predictor", "predictor", "predictor", "predictor", 
                "predictor", "predictor", "predictor", "predictor", 
                "predictor", "predictor", "predictor", "predictor", 
                "predictor", "predictor", "predictor", "predictor", 
                "predictor", "outcome"), source = c("original", 
            "original", "original", "original", "original", "original", 
            "original", "original", "original", "original", "original", 
            "original", "original", "original", "original", "original", 
            "original", "original", "original", "original", "original", 
            "original", "original", "original", "original", "original", 
            "original", "original", "original", "original", "original", 
            "original"), number = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
            1, 1, 1, 1, 1, 1), skip = c(FALSE, FALSE, FALSE, 
            FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
            FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
            FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
            FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
            FALSE)), class = c("grouped_df", "tbl_df", "tbl", 
        "data.frame"), row.names = c(NA, -32L), groups = structure(list(
            variable = c("crd_r", "crd_y", "crs", "def", "def_1", 
            "drib", "drib_1", "fld_1", "fld_24", "fld_37", "fls", 
            "ga", "gca", "gf", "int", "off", "og", "p_kcon", 
            "p_kwon", "pass_dead", "pass_dead_1", "pass_live", 
            "pass_live_1", "poss", "recov", "sca", "sh", "sh_1", 
            "tkl_w", "won", "x2crd_y", "xgd"), .rows = structure(list(
                1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
                12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
                21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 
                30L, 31L, 32L), ptype = integer(0), class = c("vctrs_list_of", 
            "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", 
        "data.frame"), row.names = c(NA, -32L), .drop = TRUE))), class = "recipe"), 
    extra_role_ptypes = NULL), class = c("default_recipe_blueprint", 
"recipe_blueprint", "hardhat_blueprint")), extras = list(roles = NULL)), 
    case_weights = NULL), class = c("stage_pre", "stage")))

unfortunately that doesn't give a useable object that I can tell.
I seriously think the best adivice is 1 of either :-
providing your workflow to make the bm_fit from that initial data you shared (assuming that this reproduces your issue) ;
or recreate your flow, i.e. the steps you take and how you structure things; but on common R data as a starting point, so that the data is not an issue, and anyone here can run the code and get your flow. Its common for people working with tidymodels to follow guides, and adapt them to their own data; my suggestion is aligned with that sort of approach.
sorry.

Echoing the other feedback, maybe try the reprex package to give us more information.

One thing that I can say is that you shouldn't process your data before predicting the model; you don't need to use bake() when using a workflow.

Try using

projection_xgd <- predict(bm_fit, X_proj_2223)

instead.

Oh my god, so that's the problem. It works. Thank you!
I thought I needed to preprocess the test data with recipe again as I did the training data. So it wasn't necessary afteral.

When we're not using tidymodels, we have to make sure the trained data and the test data to have the same format right?

I think I did this same mistake before but with different error message.

Unfortunately, yes. Some packages are more forgiving than others but yes.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.