Reputation: 69
I loaded some data in R and mistakenly named it as 86. Now when I want to call the data frame I end up with the number 86 instead of my data set. Is there a way to call the data set rather than the number 86? Also, is there a way to change the name of the data so it is no longer a number? Thank you.
Upvotes: 4
Views: 59
Reputation: 21621
You need to use backticks:
"86" <- data.frame(a = "meow", b = "wouf")
> `86`
# a b
# 1 meow wouf
To change the name of your data frame, simply assign (<-
) data from 86
to df
and remove (rm
) the original 86
df <- `86`; rm(`86`)
> df
# a b
# 1 meow wouf
Because of copy-on-modify, this will not allocate memory for df
.
> "86" <- data.frame(a = "meow", b = "wouf"); tracemem(`86`)
# [1] "<0x3936b28>"
> df <- `86`; tracemem(df)
# [1] "<0x3936b28>"
Upvotes: 5