search for: res1

Displaying 20 results from an estimated 99 matches for "res1".

Did you mean: res
2004 Jun 01
1
swapping with data.frame
Hi there, I have some data which are convenient to enter as lists. For example: t1<-list(fname="animal1",testname="hyla",dspkr="left",res1=39.7,res2=15.0) t2<-list(fname="animal1",testname="bufo",dspkr="left",res1=14.4,res2=56.1) t3<-list(fname="animal2",testname="hyla",dspkr="right",res1=22.6,res2=11.8) I would like to generate a dataframe, but *not* the way this appr...
2013 Nov 21
1
how can I import a number of datsets in a folder in my working directory to a list in R
...86,ncol=2); write.table(m1,paste0("file_",i,".txt"),row.names=FALSE,quote=FALSE)}) ?D <-dir() D1 <- D[order(as.numeric(gsub("\\D+","",D)))] D1 ?res <- t(sapply(D1,function(x) {x1<- read.table(x,header=TRUE); x1[,2]})) dim(res) #[1]?? 15 1686 #or res1 <- do.call(rbind,lapply(D1,function(x) {x1<- read.table(x,header=TRUE); x1[,2]})) ?dim(res1) #[1]?? 15 1686 ?dimnames(res) <- dimnames(res1) ?identical(res,res1) #[1] TRUE A.K. I have a folder containing 15 text files in my working directory. ?I want to use the dir() function D<-di...
2013 May 22
0
calcul of the mean in a period of time
...se y; data.frame(patient_id=unique(y1$patient_id),t=head(y1$t,1),scores=mean(y1$scores,na.rm=TRUE))}) ) }) lst1[lapply(lst1,length)==0]<-lapply(lst1[lapply(lst1,length)==0],function(x) x<- dat2[unlist(with(dat2,tapply(t,patient_id,FUN=function(x) x==0 & length(x)==1)),use.names=FALSE),]) res1<-do.call(rbind,lst1) ?row.names(res1)<- 1:nrow(res1) ?res2<- res1[,-2] res2$period<-with(res2,ave(patient_id,patient_id,FUN=seq_along)) ?res2 # patient_id scores period #1????????? 1?? 2.05????? 1 #2????????? 2?? 2.40????? 1 #3????????? 2?? 2.05????? 2 #4????????? 3?? 1.20????? 1 #5????...
2013 May 07
4
how to calculate the mean in a period of time?
...????????????? 2???????????????? 2.5 2????????????????????? 4????????????????? 2.6 2?????????????????????? 5???????????????? 1.5 ",sep="",header=TRUE) library(plyr) ?dat2New<-ddply(dat2,.(patient_id),summarize,t=seq(min(t),max(t))) ?res<-join(dat2New,dat2,type="full") res1<-do.call(rbind,lapply(split(res,res$patient_id),function(x) {x1<-x[x$t!=0,];do.call(rbind,lapply(split(x1,((x1$t-1)%/%3)+1),function(y) {y1<-if(any(y$t==1)) rbind(x[x$t==0,],y) else y; data.frame(patient_id=unique(y1$patient_id),scores=mean(y1$scores,na.rm=TRUE))}) ) })) ?row.names(res...
2013 Apr 29
1
how to add new rows in a dataframe?
...??????? 3.6 2???????????????? 4??????????????????????? 5.6 2???????????????? 6??????????????????????? 7.8 3???????????????? 0??????????????????????? 1.6 3???????????????? 1???????????????????????? 1.2 3???????????????? 4???????????????????????? 1.5 ",sep="",header=TRUE) library(zoo) res1<-do.call(rbind,lapply(split(dat1,dat1$id),function(x) {t1<-seq(min(x$t),max(x$t));scores1<-na.locf(x$scores[match(t1,x$t)]);data.frame(id=rep(unique(x$id),length(t1)),t1,scores1)})) ?row.names(res1)<- 1:nrow(res1) ?res1 #?? id t1 scores1 #1?? 2? 0???? 1.2 #2?? 2? 1???? 1.2 #3?? 2? 2???...
2000 Jul 05
1
Tukey.aov with split-plot designs
...ionnaires" data <- c(30,14,24,38,26,28,18,20,34,28,16,10,18,20,14,34,22,30,44,30) Stv.df <- data.frame(rt=data,subj=factor(rep(paste("subj",1:5,sep=""),4)),drug=factor( rep(paste("drug",1:4,sep=""),c(5,5,5,5)))) res0 <- aov(rt~drug,data=Stv.df) res1 <- aov(rt~drug+subj,data=Stv.df) res2 <- aov(rt~drug+Error(subj/drug),data=Stv.df) res0$resid works resid(res0) works res0$df.residual works res1$resid works resid(res1) works res1$df.residual work res2$resid doesn't work and reports NULL resid(res2) doesn't work and reports NU...
2006 Feb 27
1
Different deviance residuals in a (similar?!?) glm example
...6, 3) # just as example deaths.sim <- rpois(length(age), exposures*hazard.sim) # simulating deaths from a poisson distribution (Brillinger, 1986) my.offset <- log(exposures) # offset for the poisson regression # new dataset: decupleing the sample size deaths.sim1 <- deaths.sim * 10 exposures1 <- exposures * 10 my.offset1 <- log(exposures1) # fitting the first dataset fit <- glm(formula = deaths.sim ~ age + offset(my.offset), family = poisson(link = "log")) res <- residuals(fit, type="deviance") # fitting the new dataset fit1 <- glm(fo...
2012 Nov 06
1
pivot table
Hello, I have a data which looks like below: Some of the patients have multiple diagnosis. ID(200 patients)   Diag (100 unique Diag-200 in general)   Proc (50 uniqe Proc)  DOB (200)   Gender (200)    a                           daig1 b                           diag2 c                            diag1 I want to reformat this data to : ID   diag1 diag 2 diag 3..  diagx   proc1   proc2  
2013 Sep 25
1
Computing calculation among two vectors
Hi, Try: x<- 1:4 ?y<- c("*","/","-","+") res<-sapply(y,function(i) {x1<-expand.grid(x,x); unlist(lapply(paste0(x1[,1],i,x1[,2]),function(u) eval(parse(text=u))))}) row.names(res)<- as.character(interaction(expand.grid(x,x),sep="_")) head(res) #??? *?? /? - + #1_1 1 1.0? 0 2 #2_1 2 2.0? 1 3 #3_1 3 3.0? 2 4 #4_1 4 4.0? 3 5
2013 Aug 26
4
transform variables
Dear all! I have a data frame composed by 13 columns (year, and 12 months). I want to transform this data base in another like this year month values 1901 1 1901 2 1901 3 ..... 1901 12 1902 1 1902 2 .... 1902 12 Is there a possibility to succeed that in R? Thank you! best regards! CR -- --- Catalin-Constantin ROIBU Lecturer PhD, Forestry engineer Forestry Faculty of Suceava Str.
2010 Jul 20
1
p-values pvclust maximum distance measure
...-values above 95%. I wrote an example programme which demonstrates this effect. I uploaded a PDF showing the results Here is the code which produces the PDF file: ------------------------------------------------------------------------------------- s <- matrix(runif(1600,0,1000), nrow=20) a.res1 <- pvclust(t(s), method.hclust="complete", method.dist="euclidian", nboot=500) a.res2 <- pvclust(t(s), method.hclust="complete", method.dist="maximum", nboot=500) a.res3 <- pvclust(t(s), method.hclust="complete", method.dist="canberra&...
2005 Jul 13
1
problems with MNP
...s("small.sav") Warning message: small.sav: Unrecognized record type 7, subtype 13 encountered in system file. > library(MNP) MNP: R Package for Fitting the Multinomial Probit Models Version: 1.3-1 URL: http://www.princeton.edu/~kimai/research/MNP.html > > res1 <- mnp(PREVOTE3 ~ 1, choiceX = list(1=UCLC, 2=UDLC, 3=UPLC), Error: syntax error > cXnames = "ut", data = small, n.draws = 500, burnin = 100, Error: syntax error > verbose = TRUE) Error: syntax error > > # another try giving arbitrary names...
2013 Feb 01
29
cumulative sum by group and under some criteria
...ut data length > 0 On Thu, Jan 31, 2013 at 12:21 PM, arun kirshna [via R] < ml-node+s789695n4657196h87@n4.nabble.com> wrote: > Hi, > Try this: > colnames(d)<-c("m1","n1","x1","y1","p11","p12") > library(zoo) > res1<- do.call(rbind,lapply(lapply(split(d,list(d$m1,d$n1)),function(x) > {x$cp11[x$x1>1]<- cumsum(x$p11[x$x1>1]);x$cp12[x$y1>1]<- > cumsum(x$p12[x$y1>1]);x}),function(x) > {x$cp11<-na.locf(x$cp11,na.rm=F);x$cp12<- na.locf(x$cp12,na.rm=F);x})) > #there would be a w...
2013 Jun 10
4
Combining CSV data
Hello R community, I am trying to combine two CSV files that look like this: File A Row_ID_CR, Data1, Data2, Data3 1, aa, bb, cc 2, dd, ee, ff File B Row_ID_N, Src_Row_ID, DataN1 1a, 1, This is comment 1 2a, 1, This is comment 2 3a,
2007 Aug 15
3
Formula in lm inside lapply
...or message when I tried to do that. Here is my sample code: #generating data x1 <- rnorm(100,1) x2 <- rnorm(100,1) y <- rnorm(100,1) group <- rep(c("A","B"),c(40,60)) group <- factor(group) df <- data.frame(y,x1,x2,group) #write formula inside lm--works fine res1 <- lapply(levels(df$group), function(x) lm(y~x1,df, subset = group ==x)) res1 res2 <- lapply(levels(df$group),function(x) lm(y~x1+x2,df, subset = group ==x)) res2 #try to pass formula into lm()--does not work formula1 <- as.formula(y~x1) formula2 <- as.formula(y~x1+x2) resf1 <- lapp...
2013 Dec 15
1
Rows to Column
Hi all, I'm kinda new in R programming and I need some help preparing a database to run logistic regression. I have data in a tuple form: *id cat val* 1 A 2 1 C 4 3 B 1 5 A 2 6 A 3 6 B 5 6 C 2 8 B 5 8 D 2 9 D 3 and would like to have it like: *id catA catB catC catD* 1 2 0 4 0 3 0 1 0 0 5 2 0 0 0 6 3
2012 Feb 02
9
sqldf for Very Large Tab Delimited Files
...;irisNoH.txt") attr(f1, "file.format") <- list(header=FALSE,sep="\t") # read into table called irisTab in the mytestdb sqlite database read.csv.sql("irisNoH.txt", sql = "create table main.irisTab1 as select * from file", dbname = "mytestdb") res1<-sqldf("select * from main.irisTab1 limit 10", dbname = "mytestdb") write.table(res1, "iris10.txt", sep = "\t", quote = FALSE, col.names=FALSE,row.names = FALSE) # For querying records of a particular species - unresolved problems #a1<-"virginica&...
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 ?res2<-t(sapply(split(as.data.frame(A),((seq_len(nrow(A))-1)%/%2)+1),colProds)) ?identical(res1,res2) #[1] TRUE #or ?t(sapply(split(as...
2013 Nov 05
0
Sampling question
...","",names(lst1[[i]][1]))))] ??? ??? ??? ?cbind(lst1[[i]][1], sample(x1,3)) ??? ??? ??? ??? ??? ??? ??? } ??? ??? ??? ??? ) ?do.call(rbind,lapply(lst1,function(x) {datNew <- cbind(SubID= as.numeric(row.names(x)), x); names(datNew)[-1] <- "var"; datNew})) }) res } ?res1 <- fun1(dat1,5) lst2 <- lapply(split(res1,col(res1)), function(x) {dat <- do.call(cbind,x); colnames(dat) <- c("SubID", rep("var",4));dat}) do.call(cbind,res1[,1]) do.call(cbind,res1[,2]) A.K. I have a question about drawing samples from a data frame. This might...
2013 Oct 17
1
Reshape
Hello, I have data frame like the one created below, ##input data Person <- c(1,1,1,1,1,1,2,2) Amount <- c(100,10,100,10,100,10,50,150) Date <- c("12/01/2012", "12/01/2012",