0

I've got a tibble that I'm struggling to turn into a tsibble.

  # A tibble: 13 x 8
   year  `Administration, E~ `All Staff` `Ambulance staff` `Healthcare Assi~ `Medical and De~ `Nursing, Midwife~
   <chr>               <dbl>       <dbl>             <dbl>             <dbl>            <dbl>              <dbl>
 1 2009                 3.97        5.08              7.16              6.94             1.36               6.19
 2 2010                 4.12        5.07              6.89              7.02             1.41               6.02
 3 2011                 4.06        5.03              6.69              7.06             1.36               6.02
 4 2012                 4.40        5.40              7.79              7.48             1.52               6.44
 5 2013                 4.28        5.35              8.19              7.46             1.48               6.44
 6 2014                 4.45        5.56              8.87              7.82             1.53               6.67
 7 2015                 4.30        5.29              6.86              7.54             1.44               6.30
 8 2016                 4.21        5.15              7.56              7.15             1.66               6.17
 9 2017                 4.33        5.13              7.32              7.20             1.69               6.04
10 2018                 4.58        5.30              7.96              7.00             1.73               6.38
11 2019                 4.71        5.52              7.66              7.96             1.94               6.65
12 2020                 4.69        5.98              7.49              8.37             2.11               7.56
13 2021                 4.19        5.72              9.62              8.47             1.71               7.29
# ... with 1 more variable: Scientific, Therapeutic and Technical staff <dbl>

How would I turn this into a tsibble so that I can plot graphs with ggplot2?

When trying as_tsibble()

absence_ts <- as_tsibble(absence, key = absence$All Staff, index = absence$year)

it comes up with the following error:

Error: Must subset columns with a valid subscript vector. x Can't convert from <double> to <integer> due to loss of precision.

  • try `as_tsibble` refer https://tsibble.tidyverts.org/ – Nad Pat Sep 07 '21 at 14:34
  • use `as_tsibble(absense, key = `All Staff`, index = year)`. – phiver Sep 07 '21 at 15:01
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Sep 07 '21 at 16:44

0 Answers0