Changing column attributes in R

Hi,
I am new to this package and in fact data analysis. At the moment I am trying to complete my Google Data Analysis Capstone. When I try to merge my csv files I receive the following:
class attribute on column 3 of item 4 does not with column 3 of item 1. Upon inspection the conflict appears to arise as one column is col_datetime and the other is col_character. Is there a way for me to change specific columns in R?

df <- data.frame(a=c(1,2,3), b=c(4,5,6), c=c(7,8,9))
df$b <- as.factor(df$b)
df$c <- as.character(df$c)
str(df)

'data.frame': 3 obs. of 3 variables:
a: num 1 2 3 b: Factor w/ 3 levels "4","5","6": 1 2 3
$ c: chr "7" "8" "9"

Please use dplyr

install.packages(“dplyr”)
library(dplyr)

First:

Object <- rename(muestra, Autos = genero1)

(Autos is the new column name, that replace genero1 column name.)

Second: You may recode:

distinct(Object, Autos)
Object$Autos <- recode(Object$Autos,
Acción = "Audi",
Action = "Audi")

(Where Acción and Action are chenged by “Audi”)

Greetings!

Miguel Angel Bustos

It might be helpful for you to know how to properly format code and console output that you post here. Using proper code formatting makes the site easier to read, prevents confusion (unformatted code can get garbled by the forum software :anguished:), and is generally considered the polite thing to do. Check out this FAQ to find out how — it's as easy as the click of a button! :grinning::

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.