how to add the log of a variable to a dataset?

Hi everyone.
I'm pretty niew to R and I discovered R studio even more recently.
I'm trying to adapt a script from R (wich is working just fine in the R console) to R studio and the main issue I have is that it isn't creating a column with a mutated variable anymore with this line :
MetalsBC$LogBa <- with(MetalsBC, log(1+ Barium_Ba.))
this was running really well in RGui 3.6.1 without any package needed and doesn't compute on RStudio (I thought both were supposed to understand each others ^^)
thanks for your answers!

Is there really a variable whose last letter of its name is the full stop symbol? or is that a typo?

Also if you have a specific error that you want help with, please consider sharing the error at a minimum, or do you mean, that you get no LogBa variable, but no error either ?

This has (almost certainly) nothing to do with RStudio or even the version of R you are using. Most likely you introduced an error in adapting your script.

To get help, please produce a reproducible example:

1 Like

A reprex to confirm that this works and that very likely you just have a typo

iris$log_sepal <- with(iris, log(1 + Sepal.Length))
head(iris$log_sepal)
#> [1] 1.808289 1.774952 1.740466 1.722767 1.791759 1.856298

Created on 2020-03-05 by the reprex package (v0.3.0.9001)

thanks! That was simply it.
In the original dataset the variables names had differents symbols in it. I just simplified it and it's now running smoothly.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.