Skip to content

undefined columns selected!

4 messages · Elahe chalabi, John McKown, Bert Gunter +1 more

#
Hi all,
I know it seems simple but I am trying to copy a code and I don't know what is the problem with this command!

    msubsub=msub[,cn]

the error I get is : error in '[.data.frame '(msub, ,cn) : undefined columns selected 
 
Thanks for any help,
Elahe
#
On Wed, May 4, 2016 at 8:05 AM, ch.elahe via R-help <r-help at r-project.org>
wrote:
?First - very important - please change from HTML posting to plain text.
This forum doesn't handle HTML well and its use very often results in
?unreadable and thus unusable messages.

?TLI (Too Little Information). I would probably help if you would post the
information from things like:

dput(head(msub))

dput(head(cn)?)


Most want "dput(msub)" and "dput(cn)", but I use the "head()" to subset
that to examples which are usually easier to post. It depends on the
problem and the size of the data involved. Oh, please don't just
cut'n'paste the output from simply listing "msub" or "cn", that produces
output which cannot be cut and pasted easily into an R session. Thanks.

  
    
#
The the column name must be quoted in the index:

msubsub=msub[,"cn"]


Please go through a basic R tutorial  or two if you want to learn to use R.


Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, May 4, 2016 at 6:05 AM, ch.elahe via R-help
<r-help at r-project.org> wrote:
#
First, type
   names(msub)
and then type
   cn
and compare the output.

Probably, you will find a name in cn that is not among the names of msub.

To maybe make it easier to see the missing column(s), you can type

  setdiff(cn, names(msub))

The expression
  msub[,cn]
is intended to select columns from msub. That error message means that you
are trying to select one or more columns that are not there.

Or perhaps Bert Gunter is correct, and it should be
  msub[,'cn']
but I believe that if that were the case the error message would likely be
different. Without more information we can't be sure.

-Don