-1

Hi guys I am a student and we have barely gone through R and are expected the following: dataset In the dataset provided, I'm being told to define the data type of each column including the category and sub-category. How do I do this?

I am not sure where to start Any help will be appreciated

  • 1
    `str(yourdataframe)` or `library(dplyr) glimpse(yourdataframe)` or `library(dplyr) library(tibble) yourdataframe %>% as_tibble` ...etc.. – TarJae Nov 22 '22 at 19:53
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Please [do not post code or data in images](https://meta.stackoverflow.com/q/285551/2372064). It's not clear what "category" and "sub-category" you are referring to. – MrFlick Nov 22 '22 at 20:14

1 Answers1

0

you can change a column data type using the following commands (depending on the data type you want) :

dataframeName$colName <- as.factor(datataframeName$colName)
dataframeName$colName <- as.numeric(datataframeName$colName)
cgvoller
  • 873
  • 1
  • 14