I created a dataset named state indigenous the integrated matrix state.x77 with two consistent variables (Population and also Income) and two variable variables (region and area).

You are watching: Error in unique.default(x, nmax = nmax) : unique() applies only to vectors

I computed mean earnings by region using tapply(), by(), aggregate(), and ave() to check out the layout of the changed object.

But the speak to to ave() is offering the error

Error in unique.default(x) : unique() uses only come vectors

The code is:


r
share
follow
edited Apr 8 "16 at 17:48
*

bill the Lizard
379k203203 yellow badges551551 silver- badges853853 bronze title
asked might 22 "13 in ~ 0:47
*

timetime
90133 gold badges1111 silver badges1515 bronze badges
0
add a comment |

1 answer 1


energetic oldest Votes
30
This is a very common mistake, you need to use the named discussion FUN:

ave(state$inc, state$region, funny = mean)otherwise mean will be construed as another grouping variable (part of the ... Dispute to ave.)


re-superstructure
monitor
answered may 22 "13 in ~ 0:52
*

flodelflodel
83.9k1919 gold badges173173 silver badges210210 bronze title
2
add a comment |

her Answer


Thanks for contributing response to stack Overflow!

Please be certain to answer the question. Carry out details and also share your research!

But avoid

Asking because that help, clarification, or responding to various other answers.Making statements based on opinion; ago them increase with recommendations or personal experience.

To discover more, check out our advice on writing great answers.

See more: Dark Souls 2 Throne Defender Soul, Dark Souls 2: Throne Of Want


Draft saved
Draft discarded

Sign up or log in in


sign up using Google
authorize up using Facebook
sign up making use of Email and Password
send

Post as a guest


surname
email Required, but never shown


Post as a guest


surname
email

Required, but never shown


article Your prize Discard

By click “Post her Answer”, you agree come our regards to service, privacy policy and also cookie policy


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


The Overflow Blog
Featured ~ above Meta
Linked
8
How to calculate Z-score through group
2
R Error in unique.default(x) : unique() uses only come vectors once using ddply
0
How to do contingency table over a perform in r
0
Error in unique.default(x, nmax = nmax) : unique() uses only come vectors by making use of with(data_frame, table(year, country))
0
Truncate dataset after maximum value
connected
4
why this simple ave role is not working
1
R cut duty for strings
1
approach for creating plotting way from data frame
1
exactly how to create an ar indicator variables indigenous a state list in R
3
Merger and also partial addition of rows without teams in R
0
Plot how the approximated survival depends upon the value of a covariate of interest. Difficulties with relevel
0
exactly how do you produce a new character change in R?
0
Residual plot by categorical independent variable only provides residuals for part categories
2
Error in unique.default(x) : unique() uses only come vectors
hot Network inquiries much more hot questions

question feed
i ordered it to RSS
inquiry feed To i ordered it to this RSS feed, copy and also paste this URL into your RSS reader.


*

lang-r
ridge Overflow
products
agency
ridge Exchange Network
site architecture / logo © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.11.9.40686


Stack Overflow works finest with JavaScript allowed
*

her privacy

By click “Accept all cookies”, you agree stack Exchange deserve to store cookie on your maker and disclose details in accordance with our Cookie Policy.