I'm working on a problem and I'm trying to scale my validation data using the column mean and column standard dev as my center and scale. My code is like this
hitters_validation_nn<-scale(hitters_validation_nn,center=col_means_train,scale=col_stddevs_train)
To get the col_means_train and col_stddevs_train I'm using
col_means_train <- attr(hitters_train_nn, "scaled:center")
but the attr() function is returning NULL
here's some sample input
structure(list(AtBat = c(0.52350241534542, -0.545180588669811,1.30134131067296, -1.46505963010064, -0.70074836773532, -0.531652955707593,-0.00407527018108685, 0.496447149420984, 1.15930116456967, 1.551602520474), Hits = c(0.501345534618258, -0.447517828046905, 1.36194253796573,-1.55084731951803, -0.756450085658819, -0.57991736702344, -0.337184878899793,0.413079175300568, 0.810277792230171, 1.38400912779515), HmRun = c(0.723762278211338,-0.181887902377718, -0.86112553781951, -1.20074435554041, -1.31395062811404,-0.634712992672246, 0.610556005637706, -0.974331810393142, -0.29509417495135,-0.29509417495135), Runs = c(0.446904412468218, -0.615296019818122,0.761630466478986, -1.24474812783966, -1.20540737108831, -1.12672585758562,-0.221888452304662, 0.250200628711489, 1.19437879074379, 0.879652736733024), RBI = c(0.793628401583462, -0.365295353885667, -0.0176182272449283,-1.67874227675068, -1.06064960716714, -0.751603272375377, 0.561843650489637,-0.326664562036696, 0.330058899395811, -0.288033770187725), Walks = c(1.62555990659442,-0.503255532726491, -0.27186255019161, -0.919762901289278, -1.56766325238695,-1.52138465587997, 1.11649534501768, 0.514873590426987, 1.71811709960837,-0.456976936219515), Years = c(-0.908811929014153, -1.11606961129887,0.749249529263576, -1.11606961129887, -0.908811929014153, -1.11606961129887,1.16376489383301, -0.287038882160004, 0.127476482409428, 0.749249529263576), CAtBat = c(-0.457945974283276, -0.987733867068442, 0.743136675158013,-1.0662529195822, -0.938983026771436, -1.01146215216876, 1.08741252079528,-0.425157798508298, 0.221114402951131, 0.95884835788813), CHits = c(-0.415609861733436,-0.958367558745463, 0.615019922480415, -1.0483189748233, -0.947695356837923,-0.981236562833049, 0.918415376709048, -0.452200268273572, 0.194230247268843,1.10899041077226), CHmRun = c(-0.079032103140561, -0.687958971143279,-0.604380773574278, -0.819296138751708, -0.831235881261565, -0.759597426202422,2.18951897373231, -0.747657683692565, 0.326919142194584, -0.473043605965849), CRuns = c(-0.419711148638035, -0.944259675135059, 0.405856702723757,-0.9979066835268, -0.965122400620736, -0.991945904816607, 1.24930689021613,-0.440573874123713, 0.313464632715759, 1.22248338602026), CRBI = c(-0.20415029634257,-0.879131279911227, 0.0106163802474568, -0.992650808965956, -0.906744138329945,-0.915948424469518, 1.71034122068853, -0.734930797057923, 0.268336392155489,0.075046383224465), CWalks = c(0.00398745948203903, -0.858967846532506,-0.254899132322324, -0.892735662854814, -0.937759417951225, -0.952767336316696,2.26643115307669, -0.434994152707969, 0.262874051286403, -0.0485402547971072), League = c(-0.945025390826775, 1.05374512605463, -0.945025390826775,1.05374512605463, -0.945025390826775, 1.05374512605463, -0.945025390826775,-0.945025390826775, -0.945025390826775, -0.945025390826775),Division = c(1.00208986643834, -0.993739117551354, 1.00208986643834,-0.993739117551354, 1.00208986643834, 1.00208986643834, -0.993739117551354,1.00208986643834, -0.993739117551354, 1.00208986643834),PutOuts = c(2.15433523777071, 1.88200861940821, -0.0170156659729988,-0.765006111075347, -0.601610140057844, -0.521727665338176,-1.04096375101602, -0.90661595262385, 3.73019860269508, 0.44049305287601), Assists = c(-0.259085518961558, -0.547092212132778, 2.06553993306329,0.0494930808647492, 1.11923222692928, 1.16723334245782, -0.821384300867273,-0.0465091501923241, 0.0769222897381988, -0.793955091993824), Errors = c(0.810388198142198, -0.702758515576438, 2.4748495832327,-0.248814501460847, 0.0538148412828805, 1.56696155500152,-1.30801720106389, -0.248814501460847, 0.507758855398471,-0.854073186948301), NewLeague = c(-0.921490825091866, 1.08065742215319,-0.921490825091866, -0.921490825091866, -0.921490825091866,1.08065742215319, -0.921490825091866, -0.921490825091866,-0.921490825091866, -0.921490825091866)), row.names = c(1L,2L, 3L, 4L, 5L, 6L, 7L, 237L, 238L, 239L), class = "data.frame")