[R] Trailing path separators and dirname(), file.exists(), file.path()

2016-11-12 Thread Dave Gerrard
I've found something irritating in the behaviour of dirname() and subsequent interactions with file.path() and file.exists(). The problem is how it and they deal with trailing path separators. It seems the code is correct to specification but I think it could be better. Part of the problem is re

[R] Variable 'A' is not a factor Error message

2016-11-12 Thread ahmed meftah
I am running a DOE with the following code library(Rcmdr) library(RcmdrMisc) library(RcmdrPlugin.DoE) # Define plackett burman experiment PB.DOE <- pb(nruns= 12 ,n12.taguchi= FALSE ,nfactors= 12 -1, ncenter= 0 , replications= 1 ,repeat.only= FALSE ,randomize= TRUE ,se

Re: [R] Average every 4 columns

2016-11-12 Thread Jim Lemon
Hi Miluj, Perhaps you didn't get my previous email. Let your data frame be named "msdf": block_col_summ<-function(x,step,block_size,FUN="mean") { dimx<-dim(x) return_value<-NA start<-1 end<-start+block_size-1 block_count<-1 while(end <= dimx[2]) { return_value[block_count]<- do.call(FUN

[R] replace items in vector with character based on logical operator

2016-11-12 Thread Adrian Johnson
Hi group, I have a vector of numeric items and I want to replace based on logical operator (> or <) with 'up', 'down' or 'nochange' The way I am doing works sometimes and does not work sometime. I dont understand the problem. In this example, that works for condition DN first, gets over-written

Re: [R] replace items in vector with character based on logical operator

2016-11-12 Thread Jeff Newmiller
Your goal is fundamentally flawed, since all elements of a vector must be if the same type. Create another vector to hold your character information. kc <- rep( 'NC', length( kx ) ) kc[ kx <= qt[[2]] ] <- 'DN' kc[ kx >=qt [[4]] ] <- 'UP' -- Sent from my phone. Please excuse my brevity. On N

Re: [R] replace items in vector with character based on logical operator

2016-11-12 Thread William Dunlap via R-help
Your first replacement in kx changed it to a character vector and comparisons of character strings given different results than comparisons of numbers > kx <- 1:10 > qt <- quantile(kx) > kx[kx <= qt[2]] <- "DN" > kx [1] "DN" "DN" "DN" "4" "5" "6" "7" "8" "9" "10" > "10" < "6" [1] TRUE > > #

[R] Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, :

2016-11-12 Thread greg holly
Dear all; I am getting the following error message when I run maSigPro package by using make.design.matrix commend. I could not figure out why this error happens. Thanks for your help Greg Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, : ‘min’ not meaningful for facto

Re: [R] Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, :

2016-11-12 Thread Duncan Murdoch
On 12/11/2016 7:33 PM, greg holly wrote: Dear all; I am getting the following error message when I run maSigPro package by using make.design.matrix commend. I could not figure out why this error happens. Thanks for your help Greg Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34

Re: [R] Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, :

2016-11-12 Thread greg holly
Hi Duncan; Thanks for this. I used followed command. In command line: blood is the name of the data file, degree=11 because I have 12-time point. I need to create the design matrix of dummies (named des_blood) for fitting time series micorarray gene expression experiments using maSigPro program.

[R] value matching %in% for a number pair

2016-11-12 Thread John
Hi, We can match one numerical value as follows > 3 %in% c(4,5) [1] FALSE > 3 %in% c(4,5,3) [1] TRUE To see whether value pairs are identical, > identical(c(3,4), c(3,5)) [1] FALSE > identical(c(3,4), c(3,4)) [1] TRUE Is there any way to test whether “A value pair is in a set of value p

Re: [R] value matching %in% for a number pair

2016-11-12 Thread Duncan Murdoch
On 12/11/2016 8:36 PM, John wrote: Hi, We can match one numerical value as follows 3 %in% c(4,5) [1] FALSE 3 %in% c(4,5,3) [1] TRUE To see whether value pairs are identical, identical(c(3,4), c(3,5)) [1] FALSE identical(c(3,4), c(3,4)) [1] TRUE Is there any way to test whether

Re: [R] Error in Summary.factor(c(24L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, :

2016-11-12 Thread Duncan Murdoch
On 12/11/2016 8:14 PM, greg holly wrote: Hi Duncan; Thanks for this. I used followed command. In command line: blood is the name of the data file, degree=11 because I have 12-time point. I need to create the design matrix of dummies (named des_blood) for fitting time series micorarray gene expr

Re: [R] value matching %in% for a number pair

2016-11-12 Thread Jeff Newmiller
This really depends on the way you represent these pairs. Here is some food for thought: p <- matrix( c( 1,2, 4,3, 3,3, 2,3, 4,5 ), byrow=TRUE, ncol=2 ) ( 2 %in% p[,1] ) & ( 3 %in% p[,2] ) # (2,3) ( c( 2, 1, 5 ) %in% p[,1] ) & ( c( 3, 2, 5 ) %in% p[,2] ) # (2,3) (1,2) (5,5) -- Sent from my phon

Re: [R] value matching %in% for a number pair

2016-11-12 Thread William Dunlap via R-help
> S <- list(c(1,2), c(4,3), c(3,3), c(2,3), c(4,5)) > list(c(1,2), c(3,4), c(2,3)) %in% S # is in S? [1] TRUE FALSE TRUE > match(list(c(1,2), c(3,4), c(2,3)), S) # which element of S? [1] 1 NA 4 Bill Dunlap TIBCO Software wdunlap tibco.com On Sat, Nov 12, 2016 at 5:36 PM, John wrote: > Hi,

Re: [R] value matching %in% for a number pair

2016-11-12 Thread Jeff Newmiller
Sorry, that was a fail. Better to think about: any( 2 == p[,1] & 3 == p[,2] ) v <- matrix( c( 2,3, 1,2, 5,5 ), byrow=TRUE, ncol=2 ) apply( v, 1, function(x) { any( x[1]==p[,1] & x[2]==p[,2] ) } ) -- Sent from my phone. Please excuse my brevity. On November 12, 2016 6:11:13 PM PST, Jeff Newmille

Re: [R] value matching %in% for a number pair

2016-11-12 Thread Jim Lemon
Hi john, I don't know whether this breaks any rules, but: target_pair<-c(3,4) pair_list<-list(c(1,2),c(3,4),c(5,6)) sapply(pair_list,identical,target_pair) [1] FALSE TRUE FALSE Jim On Sun, Nov 13, 2016 at 1:32 PM, Jeff Newmiller wrote: > Sorry, that was a fail. Better to think about: > > any(

Re: [R] Is this foreach behaviour correct?

2016-11-12 Thread James Hirschorn
I'm still not clear about whether this is a bug in foreach. Should c.Date be invoked by foreach with .combine='c'? On 11/06/2016 07:02 PM, William Dunlap wrote: Note that in the OP's example c.Date is never invoked. c.Date is called if .combine calls c rather than if .combine is c: > library(z