$ is just valid for recursive objects, and also is only discussed in the area below on recursive objects.

You are watching: $ operator is invalid for atomic vectors

Now, let"s check whether x is recursive

> is.recursive(x)<1> FALSEA recursive object has actually a list-like structure. A vector is not recursive, it is an atomic object instead, let"s check

> is.atomic(x)<1> TRUEThus you acquire an error when applying $ to a vector (non-recursive object), usage < instead:

> x<"ed">ed 2 You have the right to additionally use getElement

> getElement(x, "ed")<1> 2
Share
Improve this answer
Follow
edited Apr 25 "14 at 17:56
answered Apr 25 "14 at 17:51

*

Jilber UrbinaJilber Urbina
51.5k99 gold badges102102 silver badges129129 bronze badges
2
Add a comment |
41
The reason you are getting this error is that you have a vector.

If you want to usage the $ operator, you simply need to transform it to a documents.framework. But considering that you only have one row in this particular situation, you would certainly additionally have to transpose it; otherwise bob and also ed will certainly end up being your row names rather of your column names which is what I think you desire.

x
Share
Improve this answer
Follow
edited Oct 16 "16 at 10:52

*

Adam Smith
2,27922 gold badges1717 silver badges3333 bronze badges
answered Feb 22 "15 at 23:24
*

DalupusDalupus
1,03099 silver badges1919 bronze badges
2
Add a comment |
13
Because $ does not work on atomic vectors. Use < or << rather. From the help file for $:

The default techniques occupational rather differently for atomic vectors, matrices/arrays and for recursive (list-prefer, see is.recursive) objects. $ is just valid for recursive objects, and is just discussed in the area below on recursive objects.

x<<"ed">> will work.


Share
Improve this answer
Follow
answered Apr 25 "14 at 17:51
tmpname12345tmpname12345
2,6611616 silver badges2020 bronze badges
Add a comment |
4
Here x is a vector.You should convert it right into a dataframework for using $ operator.

x will certainly occupational for you.

xwill certainly offer you output of x as:bob 1ed 2And, will offer you output of x$ed as:NULL If you want bob and also ed as column names then you need to transpose the dataframework favor x So your code becomes

xNow the output of x$ed is:<1> 2


Share
Improve this answer
Follow
edited Jul 8 "19 at 13:30
answered Jul 8 "19 at 13:21
Sanjay NandakumarSanjay Nandakumar
18388 bronze badges
Add a comment |
0
You get this error, despite everything being in line, because of a dispute led to by one of the packages that are currently loaded in your R environment.

So, to solve this worry, detach all the packeras that are not essential from the R atmosphere. For example, when I had actually the very same worry, I did the following:

detach(package:neuralnet)bottom line: detach all the libraries no longer needed for execution... and also the trouble will certainly be addressed.


Share
Improve this answer
Follow
edited Jun 13 "18 at 12:44
answered Jun 13 "18 at 12:16
Chinnappa ReddyChinnappa Reddy
1933 bronze badges
0
Add a comment |
0
This solution worked for medata


Share
Improve this answer
Follow
answered Jun 4 at 19:19
sümeyra özuğursümeyra özuğur
1
Add a comment |
-2
Atomic collections are available by $

Recursive collections are not. Rather the << >> is used

Browse<1>> is.atomic(list()) <1> FALSE Browse<1>> is.atomic(information.frame()) <1> FALSE Browse<1>> is.atomic(class(list(foo="bar"))) <1> TRUE Browse<1>> is.atomic(c(" lang ")) <1> TRUER deserve to be funny sometimes

a = list(1,2,3) b = data.frame(a) d = rbind("?",c(b)) e = exp(1) f = list(d) print(data.frame(c(list(f,e)))) X1 X2 X3 X2.71828182845905 1 ? ? ? 2.718282 2 1 2 3 2.718282
Share
Improve this answer
Follow
edited May 18 "18 at 0:38
camille
14.2k1313 gold badges3131 silver badges4848 bronze badges
answered Mar 24 "15 at 3:09
kpiekpie
8,13755 gold badges1919 silver badges4141 bronze badges
1
Add a comment |

Your Answer


Thanks for contributing a response to Stack Overflow!

Please be certain to answer the question. Provide details and share your research!

But avoid

Asking for assist, clarification, or responding to various other answers.Making statements based upon opinion; back them up through referrals or personal experience.

To learn even more, watch our tips on creating great answers.

See more: Simple Skills Crossword Clue, Potential Answers For Simple Skills


Draft saved
Draft discarded

Sign up or log in


Sign up making use of Google
Sign up using Facebook
Sign up utilizing Email and Password
Submit

Article as a guest


Name
Email Required, but never shown


Article as a guest


Name
Email

Required, but never before shown


Article Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of company, privacy plan and cookie policy


Not the answer you're looking for? Browse various other inquiries tagged r or ask your own question.


The Overflow Blog
Featured on Meta
Linked
23
R, accessing a column vector of a matrix by name
2
How to obtain time distinctions via output having multiple units
0
Vectorizing via lapply rather of using For loop
0
Error: $ operator is invalid for atomic vectors while utilizing fscaret to execute attribute selection (wrapper approach)
0
How to choose personalities that are present in multiple columns of data
0
Creating information frames through various names in a loop
0
How can i include 2 various markers in the exact same Rshiny plot
0
Error in 2 almost similar R functions- one gets executed yet not the other
-1
How to obtain vector's TRUE names
Related
0
Error $ operator is invalid for atomic vectors or "No Bins"
0
googlevis $ operator is invalid for atomic vectors
0
R: $ operator invalid for atomic vectors Error through POSIX
1
Anova: Error: $ operator is invalid for atomic vectors
0
Error: $ operator is invalid for atomic vectors via ols()
Hot Netjob-related Questions even more hot concerns

Concern feed
Subscribe to RSS
Question feed To subscribe to this RSS feed, copy and paste this URL right into your RSS reader.


lang-r
Stack Overcirculation
Products
Company
Stack Exchange Network-related
site style / logo design © 2021 Stack Exreadjust Inc; user contributions licensed under cc by-sa. rev2021.9.10.40187


Stack Overcirculation works finest with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exadjust deserve to save cookies on your device and disclose information in accordance through our Cookie Policy.