undefined columns selected!

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

undefined columns selected!

R help mailing list-2

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

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: undefined columns selected!

John McKown
On Wed, May 4, 2016 at 8:05 AM, ch.elahe via R-help <[hidden email]>
wrote:

>
> 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
>

​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.


>
> Thanks for any help,
> Elahe
>
>

--
The unfacts, did we have them, are too imprecisely few to warrant our
certitude.

Maranatha! <><
John McKown

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: undefined columns selected!

Bert Gunter-2
In reply to this post by R help mailing list-2
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
<[hidden email]> wrote:

>
> 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
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: undefined columns selected!

MacQueen, Don
In reply to this post by R help mailing list-2
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



--
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/4/16, 6:05 AM, "R-help on behalf of ch.elahe via R-help"
<[hidden email] on behalf of [hidden email]> wrote:

>
>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
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://secure-web.cisco.com/17LbfsJ6l1TxAGGDaZPJaqSjzCIWn5E9CwPSSMrKL6TmF
>nzxq4NMk2_I5ZoRND9U7-DVdKRI4gQq-ksFm42c_Y4YLWER6RjmX7KA43TlJE090H6BW03h2ch
>R-AjcGVBd7OkbsupK4ILVvkOhZEs4oearHg3fxw5eGd1HheF2ZmV23Gk8iUz73qq3xABMYDqRs
>MimloONz77mr0nVciORpjobMGuDvIH69DttdwbXnkLyVgrlscdiOjTp_LjcdJMSFKqMjepMDxH
>iQGQfThQ4q3l5ZjSUts8soTR8Bg5R722f-4WJkevdYYreIEU3i0aH64_AdN7Hhn9lHL1MUOm0K
>Mg0IV4twClhcRjs7Bf5Qf9M/https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2F
>r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.