Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Jim Lemon
It does remind me of counting on one's fingers, though. Jim On Sun, Dec 20, 2020 at 4:38 PM Bert Gunter wrote: > But c(x[-1], x[1]) is, which is not so terrible, after all... __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https:

Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Bert Gunter
Inline... On Sat, Dec 19, 2020 at 9:22 PM Richard O'Keefe wrote: > More accurately, in x[i] where x and i are simple vectors, > i may be a mix of positive integers and zeros > where the zeros contribute nothing to the result > or it may be a MIX of negative integers and zeros > where the ze

Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Richard O'Keefe
More accurately, in x[i] where x and i are simple vectors, i may be a mix of positive integers and zeros where the zeros contribute nothing to the result or it may be a MIX of negative integers and zeros where the zeros contribute nothing to the result and -k means "do not include element k".

Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Chao Liu
Jim and Bert, Thank you for your help. It was an indexing problem. I was able to solve it by changing the split line to: clusters <- split(seq_len(nrow(dd)), dd$cluster). Thank you. Best, Chao On Sat, Dec 19, 2020 at 4:19 PM Jim Lemon wrote: > Hi Chao, > You have discovered one of the surpri

Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Jim Lemon
Hi Chao, You have discovered one of the surprising things about the extraction operator "[". It expects to get an object consisting of integers (like 1,2,3,...) or logical values (TRUE,FALSE or 0,1). As you have passed the _values_ of your cluster, it can't deal with the negative numbers as they do

Re: [R] Error Message Cannot use `+.gg()` with a single argument. Did you accidentally put + on a new line?

2020-12-19 Thread Eric Berger
As the error message says, move the '+' sign from the start of the second line to the end of the preceding line. On Sat, Dec 19, 2020 at 10:29 PM Rosato, Kyle wrote: > For some simple reason, I am unable to see the mistake: > > ggplot(filter(nlsw88, !(is.na(union))), aes(y = wage, x = union, fi

[R] Error Message Cannot use `+.gg()` with a single argument. Did you accidentally put + on a new line?

2020-12-19 Thread Rosato, Kyle
For some simple reason, I am unable to see the mistake: ggplot(filter(nlsw88, !(is.na(union))), aes(y = wage, x = union, fill = union)) + geom_boxplot() + facet_wrap(~idblack) [[alternative HTML version deleted]] __ R-help@r-project.org mailing

Re: [R] Question about dotwhisker

2020-12-19 Thread Dan Bolser
Sorry, forgot to link the actual vignette: https://cran.r-project.org/web/packages/dotwhisker/vignettes/dotwhisker-vignette.html In fact the vignette states: dwplot(m1_df) #same as dwplot(m1) where m1_df is m1_df <- tidy(m1) They are not the same in either the vignette itself or on my computer.

[R] Question about dotwhisker

2020-12-19 Thread Dan Bolser
Hello, I'm reading this and one part is confusing me (the most ;-) library(dotwhisker) library(broom) library(dplyr) m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars) # Please compare: dwplot(m1) dwplot(tidy(m1)) Why is the dwplot of tidy(m1) so different from the dwplot of m1? I had thou

Re: [R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Bert Gunter
1. Thanks for the example. 2. Good opportunity to learn (more) about debugging in R. See ?debug or ?browser() 3. Hint: what do you think ... unlist(clusters[... gives? (you are using it as an index for subscripting dd) Cheers, Bert Bert Gunter "The trouble with having an open mind is that peop

[R] Problem in cluster sampling: 'mixed with negative subscripts'

2020-12-19 Thread Chao Liu
Hi, I was trying to do a cluster sampling but came across this error: Error in xj[i] : only 0's may be mixed with negative subscripts. What is the cause and how to get around? Thank you for your help! Here is the code: #simulate some data y <- rnorm(20) x <- rnorm(20) z <- rep(1:5, 4) w <- rep(1