search for: dat2

Displaying 20 results from an estimated 376 matches for "dat2".

Did you mean: dat
2012 Aug 07
0
predicting test dataset response from training dataset with randomForest
...e=rep(1, 2), + pch=as.numeric(dat1$SR)) > > > path3 <- "C:\\Users..." > path4 <- "..." > name2 <- "..." > > # reading in the test dataset > actualFileName2 <- paste(path3, path4, name2, ".txt", sep="") > > dat2 <- read.table(actualFileName2, header=TRUE, sep="\t", > colClasses="character") > > > dat2$X13 <- as.factor(dat2$X13) > dat2$X52 <- as.factor(dat2$X52) > dat2$X53 <- as.factor(dat2$X53) > dat2$X64 <- as.factor(dat2$X64) > dat2$X85 <-...
2011 May 19
3
A better way to do this
...39;, each of these groups contains longitudinal data for 100 subjects. I have to plot all these subjects on a single chart and then put a regression line for each of the group for all the subjects. I have written a function to do the chart grpcharts<-function (dat, group,group2,molecule,cutoff){ dat2<-dat[grep(group,dat$Group),] ylim=log2(c(min(dat2[,molecule],na.rm=T)+4,max(dat2[,molecule],na.rm=T)+1)) all.sub.id<-dat2$Subject.ID if (group=='control'){ col=c('blue') }else{col=c('red')} if(group2=='case'){ col2=c('red') }else{ col2=c('blue&...
2012 Nov 01
2
Name assignment in for loop
...to each model created, using the loop index. The loop gets stuck at the name of the model, giving the error "target of assignment expands to non-language object". The linear model runs without error; only the name is problematic. Here is the current loop syntax. The use of dat and dat2 is not an error. I'm pulling data from 2 sources for the model. for (i in 1:dim(dat2)[[1]]) { assign("modelb",i) <- lm(log(dat$flux) ~ dat$Tsoil_flux, subset = dat$chamber == dat2$chamber[i] & dat$year == dat2$year[i] & dat$doy >= dat2$day1[i] & dat$doy <= dat...
2013 May 07
4
create unique ID for each group
Hey All, I have a dataset(dat1) like this: ObsNumber ID Weight 1 0001 12 2 0001 13 3 0001 14 4 0002 16 5 0002 17 And another dataset(dat2) like this: ID Height 0001 3.2 0001 2.6 0001 3.2 0002 2.2 0002 2.6 I want to merge dat1 and dat2 based on "ID" in order, I know "match" only returns the first match it finds. So I am thinking create uniq...
2008 Mar 25
2
Compare two data sets
I would like to compare two data sets saved as text files (example below) to determine if both sets are identical(or if dat2 is missing information that is included in dat1) and if they are not identical list what information is different between the two sets(ie output "a1", "a3" as the differing information). The overall purpose would be to remove "a1" and "a3" from dat 1 so both...
2010 Mar 22
1
Replacing elements of list
Dear all, I have following two list object, both are basically collection of matrices : dat1 <- matrix(rnorm(25*6), ncol=6) dat1 <- split(dat1, seq(5,25,by=5)) dat1 <- lapply(dat1, matrix, ncol=6) dat2 <- matrix(rnorm(25*4), ncol=4) dat2 <- split(dat2, seq(5,25,by=5)) dat2 <- lapply(dat2, matrix, ncol=4) Now I want to replace last 4 columns of each matrix at "dat1" with the corresponding matrix in "dat2". However I want to avoid the time consuming loop to do that. I...
2013 Sep 02
1
R dataframe and looping help
...y this: dat1<- read.table(text=" CustID TripDate Store Bread Butter Milk Eggs 1 2-Jan-12 a 2 0 2 1 1 6-Jan-12 c 0 3 3 0 1 9-Jan-12 a 3 3 0 0 1 31-Mar-13 a 3 0 0 0 2 31-Aug-12 a 0 3 3 0 2 24-Sep-12 a 3 3 0 0 2 25-Sep-12 b 3 0 0 0 ",sep="",header=TRUE,stringsAsFactors=FALSE) dat2<- dat1[,-c(1:3)] res<- lapply(seq_len(ncol(dat2)),function(i) {x1<-cbind(dat1[,c(1:3)],dat2[,i]);colnames(x1)[4]<- colnames(dat2)[i];x2<-x1[x1[,4]!=0,];within(x2, {daysbetweentrips<-unlist(tapply(as.Date(x2$TripDate,"%d-%b-%y"),list(x2$CustID),function(x) c(NA,as.numeri...
2012 Jun 07
3
conditional statement to replace values in dataframe with NA
Hello and thanks for helping. #some data L3 <- LETTERS[1:3] dat1 <- data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE))) #When x==1 and y==1 I want to replace the 1 values with NA #I can select the rows I want: dat2<-subset(dat1,x==1 & y==1) #replace the 1 with NA dat2$x<-rep(NA,nrow(dat2) dat2$y<-rep(NA,nrow(dat2) #select the other rows and rbind everything back together #This is where I get stuck #The end dataframe will look something like: ? x y ?fac NA NA ? B NA NA ? A 1 2 ? C 1 3 ? C 1 2 ?...
2011 Apr 03
1
zoo:rollapply by multiple grouping factors
...se because the output seems to be a mix of data.frame and lists. out2[1,4] out2[1,5] is.data.frame(out2) is.list(out2) # The situation is made more problematic by the fact that the time point of first survey can differ between plots (e.g., site1-plot3 may only start at time-point 3). As in... dat2<-dat dat2<-dat2[-which(dat2$Plot==3 & dat2$Time<3),] dat2 # I must therefore ensure that I'm keeping track of the true time associated with each value, not just the order of their occurences. This information is (seemingly) lost by both methods. datx<-list(Site=dat2$Site,Plo...
2012 Aug 31
3
fitting lognormal censored data
...e,   cur=curd=cen=cens=array(1,100) Cur=RealCur=realcensoring=realcured=array(1,20) ExpCure=Bias=RealCure=array(1,21) ################################## Z1=c(rbinom(100,1,0.5)) Z2=c(rbinom(100,1,0.5)) dat1<-data.frame(time=rlnorm( 100,2,0.8),Censored=rbinom(100,1,0.9),Cured=rbinom(100,1,.3)) dat2<-dat1[order(dat1[,1]),] # order the data # for (i in 1:10) { dat2$Cured[i+90]=0 #Long term survivors/10 individuals# dat2$Censored[i+90]=0 dat2$time[i+90]=dat2$time[90] } cens<-c(dat2$Censored) #censored status # curd<-c(dat2$Cured) #cured status # tim&...
2012 Oct 04
3
R combining vectors into a data frame but without a continuous common variable
Hello, I have two different files which I'd like to combine to make one data frame but I've no idea how to do it! The first file has two columns; one is the date, the following is a binary code for debris flow events. Then my other file has also two columns; the date and then precipitation data. The thing is, is that the two date columns don't all contain the same dates. The binary
2012 Jul 01
2
list to dataframe conversion-testing for identical
...st using two methods. #Suppose my list is: listdat1<-list(rnorm(10,20),rep(LETTERS[1:2],5),rep(1:5,2)) #Creating dataframe using cbind dat1<-data.frame(do.call("cbind",listdat1)) colnames(dat1)<-c("Var1","Var2","Var3") #Second dataframe conversion dat2<-data.frame(Var1=listdat1[[1]],Var2=listdat1[[2]],Var3=listdat1[[3]]) #Structure is different in two datasets ?>str(dat1) 'data.frame':??? 10 obs. of? 3 variables: ?$ Var1: Factor w/ 10 levels "18.6153321029756",..: 5 2 6 8 7 9 1 4 3 10 ?$ Var2: Factor w/ 2 levels "A&q...
2013 Apr 12
2
split date and time
Hi R experts, For example I have a dataset looks like this: Number TimeStamp Value 1 1/1/2013 0:00 1 2 1/1/2013 0:01 2 3 1/1/2013 0:03 3 How can I split the "TimeStamp" Column into two and return a new table like this: Number Date Time Value 1 1/1/2013 0:00 1 2 1/1/2013 0:01 2 3 1/1/2013 0:03 3 Thank! [[alternative HTML version
2010 Oct 20
2
create a list fails
...ror: object 'stuff21' not found > Why does it have to be found, exist previously ... it is being created? But this works fine .... data <- list(Ntrials =numtritot, Ncomparisons=2, treat=c(rep(1 ,N.trials[1,2]), rep(2,N.trials[1,3])), total.patientnums.trt1=dat2[ ,2], total.patientnums.trt23=dat2[ ,2], num.countstrt1=dat2[ ,5], num.countstrt23=dat2[ ,6] ) .... ???? =============================== Dr. Jim Maas University of East Anglia [[alternative HTML version deleted]]
2017 Dec 14
2
help with recursive function
.... Updated function is pasted below. I am still getting the same error ?Error: !(any(data1$norm_sd >= 1)) is not TRUE? I would appreciate any help. Nilesh dput(calclp) function (dataset) { dat1 <- funlp1(dataset) recursive_funlp <- function(dataset = dat1, func = funlp2) { dat2 <- dataset %>% select(uniqueid, field_rep, lp) %>% mutate(field_rep = paste(field_rep, "lp", sep = ".")) %>% spread(key = field_rep, value = lp) %>% mutate_at(.vars = grep("_", names(.)), funs(norm = round(scale(.), 3)...
2012 Oct 10
7
multiple t-tests across similar variable names
Hi everyone- I have a dataset with multiple "pre" and "post" variables I want to compare. The variables are named "apple_pre" or "pre_banana" with the corresponding post variables named "apple_post" or "post_banana". The variables are in no particular order. apple_pre orange_pre orange_post pre_banana apple_post post_banana person_1
2004 Dec 17
1
reshape and split
Dear R-users, I am trying to reshape the DF "dat2" in the "long" format, but can't figure out how to use the "split"-option: > dat2 a.1995.z b.1995.z a.1996.z var 1 100.00000 100.00000 100.00000 Neue Anlagen insgesamt 2 40.09904 23.60890 40.88960 Neue Ausr??stungen 3 59.90096 76.39...
2011 Nov 17
1
Fisher Exact Test
...the same site, and I have data on the number of times people filled out a form on each version of the site. Sample data: Site 1 Site 2 Filled out form 10 35 Did not fill out form 50 40 dat2 = matrix(c(10,50,35,40), ncol=2) dat2 fisher.test(dat2) > fisher.test(dat2) Fisher's Exact Test for Count Data data: dat2 p-value = 0.0002381 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.09056509 0.54780215 sample estimates: odds ratio 0.2...
2017 Dec 14
0
help with recursive function
...m_sd >= 1)) is > not TRUE? > > > > I would appreciate any help. > > Nilesh > > dput(calclp) > > function (dataset) > > { > > dat1 <- funlp1(dataset) > > recursive_funlp <- function(dataset = dat1, func = funlp2) { > > dat2 <- dataset %>% select(uniqueid, field_rep, lp) %>% > > mutate(field_rep = paste(field_rep, "lp", sep = ".")) %>% > > spread(key = field_rep, value = lp) %>% mutate_at(.vars = > grep("_", > > names(...
2017 Dec 14
3
help with recursive function
If you are trying to understand why the "stopifnot" condition is met you can replace it by something like: if ( any(dat2$norm_sd >= 1) ) browser() This will put you in a debugging session where you can examine your variables, e.g. > dat$norm_sd HTH, Eric On Thu, Dec 14, 2017 at 5:33 PM, Eric Berger <ericjberger at gmail.com> wrote: > The message is coming from your stopifnot() condition being...