writing data with dots or citation

Hi R community

So when running my dataset, R studio change the way it wants me to refere to my data , in on of these two ways:
Baseline$Rec.age.in.y
Baseline$Rec age in y

This means that I often have to change my entire script.

Why does this happen?
I have installed the following packages

library(readxl)
library(ggplot2)
library(ggpubr)
library(nlme)
dir()
library(Publish)
library(dplyr)
library(tidyverse)

Hope you can help me :slight_smile:

Best, Kathrine

This is a non-syntactic variable name (because of the empty spaces) and should be avoided since It can cause issues and makes code typing harder. That is why packages like readxl automatically "clean" them (by replacing empty spaces with dots).

The way to force the use of a non-syntactic variable name is by enclosing it between backticks i. e. `Rec age in y`

Thank you for the fast reply.
I still don't know hwo I get it to accept Baseline$Rec.age.in.y
All my codes are written like this, but now after running library(readxl), it wants me to change it to Baseline$ Rec age in yand this messages comes up:

Error in unique.default(c("AsIs", oldClass(x))) :
object 'Rec.age.in.y' not found

`Rec age in y` != Rec.age.in.y

Both variable names are not equivalent, you have to choose a naming convention and make sure your data set is being read respecting that naming convention.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

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.