Question: (Closed) Merging Data Frames With Long Names
0
gravatar for robjohn7000
7.2 years ago by
robjohn7000100
United Kingdom
robjohn7000100 wrote:

Hi,

I tried merging two data frames (One_17#20, Two_18#30) using the R merge function this way:

x <- merge(One_17#20, Two_18#30)

I got the following error:

Error in merge(One_17) : object 'One_17' not found.

I thought this might be due to the long names with underscore/# character. Does anyone know the way around this problem?

Thanks

R merge • 1.4k views
ADD COMMENTlink modified 7.2 years ago by Devon Ryan98k • written 7.2 years ago by robjohn7000100

This is not a bioinformatics question.

ADD REPLYlink written 7.2 years ago by Michael Dondrup48k
2
gravatar for karl.stamm
7.2 years ago by
karl.stamm3.9k
United States
karl.stamm3.9k wrote:

That # is a comment character, the system only sees merge(One_17 and I'm surprised it didnt give the error missing ), that might have been next if there was a variable named One_17

You can't use # in variable names in many programming languages.

ADD COMMENTlink modified 7.2 years ago • written 7.2 years ago by karl.stamm3.9k
1
gravatar for Devon Ryan
7.2 years ago by
Devon Ryan98k
Freiburg, Germany
Devon Ryan98k wrote:

As karl.stamm mentioned, don't use # in variable names (in general, don't use symbols other than "_", which I'm sure is also a special character in some language I've never used). If you must, though, then

x <- merge(`One_17#20`, `Two_18#30`)

will do what you want.

ADD COMMENTlink modified 7.2 years ago • written 7.2 years ago by Devon Ryan98k

Thanks for your comments!

ADD REPLYlink written 7.2 years ago by robjohn7000100

You might have used it, the underscore x_4 was an assignment operator in R until 1.8.0 and also in S-Plus.

ADD REPLYlink written 7.2 years ago by Michael Dondrup48k

That predates my usage of R by at least 7 years (and I've never used S-Plus) :)

ADD REPLYlink written 7.2 years ago by Devon Ryan98k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1777 users visited in the last hour
_