Making a new variable by taking the natural function of the original

Hello! I'm very new to R and can't figure out a problem of assigning a creating a new variable that takes the natural log of its original.

ggplot(data=Crime, aes(x=MHI))+
geom_histogram()+
theme_minimal()

I'd like to take the log of the x variable and assign it as a new variable, logMHI.

I've tried a few different things, none seem to work.

Thanks so much!

Crime$logMHI <- log(Crime$MHI)

is one way to do it.

1 Like

This topic was automatically closed 42 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.