banuka
October 2, 2021, 8:13am
1
##CSV file df date column separate to year and month columns.
Error: arrange() failed at implicit mutate() step.
Problem with mutate()
column ..1
.
i ..1 = Month
.
x object 'Month' not found
Run rlang::last_error()
to see where the error occurred.
The error message is quite explicit. It couldn't find Month in your dataset.
Without a sample of your data neither can we!
Can you provide a head( )?.
Can you provide a reprex?
If you can see Month (not month) as a column my gut feeling is there may be a rogue character that doesn't display on screen but is in the name. Janitor could be your friend. But I'm speculating...
The other time I see this is when I stupidly forget to pass my data to the mutate function!
1 Like
banuka
October 2, 2021, 9:41am
3
library(tidyr)
setwd("D:\\time series assignment")
dir()
data=read.csv("data.CSV")
head(data)
data %>%
separate(Year..Month, into = c('Year', 'Month'), sep = '-') %>%
select(Year,Month,Tea.Production)
library(dplyr)
head(df)
str(df)
df=arrange(df,Month,Tea.Production)
banuka
October 2, 2021, 9:48am
4
Initial dataframe from csv file
banuka
October 2, 2021, 9:51am
5
modified data frame. I need to sort this data set according to month. All January values together and all February values together. likewise
Do you need the months to go in the correct order and the year too?
banuka
October 5, 2021, 2:17pm
8
Basically i need to convert imported csv file df to tsibble
OK. Would it be better... to us as_tisbble by converting year..month to a proper date?
library(tidyr)
require(tsibble
setwd("D:\\time series assignment")
data=read.csv("data.CSV")
data %>%
mutate(YearMonth = as.Date(Paste 0(Year..Month,"-01")) %>%
as_tsibble(index=YearMonth, key=Tea.Production)
system
Closed
October 29, 2021, 10:15pm
10
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.