У меня есть два списка, которые выглядят так:
[[1]]
<100/1/149>
[[2]]
<100/1/149>
К которым можно получить доступ с помощью:
library(rsample)
map(d, ~ analysis(.x))
map(d, ~ assessment(.x))
Похоже:
[[1]]
# A tibble: 100 x 5
time ID Value out NA
<date> <chr> <dbl> <dbl> <dbl>
1 2016-06-01 CAT1 0 0 0
2 2016-06-02 CAT1 -0.00511 0 0
3 2016-06-03 CAT1 -0.0110 0 0
4 2016-06-06 CAT1 -0.00802 0 0
5 2016-06-07 CAT1 0.000140 0 0
6 2016-06-08 CAT1 0.0162 1 0
7 2016-06-09 CAT1 0.000412 1 1
8 2016-06-10 CAT1 -0.0126 0 1
9 2016-06-13 CAT1 -0.00146 1 0
10 2016-06-14 CAT1 -0.000125 1 1
# ... with 90 more rows
[[2]]
# A tibble: 100 x 5
time ID Value out NA
<date> <chr> <dbl> <dbl> <dbl>
1 2016-06-02 CAT1 -0.00511 0 0
2 2016-06-03 CAT1 -0.0110 0 0
3 2016-06-06 CAT1 -0.00802 0 0
4 2016-06-07 CAT1 0.000140 0 0
5 2016-06-08 CAT1 0.0162 1 0
6 2016-06-09 CAT1 0.000412 1 1
7 2016-06-10 CAT1 -0.0126 0 1
8 2016-06-13 CAT1 -0.00146 1 0
9 2016-06-14 CAT1 -0.000125 1 1
10 2016-06-15 CAT1 0.000905 0 1
# ... with 90 more rows
> map(d, ~ assessment(.x))
[[1]]
# A tibble: 1 x 5
time ID Value out NA
<date> <chr> <dbl> <dbl> <dbl>
1 2016-10-21 CAT1 0.00301 1 0
[[2]]
# A tibble: 1 x 5
time ID Value out NA
<date> <chr> <dbl> <dbl> <dbl>
1 2016-10-24 CAT1 0.0172 1 1
Япытаюсь применить к данным функцию центра и масштаба.
Scale_Me <- function(x){
(x - mean(x, na.rm = TRUE)) / sd(x, na.rm = TRUE)
}
Я хочу применить функцию Scale_Me
к столбцу Value
каждого из списков analysis
с одинаковыми Scale_Me
функция, применяемая к данным assessment
. То есть я хочу применить функцию Scale_Me
к списку [[1]] A tibble: 100 x 5
и с этими значениями применить ее к [[1]] A tibble: 1 x 5
. Затем сделайте то же самое для [[2]] A tibble: 100 x 5
и примените его к [[2]] A tibble: 1 x 5
и т. Д.
Я пытался использовать map
, но, похоже, не могу получить такое же масштабирование для применения к данным assessment
.
Данные:
list(structure(list(data = structure(list(structure(c(16953,
16954, 16955, 16958, 16959, 16960, 16961, 16962, 16965, 16966,
16967, 16968, 16969, 16972, 16973, 16974, 16975, 16976, 16979,
16980, 16981, 16982, 16983, 16987, 16988, 16989, 16990, 16993,
16994, 16995, 16996, 16997, 17000, 17001, 17002, 17003, 17004,
17007, 17008, 17009, 17010, 17011, 17014, 17015, 17016, 17017,
17018, 17021, 17022, 17023, 17024, 17025, 17028, 17029, 17030,
17031, 17032, 17035, 17036, 17037, 17038, 17039, 17042, 17043,
17044, 17045, 17046, 17050, 17051, 17052, 17053, 17056, 17057,
17058, 17059, 17060, 17063, 17064, 17065, 17066, 17067, 17070,
17071, 17072, 17073, 17074, 17077, 17078, 17079, 17080, 17081,
17084, 17085, 17086, 17087, 17088, 17091, 17092, 17093, 17094,
17095, 17098, 17099, 17100, 17101, 17102, 17105, 17106, 17107,
17108, 17109, 17112, 17113, 17114, 17115, 17116, 17119, 17120,
17121, 17122, 17123, 17126, 17127, 17128, 17130, 17133, 17134,
17135, 17136, 17137, 17140, 17141, 17142, 17143, 17144, 17147,
17148, 17149, 17150, 17151, 17154, 17155, 17156, 17157, 17158,
17162, 17163, 17164, 17165), class = "Date"), c("CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1"), c(0, -0.00510794780005341, -0.0110350448181257,
-0.00801566960652444, 0.000139607845475398, 0.0162282908121412,
0.000411912984092044, -0.0125861865355003, -0.00145951271098099,
-0.00012523665276265, 0.000904900638899031, -0.0119067465120106,
-0.0262402364907984, 0.00287696045138475, 0.00321457082827048,
0.00218412506197607, 0.00632290433988492, -0.0379700289082738,
-0.0103076942313959, 0.0176278212428125, 0.00598495254936315,
0.0116793953826004, 0.0102731487452039, -0.00609260431910685,
0.00405785732974429, -0.0034539102152884, 0.0147693571984875,
0.0134064905587454, 0.00776124374616671, -0.00507886728993256,
0.00553715879207672, -0.00152581452484957, 0.0193513280050455,
0.00433371429355156, 0.00573976860850678, -0.00345390114962729,
0.00556433528583788, -0.00399866715134056, -0.00182494148654477,
0.00453676373490031, 0.00558118134782526, 0.0306739497100141,
0.00532008366009151, -0.00234188747061703, 0.00273643894956987,
-0.00203058539307022, 0.0137504519203442, -0.000588020016175195,
0.00319791236187683, 0.000535515000949838, 0.000216627162048733,
-0.00207683640166156, -0.000995849223563661, -0.00677366569507276,
0.00356429722641427, -0.00309006562735681, -0.00267526302250809,
-0.0042170166770128, -0.0000906650234074879, -0.00316029679084417,
-0.000298895581721914, 0.000168967136587872, 0.00339169643503556,
-0.00396295655622492, -0.00265253602098781, 0.00225544752892959,
0.00348603358425681, 0.011173612052706, 0.000346065780582494,
-0.00644578606355972, -0.0201981554179086, 0.0123213639426545,
-0.0121323473477323, 0.00368569810400099, 0.0121575628815795,
-0.00373173650186931, -0.00413587683295258, 0.00745717762898512,
0.00623533292069589, 0.0141584233987713, -0.000393793258897213,
-0.016126574676531, 0.0113664093074735, -0.00185184350325229,
-0.00838065921587761, 0.00294185619615428, -0.0060852193311054,
0.00500931320547093, 0.0000514895101431101, 0.000502291156859291,
-0.00229123398600595, 0.0140114372217135, -0.00365167187405735,
0.00392047706151, -0.0101127189155992, 0.000436945988930848,
0.00183678592569736, 0.0196163746454174, 0.00784647778278202,
-0.00565193886462889, 0.00301143592272179, 0.0171885235697395,
-0.00669036428079295, -0.0106478836418512, -0.00465545067066953,
0.0000251700516804565, -0.0136163258207899, -0.00118539912060411,
-0.0190272881732103, -0.00854690633203736, -0.000144312649125955,
0.0269021803390415, 0.0102105886057713, -0.00657804700031572,
-0.0289694516279417, -0.0111990899370517, -0.0237924756958046,
0.0304450229355975, 0.00789725649510542, 0.0088295314155904,
-0.0138609782778413, 0.0113866913646978, -0.0012090379426567,
-0.00947587412040363, 0.00090671757719174, 0.00861253683999563,
0.00338440726054889, -0.016605324777718, -0.0133502127773003,
0.00344958960669994, 0.0160160159893405, -0.00447205963195563,
0.0159133949476373, 0.00678170228664343, 0.0165760738798502,
-0.0000252860172512692, 0.00865350998635406, 0.00121847887105075,
0.000978545163097477, -0.00883623264030775, 0.00429947401567232,
0.00279522911918573, -0.00233543235943645, -0.00415322695366804,
-0.00170618631415476, 0.00207620495506755, -0.00821173659091756,
-0.00287881031086645, -0.0140139389980795), c(0, 0, 0, 0, 0,
1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0,
1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0,
0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1,
0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0), c(0, 0,
0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1,
1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0,
1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0,
1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0,
0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-149L), .Names = c("time", "ID", "Value", "out", NA)), in_id = 1:100,
out_id = 101L, id = structure(list(id = "Slice01"), row.names = c(NA,
-1L), class = c("tbl_df", "tbl", "data.frame"))), class = c("rsplit",
"rof_split")), structure(list(data = structure(list(structure(c(16953,
16954, 16955, 16958, 16959, 16960, 16961, 16962, 16965, 16966,
16967, 16968, 16969, 16972, 16973, 16974, 16975, 16976, 16979,
16980, 16981, 16982, 16983, 16987, 16988, 16989, 16990, 16993,
16994, 16995, 16996, 16997, 17000, 17001, 17002, 17003, 17004,
17007, 17008, 17009, 17010, 17011, 17014, 17015, 17016, 17017,
17018, 17021, 17022, 17023, 17024, 17025, 17028, 17029, 17030,
17031, 17032, 17035, 17036, 17037, 17038, 17039, 17042, 17043,
17044, 17045, 17046, 17050, 17051, 17052, 17053, 17056, 17057,
17058, 17059, 17060, 17063, 17064, 17065, 17066, 17067, 17070,
17071, 17072, 17073, 17074, 17077, 17078, 17079, 17080, 17081,
17084, 17085, 17086, 17087, 17088, 17091, 17092, 17093, 17094,
17095, 17098, 17099, 17100, 17101, 17102, 17105, 17106, 17107,
17108, 17109, 17112, 17113, 17114, 17115, 17116, 17119, 17120,
17121, 17122, 17123, 17126, 17127, 17128, 17130, 17133, 17134,
17135, 17136, 17137, 17140, 17141, 17142, 17143, 17144, 17147,
17148, 17149, 17150, 17151, 17154, 17155, 17156, 17157, 17158,
17162, 17163, 17164, 17165), class = "Date"), c("CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1"), c(0, -0.00510794780005341, -0.0110350448181257,
-0.00801566960652444, 0.000139607845475398, 0.0162282908121412,
0.000411912984092044, -0.0125861865355003, -0.00145951271098099,
-0.00012523665276265, 0.000904900638899031, -0.0119067465120106,
-0.0262402364907984, 0.00287696045138475, 0.00321457082827048,
0.00218412506197607, 0.00632290433988492, -0.0379700289082738,
-0.0103076942313959, 0.0176278212428125, 0.00598495254936315,
0.0116793953826004, 0.0102731487452039, -0.00609260431910685,
0.00405785732974429, -0.0034539102152884, 0.0147693571984875,
0.0134064905587454, 0.00776124374616671, -0.00507886728993256,
0.00553715879207672, -0.00152581452484957, 0.0193513280050455,
0.00433371429355156, 0.00573976860850678, -0.00345390114962729,
0.00556433528583788, -0.00399866715134056, -0.00182494148654477,
0.00453676373490031, 0.00558118134782526, 0.0306739497100141,
0.00532008366009151, -0.00234188747061703, 0.00273643894956987,
-0.00203058539307022, 0.0137504519203442, -0.000588020016175195,
0.00319791236187683, 0.000535515000949838, 0.000216627162048733,
-0.00207683640166156, -0.000995849223563661, -0.00677366569507276,
0.00356429722641427, -0.00309006562735681, -0.00267526302250809,
-0.0042170166770128, -0.0000906650234074879, -0.00316029679084417,
-0.000298895581721914, 0.000168967136587872, 0.00339169643503556,
-0.00396295655622492, -0.00265253602098781, 0.00225544752892959,
0.00348603358425681, 0.011173612052706, 0.000346065780582494,
-0.00644578606355972, -0.0201981554179086, 0.0123213639426545,
-0.0121323473477323, 0.00368569810400099, 0.0121575628815795,
-0.00373173650186931, -0.00413587683295258, 0.00745717762898512,
0.00623533292069589, 0.0141584233987713, -0.000393793258897213,
-0.016126574676531, 0.0113664093074735, -0.00185184350325229,
-0.00838065921587761, 0.00294185619615428, -0.0060852193311054,
0.00500931320547093, 0.0000514895101431101, 0.000502291156859291,
-0.00229123398600595, 0.0140114372217135, -0.00365167187405735,
0.00392047706151, -0.0101127189155992, 0.000436945988930848,
0.00183678592569736, 0.0196163746454174, 0.00784647778278202,
-0.00565193886462889, 0.00301143592272179, 0.0171885235697395,
-0.00669036428079295, -0.0106478836418512, -0.00465545067066953,
0.0000251700516804565, -0.0136163258207899, -0.00118539912060411,
-0.0190272881732103, -0.00854690633203736, -0.000144312649125955,
0.0269021803390415, 0.0102105886057713, -0.00657804700031572,
-0.0289694516279417, -0.0111990899370517, -0.0237924756958046,
0.0304450229355975, 0.00789725649510542, 0.0088295314155904,
-0.0138609782778413, 0.0113866913646978, -0.0012090379426567,
-0.00947587412040363, 0.00090671757719174, 0.00861253683999563,
0.00338440726054889, -0.016605324777718, -0.0133502127773003,
0.00344958960669994, 0.0160160159893405, -0.00447205963195563,
0.0159133949476373, 0.00678170228664343, 0.0165760738798502,
-0.0000252860172512692, 0.00865350998635406, 0.00121847887105075,
0.000978545163097477, -0.00883623264030775, 0.00429947401567232,
0.00279522911918573, -0.00233543235943645, -0.00415322695366804,
-0.00170618631415476, 0.00207620495506755, -0.00821173659091756,
-0.00287881031086645, -0.0140139389980795), c(0, 0, 0, 0, 0,
1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0,
1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0,
0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1,
0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0), c(0, 0,
0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1,
1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0,
1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0,
1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0,
0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-149L), .Names = c("time", "ID", "Value", "out", NA)), in_id = 2:101,
out_id = 102L, id = structure(list(id = "Slice02"), row.names = c(NA,
-1L), class = c("tbl_df", "tbl", "data.frame"))), class = c("rsplit",
"rof_split")))
РЕДАКТИРОВАТЬ:
Для analysis
У меня есть:
[[1]]
# A tibble: 100 x 5
time ID Value out NA
<date> <chr> <dbl> <dbl> <dbl>
1 2016-06-01 CAT1 0 0 0
2 2016-06-02 CAT1 -0.00511 0 0
3 2016-06-03 CAT1 -0.0110 0 0
4 2016-06-06 CAT1 -0.00802 0 0
5 2016-06-07 CAT1 0.000140 0 0
6 2016-06-08 CAT1 0.0162 1 0
7 2016-06-09 CAT1 0.000412 1 1
8 2016-06-10 CAT1 -0.0126 0 1
9 2016-06-13 CAT1 -0.00146 1 0
10 2016-06-14 CAT1 -0.000125 1 1
# ... with 90 more rows
Для assessment
У меня есть.
[[1]]
# A tibble: 1 x 5
time ID Value out NA
<date> <chr> <dbl> <dbl> <dbl>
1 2016-10-21 CAT1 0.00301 1 0
Я пытаюсь сделать так, чтобы эти два применяли одну и ту же функцию масштабирования, я попытался bind_rows()
и применить функцию масштабирования, а затем снова разделить ее.