0

I have a time series, where left column (not column index) is date and the only column is number.

How can I filter this series from its date index? I can not do it as usual because the date is nor a column. it is on left side (does not have a title)

Thanks!

  • If you have a `data.frame` with one variable and row names, you can extract the row names with `df$date <- row.names(df)`, then filter on that variable. – Charlie Gallagher Jan 15 '21 at 19:21

1 Answers1

-1

Something like this might be what you are looking for. It will create a new column based on the index of the dataframe. Once that's created, you can then filter as needed using dplyr as per normal. The answer is copied from here.

# Original dataframe

               RMSE
A         0.03655830
B         0.24513014
C         0.02009853
D         0.02223135   

Code to make new column from index

df <- cbind(newColName = rownames(df), df)
rownames(df) <- 1:nrow(df)

# new dataframe

  newColName       RMSE
1          A 0.03655830
2          B 0.24513014
3          C 0.02009853
4          D 0.02223135
Dharman
  • 30,962
  • 25
  • 85
  • 135
thehand0
  • 1,123
  • 4
  • 14