0

I have imported data by read function

t_2020_10 <- read.csv("2020_10.csv")

and I want to convert 2 columns from integer to character. I've tried this:

t_2020_10$start_station_id <- as.character(t_2020_10$start_station_id)

However, it gave me this error message:

Error in t_2020_10$start_station_id : $ operator is invalid for atomic vectors

I'm sure the code is correct? could you please advise? and how can I convert data structure of multiple columns at once?

TIA

Martin Gal
  • 16,640
  • 5
  • 21
  • 39
  • 3
    What is the output of `str(t_2020_10)`? – Roland Nov 01 '21 at 12:36
  • [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. It's hard to know what's going on otherwise – camille Nov 01 '21 at 16:08
  • [@Roland](https://stackoverflow.com/u/1412059)'s request is helpful for determining the source of the error. As for _"convert[ing the] data structure of multiple columns at once"_, the [**`dplyr`**](https://dplyr.tidyverse.org) package lets you do this with `t_2020_10 `[`%>%`](https://magrittr.tidyverse.org/reference/pipe.html)[`dplyr::mutate`](https://dplyr.tidyverse.org/reference/mutate.html)`(start_station_id = as.character(start_station_id), another_column_name = as.character(another_column_name))`. – Greg Nov 01 '21 at 16:18

0 Answers0