search for: resnew

Displaying 13 results from an estimated 13 matches for "resnew".

Did you mean: renew
2013 Sep 27
0
Best and Worst values
...resHigh[,1],Predict=resHigh[,2][,1],Actual=resHigh[,2][,2]) ?resHigh1$id<- 1:nrow(resHigh1) ?resLow1$id<- 1:nrow(resLow1) resLow2<-resLow1[!resLow1[,2]>=0,] resHigh2<- resHigh1[resHigh1[,2]>0,] resFinal<- merge(resLow2,resHigh2,by=c("Date","id"),all=TRUE) resNew<- as.data.frame(matrix(0,nrow(resFinal)*2,3)) resNew[,1]<-rep(resFinal$Date,each=2) ###indexing is not that important here.? You can just ?melt() or ?reshape() from wide to long format and when you try ddply(), it will automatically arrange the data #accordingly. indx<-cbind(rep(seq_le...
2013 Oct 14
1
R Help-how to use sapply w/tapply
...he posting guide esp. regarding home work, assignments etc.) res <- sapply(Gene[,-1],function(x) tapply(x,list(Gene$Genotype),mean)) #or res2 <-? aggregate(.~Genotype, data=Gene,mean) #or library(plyr) ?res3 <- ddply(Gene,.(Genotype),numcolwise(mean)) identical(res2,res3) #[1] TRUE resNew <- data.frame(Genotype=rownames(res),res,stringsAsFactors=FALSE) ?attr(resNew,"row.names") <- attr(res2,"row.names") ?identical(resNew,res2) #[1] TRUE A.K. So I'm having a problem with the part b of the assignment. This is the question This is how I solved Pa...
2013 Feb 17
6
histogram
HI Elisa, You could use ?cut() vec1<-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45) label1<-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x) x),lapply(seq(5,50,5),function(x) x),SIMPLIFY=FALSE),function(i) paste(i[1],"<x<=",i[2],sep="")))
2013 Jun 08
1
splitting a string column into multiple columns faster
Hello! I have a column in my data frame that I have to split: I have to distill the numbers from the text. Below is my example and my solution. x<-data.frame(x=c("aaa1_bbb1_ccc3","aaa2_bbb3_ccc2","aaa3_bbb2_ccc1")) x library(stringr) out<-as.data.frame(str_split_fixed(x$x,"aaa",2)) out2<-as.data.frame(str_split_fixed(out$V2,"_bbb",2))
2013 Feb 28
11
new question
...#6???????? aAAAAAGAGPEMVR 1-n_acPro/ 2? 0? 0? 2 resCounts<- f(lista,FacGroup) t.test.p.value <- function(...) { ??? obj<-try(t.test(...), silent=TRUE) ??? if (is(obj, "try-error")) return(NA) else return(obj$p.value) ?} #3rd function for p-value fpv<- function(Countdata){ resNew<-do.call(cbind,lapply(split(names(Countdata)[4:ncol(Countdata)],gsub("[0-9]","",names(Countdata)[4:ncol(Countdata)])), function(i) {x<-if(ncol(Countdata[i])>1) rowSums(Countdata[i]) else Countdata[i]; colnames(x)<-NULL;x})) indx<-combn(names(resNew),2) resPval&lt...
2015 Mar 21
2
Familia *pply
...da en un bucle. > > #------------------------- > t1 <- Sys.time() > > *myfun <- function(x,y) { data[x,y] }* > > medias <- replicate(1000,{ > sel <- sample(1:20,10) > pareja <- sample(sel,100,replace = T) > ta <- Sys.time() > *#cambio > resnew <- mapply(myfun, pareja, col) > #cambio * > tb <- Sys.time() > media <- mean(resnew) > tt <- tb-ta > c(media,tt) > }) > > t2 <- Sys.time() > > diftime=(t2-t1)[[1]] > diftime > > sum(medias[2,])/diftime > > #-----------------------...
2015 Mar 19
2
Familia *pply
Hola Jorge, muchas gracias por tu pronta respuesta, no me di cuenta que el formateo podría causar problemas, envío de nuevo el código sin formatos. La idea básica es para un set de números de columnas (desordenados) y un set de numeros de fila el loop lo que hace es ir a la fila y columna correspondiente de data, tomar el valor y luego hacer la media sobre esos.
2013 Feb 15
2
data formatting
Dear Eliza, Try this: Lines1<-readLines(textConnection("1911.01.01?????? 7.87 1911.01.02?????? 9.26 1911.01.03?????? 8.06 1911.01.04?????? 8.13 1911.01.05????? 12.90 1911.02.06?????? 5.45 1911.02.07?????? 3.26 1911.03.08?????? 5.70 1911.03.09?????? 9.24 1911.04.10?????? 7.60 1911.05.11????? 14.82 1911.05.12????? 14.10 1911.06.13?????? 7.87 1911.06.14?????? 9.26
2012 Nov 27
3
loop command to matrix
Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and 365 columns. what i want to do is the following...First i want to leave out column number 1 and want to calculate the row wise mean of the remaining columns, which will obviously give me 365 values in one column, and then subtracting these values from the column i left out i.e. col=1 then i want to leave out column 2
2013 Feb 27
2
matrix multiplication
Hi, Try this: #mat1 is the data res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1}))
2012 Dec 25
5
aggregate / collapse big data frame efficiently
Hi, I need to aggregate rows of a data.frame by computing the mean for rows with the same factor-level on one factor-variable; here is the sample code: x <- data.frame(rep(letters,2), rnorm(52), rnorm(52), rnorm(52)) aggregate(x, list(x[,1]), mean) Now my problem is, that the actual data-set is much bigger (120 rows and approximately 100.000 columns) ? and it takes very very long
2013 Sep 02
3
Product of certain rows in a matrix
Hi, You could try: A<- matrix(unlist(read.table(text=" 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 ",sep="",header=FALSE)),ncol=3,byrow=FALSE,dimnames=NULL) library(matrixStats) ?res1<-t(sapply(split(as.data.frame(A),as.numeric(gl(nrow(A),2,6))),colProds)) ?res1 #? [,1] [,2] [,3] #1??? 4?? 10?? 18 #2?? 63?? 64?? 63 #3?? 18?? 10??? 4
2013 Feb 15
10
reading data
Hi, #working directory data1 #changed name data to data1.? Added some files in each of sub directories a1, a2, etc. ?indx1<- indx[indx!=""] lapply(indx1,function(x) list.files(x)) #[[1]] #[1] "a1.txt"??????? "mmmmm11kk.txt" #[[2]] #[1] "a2.txt"??????? "mmmmm11kk.txt" #[[3]] #[1] "a3.txt"??????? "mmmmm11kk.txt" #[[4]] #[1]