[R] list contingency tables

2018-11-08 Thread li li
Hi all, I am trying to list all the 4 by 2 tables with some fixed margins. For example, consider 4 by 2 tables with row margins 1,2,2,1 and column margins 3,3. I was able to do it using the code below. However, as seen below, I had to first count the total number of tables with the specific row

Re: [R] Identify row indices corresponding to each distinct row of a matrix

2018-11-08 Thread li li
Thanks. It makes sense. Jeff Newmiller 于2018年11月8日周四 下午8:05写道: > The duplicated function returns TRUE for rows that have already > appeared... exactly one of the rows is not represented in the output of > duplicated. For the intended purpose of removing duplicates this behavior > is ideal. I hav

Re: [R] Identify row indices corresponding to each distinct row of a matrix

2018-11-08 Thread Jeff Newmiller
The duplicated function returns TRUE for rows that have already appeared... exactly one of the rows is not represented in the output of duplicated. For the intended purpose of removing duplicates this behavior is ideal. I have no idea what your intended purpose is, since every row has duplicates

Re: [R] Identify row indices corresponding to each distinct row of a matrix

2018-11-08 Thread William Dunlap via R-help
One way, rather clumsy, is to convert your data.frame in a character vector or list. via an invertible tranformation, and use match on it. E.g., > tmp <- do.call(paste, c(list(sep="\001"), unname(C))) # convert to character > # or tmp <- split(C, seq_len(nrow(C))) # convert to list of its rows >

Re: [R] Identify row indices corresponding to each distinct row of a matrix

2018-11-08 Thread li li
Thanks to all the reply. I will try to use plain text in the future. One question regarding using "which( ! duplicated( m, MARGIN=1 ) )". This seems to return the fist row indices corresponding to the distinct rows but it does not give all the row indices corresponding to each of the distinct rows.

Re: [R] MGCV:: boundary conditions in gam

2018-11-08 Thread Simon Wood
This first derivative penalty spline will do it, but the price paid is that the curves are often quite wiggly. library(mgcv); set.seed(5) x <- runif(100); y <- x^4 + rnorm(100)*.1 b <- gam(y~s(x,m=1)) pd <- data.frame(x=seq(-.5,1.5,length=200)) ff <- predict(b,pd,se=TRUE) plot(x,y,xlim=c(-

Re: [R] summary function does not work with Westfall correction in multcomp with 27 comparisons

2018-11-08 Thread Gerrit Eichner
Dear Rich, w/o the original data we can actually only guess, but I think you may haven't been patient enough to let summary.glht finish its job. Have you tried to increase the number of contrasts, i.e. comparisons, step by step to see how the computational burden and hence the required computing

[R] summary function does not work with Westfall correction in multcomp with 27 comparisons

2018-11-08 Thread Friedman, Richard A.
Dear List. I ran multcomp with 27 comaprisons. The glht command returned an mcp object, but the summary command with the Westfall correction ddi not give a summary. When I ran the same dataset with 4 comparisons I got p-values. When I sued a summary with univariate or Bonferroni’s method with all

Re: [R] Remove specific rows from nested list of matrices

2018-11-08 Thread Ek Esawi
Thank you all, Bert, Jeff, Bill an Don. I realized I made a silly mistake in list indexing. Once I saw Bills’ suggestion and was able to wrap my head around indexing recursive lists, I resolved the problem. For future readers, here is the answers, even though the question may not have been clear. I

Re: [R] Identify row indices corresponding to each distinct row of a matrix

2018-11-08 Thread Bert Gunter
Yes -- much better than mine. I didn't know about the MARGIN argument of duplicated(). -- Bert On Wed, Nov 7, 2018 at 10:32 PM Jeff Newmiller wrote: > Perhaps > > which( ! duplicated( m, MARGIN=1 ) ) > > ? (untested) > > On November 7, 2018 9:20:57 PM PST, Bert Gunter > wrote: > >A mess -- du

[R] MGCV:: boundary conditions in gam

2018-11-08 Thread Mark R Payne
Dear R-help, I have a problem where I am using the mgcv package to in a situation where I am fitting a gam model with a 1-D spline smoother model over a domain [a,b] but then need to make predictions and extrapolate beyond b. Is there anyway where I force the first derivative of the spline to be z

Re: [R] saveRDS() and readRDS() Why? [solved, kind of]

2018-11-08 Thread Robert David Burbidge via R-help
Apologies, unserialize takes a connection, not a file, so you would need something like: # linux (not run) f <- file("rawData.rds", open="r") rawData <- unserialize(f) close(f) The help file states that readRDS will read a file created by serialize (saveRDS is a wrapper for serialize). It ap

Re: [R] saveRDS() and readRDS() Why? [solved, kind of]

2018-11-08 Thread Martin Maechler
> Patrick Connolly > on Thu, 8 Nov 2018 20:27:24 +1300 writes: > Many thanks to Berwin, Eric, Robert, and Jan for their input. > > I had hoped it was as simple as because I typed > > saveRDS("rawData", file = "rawData.rds") on the Windows side. > but that wasn't the case. > > Rob