Error when add `in` column into data.frame
1
0
Entering edit mode
@qiuworldou-8834
Last seen 9.3 years ago
United States

Hi,

This is a question about R. 

I try to assign a vector to a data.frame with name 'in' and got error:

Error: unexpected 'in' in "refseq$in"

I just want to know why I get this error? Thank you.

refseq <- data.frame(a=letters[1:3])
refseq$in <- 1:3
data.frame • 997 views
ADD COMMENT
2
Entering edit mode
@ryan-c-thompson-5618
Last seen 10 weeks ago
Icahn School of Medicine at Mount Sinai…

"in" is a reserved word in R. It is used in the syntax for loops. You should choose a different name for that column. If you really really have to use "in" as the column name for some reason, you can do so using backticks:

refseq$`in` <- 1:3

but I don't recommend this, since you will be stuck using backticks any time you want to refer to that column by its name.

In the future, if you have a generic R question that doesn't have to do with Bioconductor, you should ask it on Stack Overflow. You're likely to get a good answer much more quickly over there.

ADD COMMENT
0
Entering edit mode
ADD REPLY

Login before adding your answer.

Traffic: 466 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6