Not sure how to fix this error in my code.
limit data to 2015 basic and safe water
library(package = "tidyverse")
water.cleaned <- water %>%
select(Country, Total, Total_1) %>%
rename(Country = 'Country', perc.basic2015water = 'Total', perc.safe2015water = 'Total_1')
Error in select()
:
! Can't subset columns that don't exist.
Column Total
doesn't exist.
Run rlang::last_error()
to see where the error occurred.
rlang::last_error()
<error/vctrs_error_subscript_oob>
Error inselect()
:
! Can't subset columns that don't exist.
ColumnTotal
doesn't exist.
Backtrace:
- water %>% select(Country, Total, Total_1) %>% ...
- dplyr:::select.data.frame(., Country, Total, Total_1)
Runrlang::last_trace()
to see the full context.
rlang::last_trace()
<error/vctrs_error_subscript_oob>
Error inselect()
:
! Can't subset columns that don't exist.
ColumnTotal
doesn't exist.
Backtrace:
▆
- ├─water %>% select(Country, Total, Total_1) %>% ...
- ├─dplyr::rename(...)
- ├─dplyr::select(., Country, Total, Total_1)
- ├─dplyr:::select.data.frame(., Country, Total, Total_1)
- │ └─tidyselect::eval_select(expr(c(...)), data = .data, error_call = error_call)
- │ └─tidyselect:::eval_select_impl(...)
- │ ├─tidyselect:::with_subscript_errors(...)
- │ │ └─rlang::try_fetch(...)
- │ │ └─base::withCallingHandlers(...)
- │ └─tidyselect:::vars_select_eval(...)
- │ └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
- │ └─tidyselect:::eval_c(expr, data_mask, context_mask)
- │ └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
- │ └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
- │ └─tidyselect:::as_indices_sel_impl(...)
- │ └─tidyselect:::as_indices_impl(...)
- │ └─tidyselect:::chr_as_locations(x, vars, call = call, arg = arg)
- │ └─vctrs::vec_as_location(...)
- └─vctrs (local)
<fn>
() - └─vctrs:::stop_subscript_oob(...)
-
└─vctrs:::stop_subscript(...)
-
└─rlang::abort(...)