title: Remove outliers from multiple timeseries in R using tsclean
body: <p>I would like to clean multiple time series of outliers in <code>R</code>. The <code>forecast::tsclean()</code> function works well for univariate time series data (a single time series of observations) but <code>tsclean()</code> does not work for multivariate timeseries (many different timeseries of observations over a given period). I would prefer to do this following the <code>tidyverse</code> as I am using <code>tsibbles</code>.</p>
  
  <p>I am aware of the <code>feasts</code> package which makes working with multivariate time series easier, but I do not believe it has adapted the <code>tsclean</code> function.</p>
  
  <p>I provide an example where I attempt two solutions, which both fail, which highlights my problem:</p>
  
  <ul>
  <li><code>Attempt 1</code> naively applies the <code>tsclean</code> function to the <code>tsibble</code> which fails.</li>
  <li><code>Attempt 2</code> tries to exploit that <code>tsclean</code> works on univariate series, by applying the <code>group_by_key()</code> function in order to deal with each of the many time series separately. </li>
  </ul>
  
  <pre class="lang-r prettyprint-override"><code>library(fable)
  #&gt; Loading required package: fabletools
  library(tidyverse)
  
  df &lt;- structure(list(date = structure(c(
    11413, 11504, 11596, 11688,
    11778, 11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509,
    12600, 12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330,
    13422, 13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153,
    14245, 14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975,
    15065, 15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796,
    15887, 15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617,
    16709, 16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440,
    17532, 17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778,
    11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600,
    12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422,
    13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245,
    14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065,
    15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887,
    15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709,
    16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532,
    17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869,
    11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692,
    12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514,
    13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335,
    14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156,
    15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979,
    16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801,
    16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622,
    17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869, 11961,
    12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692, 12784,
    12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514, 13604,
    13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335, 14426,
    14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156, 15248,
    15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979, 16071,
    16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801, 16892,
    16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622, 17713,
    17805, 11413, 11504, 11596, 11688, 11778, 11869, 11961, 12053,
    12143, 12234, 12326, 12418, 12509, 12600, 12692, 12784, 12874,
    12965, 13057, 13149, 13239, 13330, 13422, 13514, 13604, 13695,
    13787, 13879, 13970, 14061, 14153, 14245, 14335, 14426, 14518,
    14610, 14700, 14791, 14883, 14975, 15065, 15156, 15248, 15340,
    15431, 15522, 15614, 15706, 15796, 15887, 15979, 16071, 16161,
    16252, 16344, 16436, 16526, 16617, 16709, 16801, 16892, 16983,
    17075, 17167, 17257, 17348, 17440, 17532, 17622, 17713, 17805,
    11413, 11504, 11596, 11688, 11778, 11869, 11961, 12053, 12143,
    12234, 12326, 12418, 12509, 12600, 12692, 12784, 12874, 12965,
    13057, 13149, 13239, 13330, 13422, 13514, 13604, 13695, 13787,
    13879, 13970, 14061, 14153, 14245, 14335, 14426, 14518, 14610,
    14700, 14791, 14883, 14975, 15065, 15156, 15248, 15340, 15431,
    15522, 15614, 15706, 15796, 15887, 15979, 16071, 16161, 16252,
    16344, 16436, 16526, 16617, 16709, 16801, 16892, 16983, 17075,
    17167, 17257, 17348, 17440, 17532, 17622, 17713, 17805, 11413,
    11504, 11596, 11688, 11778, 11869, 11961, 12053, 12143, 12234,
    12326, 12418, 12509, 12600, 12692, 12784, 12874, 12965, 13057,
    13149, 13239, 13330, 13422, 13514, 13604, 13695, 13787, 13879,
    13970, 14061, 14153, 14245, 14335, 14426, 14518, 14610, 14700,
    14791, 14883, 14975, 15065, 15156, 15248, 15340, 15431, 15522,
    15614, 15706, 15796, 15887, 15979, 16071, 16161, 16252, 16344,
    16436, 16526, 16617, 16709, 16801, 16892, 16983, 17075, 17167,
    17257, 17348, 17440, 17532, 17622, 17713, 17805, 11413, 11504,
    11596, 11688, 11778, 11869, 11961, 12053, 12143, 12234, 12326,
    12418, 12509, 12600, 12692, 12784, 12874, 12965, 13057, 13149,
    13239, 13330, 13422, 13514, 13604, 13695, 13787, 13879, 13970,
    14061, 14153, 14245, 14335, 14426, 14518, 14610, 14700, 14791,
    14883, 14975, 15065, 15156, 15248, 15340, 15431, 15522, 15614,
    15706, 15796, 15887, 15979, 16071, 16161, 16252, 16344, 16436,
    16526, 16617, 16709, 16801, 16892, 16983, 17075, 17167, 17257,
    17348, 17440, 17532, 17622, 17713, 17805, 11413, 11504, 11596,
    11688, 11778, 11869, 11961, 12053, 12143, 12234, 12326, 12418,
    12509, 12600, 12692, 12784, 12874, 12965, 13057, 13149, 13239,
    13330, 13422, 13514, 13604, 13695, 13787, 13879, 13970, 14061,
    14153, 14245, 14335, 14426, 14518, 14610, 14700, 14791, 14883,
    14975, 15065, 15156, 15248, 15340, 15431, 15522, 15614, 15706,
    15796, 15887, 15979, 16071, 16161, 16252, 16344, 16436, 16526,
    16617, 16709, 16801, 16892, 16983, 17075, 17167, 17257, 17348,
    17440, 17532, 17622, 17713, 17805, 11413, 11504, 11596, 11688,
    11778, 11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509,
    12600, 12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330,
    13422, 13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153,
    14245, 14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975,
    15065, 15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796,
    15887, 15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617,
    16709, 16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440,
    17532, 17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778,
    11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600,
    12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422,
    13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245,
    14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065,
    15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887,
    15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709,
    16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532,
    17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869,
    11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692,
    12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514,
    13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335,
    14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156,
    15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979,
    16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801,
    16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622,
    17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869, 11961,
    12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692, 12784,
    12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514, 13604,
    13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335, 14426,
    14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156, 15248,
    15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979, 16071,
    16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801, 16892,
    16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622, 17713,
    17805
  ), class = c("yearquarter", "Date")), Series = c(
    "10", "10",
    "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
    "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
    "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
    "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
    "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
    "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
    "10", "10", "10", "101", "101", "101", "101", "101", "101", "101",
    "101", "101", "101", "101", "101", "101", "101", "101", "101",
    "101", "101", "101", "101", "101", "101", "101", "101", "101",
    "101", "101", "101", "101", "101", "101", "101", "101", "101",
    "101", "101", "101", "101", "101", "101", "101", "101", "101",
    "101", "101", "101", "101", "101", "101", "101", "101", "101",
    "101", "101", "101", "101", "101", "101", "101", "101", "101",
    "101", "101", "101", "101", "101", "101", "101", "101", "101",
    "101", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
    "1012", "1012", "1012", "1012", "1012", "1012", "1012", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
    "1013", "1013", "1013", "1013", "1013", "1013", "102", "102",
    "102", "102", "102", "102", "102", "102", "102", "102", "102",
    "102", "102", "102", "102", "102", "102", "102", "102", "102",
    "102", "102", "102", "102", "102", "102", "102", "102", "102",
    "102", "102", "102", "102", "102", "102", "102", "102", "102",
    "102", "102", "102", "102", "102", "102", "102", "102", "102",
    "102", "102", "102", "102", "102", "102", "102", "102", "102",
    "102", "102", "102", "102", "102", "102", "102", "102", "102",
    "102", "102", "102", "102", "102", "102", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
    "1021", "1021", "1021", "1021", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
    "1022", "1022", "1022", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
    "1023", "1023", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
    "1025", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
    "1027", "1027", "1027", "1027", "1027", "1027", "1027", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
    "1029", "1029", "1029", "1029", "1029", "1029"
  ), value = c(
    0.4,
    0.6, 0.5, -0.1, 0.2, 0.8, 0.7, 0.1, 0.2, 0.4, 0.5, 0.1, 0.1,
    1, 0.9, 0.1, 0.6, 1.1, 0.6, 0.3, 0.4, 1.1, 1, -0.6, 0.8, 0.9,
    0.7, -0.5, 0.3, 0.5, 0.3, -1.9, 0.2, 0.4, 0.2, -1.3, 0.4, 0.6,
    0.6, -0.9, 0.6, 0.7, 0.6, -1.7, 2, -0.6, 0.5, -0.7, 0.8, 0.7,
    0.6, -0.1, 0.3, 0.7, 0.9, -0.6, 0.6, 1, 0.9, -0.5, 0.8, 0.9,
    0.7, -1.1, 1, 0.7, 0.8, -0.5, 0.8, 0.7, 1, 0.6, 0.6, 0.2, -0.9,
    0.3, 0.5, 0.2, -0.9, 0.3, -0.2, -0.2, 0, 0.5, 0.6, 0.5, -0.1,
    0.8, 0.8, 0.4, 0, 0.9, 0.7, 0.5, -0.6, 0.6, 0.5, -0.1, -0.8,
    0.1, -0.1, -0.6, -2.9, -0.7, -0.3, -1, -2.4, 0, -0.2, -0.4, -2.2,
    0, 0, -0.4, -1.2, 0, 0.2, 0.1, -1, 0.4, 0.7, 0.1, -0.4, 0.9,
    0.6, 0.4, -0.5, 0.6, 0.6, 0.4, -0.5, 0.8, 0.6, 0.4, -1.1, 1.2,
    0.7, 0.5, 0.2, 1, 0.7, 0.7, -0.1, 0.4, -0.1, -1.3, -0.3, 0.2,
    0, -1.5, -0.2, -0.4, -0.1, -1, -0.1, 0.5, 0.2, -0.6, 0.1, 0.6,
    0.2, -0.3, 0.3, 0.7, 0.5, -0.7, 0.4, 0.7, 0.5, -0.7, 0.3, 0.7,
    0.4, -1, 0.2, 0.5, 0, -0.9, 0.7, 0.8, 0.4, -0.7, 0.6, 0.8, 0.6,
    0.1, 0.5, 0.8, 0.6, -0.2, 0.7, 0.9, 0.6, 0.2, 0.6, 0.8, 0.6,
    -0.3, 0.3, 0.6, 0.1, -0.8, 0, 0.2, 0.2, -1.4, 0.4, 0.6, 0.3,
    -0.4, 0.7, 0.5, 0.5, 1.1, 1, 0.5, -0.3, 0.7, 0.9, 0.4, -0.6,
    0.8, 0, 0, 0.6, 1, 0.9, 0.8, 0.3, 1.3, 1.2, 0.7, 0.3, 1.4, 1,
    0.7, -0.6, 0.8, 0.6, -0.3, -1, 0, -0.3, -0.9, -3.8, -0.8, -0.4,
    -1.3, -2.9, -0.2, -0.4, -0.6, -2.8, -0.1, -0.1, -0.6, -1.6, -0.1,
    0.2, 0, -1.3, 0.5, 0.8, 0, -0.7, 1.2, 0.7, 0.4, -0.6, 0.8, 0.6,
    0.5, -0.6, 1.1, 0.8, 0.5, -1.4, 1.5, 0.8, 0.6, 0.4, 1.3, 0.8,
    0.9, -0.3, -0.1, -0.2, -1.9, -0.5, -0.2, -0.2, -1.2, -0.5, -0.5,
    -0.5, -1.1, -0.3, -0.1, -0.1, -1, -0.1, 0, -0.1, -0.5, 0, 0,
    0, -0.6, 0, 0.2, 0, -0.4, 0, -0.1, -0.2, -1.5, -0.5, -0.4, -0.4,
    -1.7, -0.1, -0.1, -0.1, -1.4, 0, 0, -0.2, -0.6, 0, 0.1, 0.1,
    -0.5, 0.2, 0.4, 0.1, 0.1, 0.4, 0.3, 0.3, -0.2, 0.3, 0.5, 0.3,
    -0.2, 0.5, 0.3, 0.2, -0.3, 0.7, 0.4, 0.3, 0.2, 0.3, 0.4, 0.5,
    0.4, 0.7, 0.6, 0.1, 0.2, 0.9, 0.8, 0.2, 0.2, 0.5, 0.7, 0.2, 0,
    1.1, 1, 0.2, 0.5, 1.1, 0.7, 0.3, 0.3, 1.1, 1.1, -0.6, 0.9, 1,
    0.8, -0.5, 0.4, 0.7, 0.4, -1.7, 0.4, 0.5, 0.4, -1.2, 0.5, 0.7,
    0.8, -0.7, 0.7, 0.8, 0.7, -1.8, 2.3, -0.7, 0.6, -0.7, 0.9, 0.7,
    0.7, 0, 0.2, 0.8, 1, -0.6, 0.6, 1.1, 1, -0.5, 0.8, 0.9, 0.8,
    -1.2, 0.9, 0.7, 0.8, -0.6, 0.7, 0.7, 1, 0.3, 0.3, 0.3, -0.5,
    0.2, 0.2, 0.3, -0.5, 0.2, -0.2, -0.2, -0.1, 0.2, 0.3, 0.2, -0.1,
    0.5, 0.3, 0.3, 0.1, 0.6, 0.4, 0.5, -0.1, 0.4, 0.4, 0.1, -0.3,
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9.7, -3.7, -6.2, -7.1, 7.3, 4.9, -8.1, -0.4, 1.9, 8,
    3.6, -8.7, 1.8, -3, -13.2, 4.7, 0.8, 7.1, -5.3, -9.8, 3.8, 7.8,
    -4.7, 1.8, 2.3, 12.4, -14.8, 7.6, 7.9, 3.4, -13.2, 4.1, -4.1,
    10.3, -0.8, -12.1, 6.3, 13.9, -14.7, 5.1, 6.4, 11.2, -7.1, 5.1,
    17.1, 1.4, -15.4, -3.5, -4.8, 9.2, -34.6, 0.1, 3.1, 7.9
  )), row.names = c(
    NA,
    -923L
  ), key = structure(list(Series = c(
    "10", "101", "1011",
    "1012", "1013", "102", "1021", "1022", "1023", "1025", "1026",
    "1027", "1029"
  ), .rows = list(
    1:71, 72:142, 143:213, 214:284,
    285:355, 356:426, 427:497, 498:568, 569:639, 640:710, 711:781,
    782:852, 853:923
  )), row.names = c(NA, -13L), class = c(
    "tbl_df",
    "tbl", "data.frame"
  ), .drop = TRUE), index = structure("date", ordered = TRUE), index2 = "date", interval = structure(list(
    year = 0, quarter = 1, month = 0, week = 0, day = 0, hour = 0,
    minute = 0, second = 0, millisecond = 0, microsecond = 0,
    nanosecond = 0, unit = 0
  ), class = "interval"), class = c(
    "tbl_ts",
    "tbl_df", "tbl", "data.frame"
  ))
  
  df
  #&gt; # A tsibble: 923 x 3 [1Q]
  #&gt; # Key:       Series [13]
  #&gt;       date Series value
  #&gt;      &lt;qtr&gt; &lt;chr&gt;  &lt;dbl&gt;
  #&gt;  1 2001 Q2 10       0.4
  #&gt;  2 2001 Q3 10       0.6
  #&gt;  3 2001 Q4 10       0.5
  #&gt;  4 2002 Q1 10      -0.1
  #&gt;  5 2002 Q2 10       0.2
  #&gt;  6 2002 Q3 10       0.8
  #&gt;  7 2002 Q4 10       0.7
  #&gt;  8 2003 Q1 10       0.1
  #&gt;  9 2003 Q2 10       0.2
  #&gt; 10 2003 Q3 10       0.4
  #&gt; # ... with 913 more rows
  
  # Attempt 1
  df %&gt;% forecast::tsclean()
  #&gt; Registered S3 method overwritten by 'xts':
  #&gt;   method     from
  #&gt;   as.zoo.xts zoo
  #&gt; Registered S3 method overwritten by 'quantmod':
  #&gt;   method            from
  #&gt;   as.zoo.data.frame zoo
  #&gt; Registered S3 methods overwritten by 'forecast':
  #&gt;   method             from    
  #&gt;   fitted.fracdiff    fracdiff
  #&gt;   residuals.fracdiff fracdiff
  #&gt; Error in is.constant(xx): (list) object cannot be coerced to type 'double'
  
  # Attempt 2
  df %&gt;% tsibble::group_by_key() %&gt;% forecast::tsclean()
  #&gt; Error in is.constant(xx): (list) object cannot be coerced to type 'double'
  </code></pre>
  
  <p><sup>Created on 2019-11-26 by the <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v0.3.0)</sup></p>
  
  <blockquote>
    <p>Written with <a href="https://stackedit.io/" rel="nofollow noreferrer">StackEdit</a>.</p>
  </blockquote>