Re: [R] Splitting a data column randomly into 3 groups

2021-09-04 Thread Avi Gross via R-help
Abou, I believe I addressed this issue in a private message the other day. As a general rule, truncating can leave a remainder. If M = length(whatever)/3 Then M is no longer an integer. It can be a number ending in .333... or .666... as well as 0. Now R may silently truncate somethi

Re: [R] Splitting a data column randomly into 3 groups

2021-09-04 Thread Bert Gunter
I have a more general problem for you. Given n items and 2 <=g < wrote: > > Dear Thomas: > > > Thank you very much for your input in this matter. > > > The core part of this R code(s) (please see below) was written by *Richard > O'Keefe*. I had three examples with different sample sizes. > > > > *

Re: [R] combining geom_boxplot and geom_point with jitter

2021-09-04 Thread Rui Barradas
Hello, And another way, with geom_jitter p + geom_jitter( mapping = aes(shape = NMP_cat, group = Software), position = position_dodge2(width = 1) ) Hope this helps, Rui Barradas Às 17:22 de 04/09/21, Rui Barradas escreveu: Hello, The problem is that you have two grouping aesthetics, c

Re: [R] Splitting a data column randomly into 3 groups

2021-09-04 Thread AbouEl-Makarim Aboueissa
Dear Thomas: Thank you very much for your input in this matter. The core part of this R code(s) (please see below) was written by *Richard O'Keefe*. I had three examples with different sample sizes. *First sample of size n1 = 204* divided randomly into three groups of sizes 68. *No problems

Re: [R] . Re: Splitting a data column randomly into 3 groups

2021-09-04 Thread Avi Gross via R-help
Thomas, There are many approaches tried over the years to do partitioning along the lines you mentioned and others. R already has many built-in or in packages including some that are quite optimized. So anyone doing serious work can often avoid doing this the hard way and build on earlier work. N

Re: [R] combining geom_boxplot and geom_point with jitter

2021-09-04 Thread Rui Barradas
Hello, The problem is that you have two grouping aesthetics, color and shape. In geom_point make the group explicit: p <- ggplot(my_data, aes(x = Diet, y = value, color = Software)) p <- p + geom_boxplot(outlier.shape = NA) p + geom_point( mapping = aes(shape = NMP_cat, group = Software),

Re: [R] How to globally convert NaN to NA in dataframe?

2021-09-04 Thread Greg Minshall
Duncan, > x[] <- lapply(...) says "set the values in x to the values in the list > on the RHS", so x retains its class. thanks! cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-h

[R] . Re: Splitting a data column randomly into 3 groups

2021-09-04 Thread Thomas Subia via R-help
I was wondering if this is a good alternative method to split a data column into distinct groups. Let's say I want my first group to have 4 elements selected randomly mydata <- LETTERS[1:11] random_grp <- sample(mydata,4,replace=FALSE) Now random_grp is: > random_grp [1] "H" "E" "A" "D" # How's

Re: [R] Managing NA values in aggregate

2021-09-04 Thread Jeff Newmiller
Literal translation... aggregate( mydf$value , mydf[ , "year_month", drop=FALSE ] , function( x ) if ( all( is.na( x ) ) ) NA else sum( x, na.rm = TRUE ) ) On September 4, 2021 9:06:57 AM PDT, Stefano Sofia wrote: >Dear R-list users, >I encountered a silly problem usi

[R] Managing NA values in aggregate

2021-09-04 Thread Stefano Sofia
Dear R-list users, I encountered a silly problem using aggregate, but I am not able to get rid of it. I read the manual quite carefully, probaby not enough. Suppose I have the following data frame: mydf <- data.frame(year_month=rep(c("2003-12", "2004-12", "2005-12"), 3), station_number=c(rep(181

Re: [R] Calculate daily means from 5-minute interval data

2021-09-04 Thread Rich Shepard
On Fri, 3 Sep 2021, Jeff Newmiller wrote: The fact that your projects are in a single time zone is irrelevant. I am not sure how you can be so confident in saying it does not matter whether the data were recorded in PDT or PST, since if it were recorded in PDT then there would be a day in March