search for: newrow

Displaying 20 results from an estimated 25 matches for "newrow".

2010 May 14
2
Subscripting a matrix-like object
...if(missing(j)) x[] <- value else x[,j] <- value } else { i <- i[!is.na(i)] if(is.numeric(i)){ if(!is.ti(i) && couldBeTi(i, tif = tif)) i <- asTi(i) if(is.ti(i)){ i <- i + 1 - xStart if(any(i < 1)){ newRows <- 1 - min(i) xStart <- xStart - newRows if(is.null(m <- ncol(x))) m <- 1 i <- i + newRows if(is.matrix(x)) x <- rbind(matrix(NA, newRows, m), x) else x <- c(rep(NA, newRows), x) } } }...
2010 May 14
2
Subscripting a matrix-like object
...if(missing(j)) x[] <- value else x[,j] <- value } else { i <- i[!is.na(i)] if(is.numeric(i)){ if(!is.ti(i) && couldBeTi(i, tif = tif)) i <- asTi(i) if(is.ti(i)){ i <- i + 1 - xStart if(any(i < 1)){ newRows <- 1 - min(i) xStart <- xStart - newRows if(is.null(m <- ncol(x))) m <- 1 i <- i + newRows if(is.matrix(x)) x <- rbind(matrix(NA, newRows, m), x) else x <- c(rep(NA, newRows), x) } } }...
2010 Mar 18
2
Pedigree / Identifying Immediate Family of Index Animal
...Code to calculate generations forward and backward: #queryIds holds the unique Ids for parents of the index animals queryIds = unique(c(ped$Sire, ped$Dam)); for(i in 1:gens){ if (length(queryIds) == 0){break}; #allPed is the dataframe with Id,Dam,Sire and Sex for animals in our colony newRows <- subset(allPed, Id %in% queryIds); queryIds = c(newRows$Sire, newRows$Dam); ped <- unique(rbind(newRows,ped)); } #build forwards #when calculating children, queryIds holds the Ids of the previous generation queryIds = unique(ped$Id); for(i in 1:gens){ if (length(queryIds)==0)...
2011 Nov 24
3
Is there way to add a new row to a data frame in a specific location
Is there easy way (without copying the existing rows to a temporary location and copying back) to add a new row to a specific index location in an existing data frame? Example df = data.frame( A= c('a','b','c'), B=c(1,2,3), C=(10,20,30)) newrow = c('X', 100, 200) I want to add the newrow as the second row to the data frame df Please suggest a solution that is efficient for a data frame that can have millions of rows, and I want to add a new row in any given index location of the data frame. Thanks, Sammy [[alternative HTML ve...
2008 Oct 15
2
R: "in-place" appending to a matrix.
Hello fellow R sufferers, Is there a way to perform an appending operation in place? Currently, the way my pseudo-code goes is like this for (i in 1:1000) { if (some condition) { newRow <- myFunction(myArguments) X <- rbind(X, newRow) # <- this is the bottleneck!! } } As you can see, it works but as the matrix X gets the size of a few million rows, the code runs very slow. I am looking for something like the natively "in place" appending pytho...
2011 Nov 23
1
Losing custom attributes
...te #### attr(mydata,"myattr")<-c("myinfo") ### creating col level attribute for 'age' column ### attr(mydata$age,"mycolattr")<-c("mycolinfo") #### Checking attributes ### attributes(mydata) attributes(mydata$age) ### creating new row ##### newrow <- data.frame(age=16, weight= 42) #### Inserting newrow as first row to my data frame #### mydata<- rbind(newrow, mydata) #### Checking attributes again ### I lost my custom attributes attributes(mydata$age) attributes(mydata) Thanks in advance, -- SG [[alternative HTML version dele...
2017 Aug 23
0
splitting a dataframe in R based on multiple gene names in a specific column
...132601999 A G exonic BCDF5,CDFG6", header=TRUE,stringsAsFactors=FALSE) multgenes<-grep(",",df.sample.gene$Gene.refGene) rep_genes<-strsplit(df.sample.gene$Gene.refGene[multgenes],",") ngenes<-unlist(lapply(rep_genes,length)) dup_row<-function(x) { newrows<-x lastcol<-dim(x)[2] rep_genes<-unlist(strsplit(x[,lastcol],",")) for(i in 2:length(rep_genes)) newrows<-rbind(newrows,x) newrows$Gene.refGene<-rep_genes return(newrows) } for(multgene in multgenes) df.sample.gene<-rbind(df.sample.gene,dup_row(df.sample.gene[mult...
2004 Jul 29
3
Editing Strings in R
I was wondering if there is a way of editting strings in R. I have a set of strings and each set is a row of numbers and paranthesis. For example the first row is: (0 2)(3 4)(7 9)(5 9)(1 5) and I have a thousand or so such rows. I was wondering how I could get the corresponding string obtained by adding 1 to all the numbers in the string above. Dursun [[alternative HTML version deleted]]
2017 Aug 22
2
splitting a dataframe in R based on multiple gene names in a specific column
I would appreciate please a suggestion on how to do the following : i'm working with a dataframe in R that contains in a specific column multiple gene names, eg : > df.sample.gene[15:20,2:8] Chr Start End Ref Alt Func.refGene Gene.refGene284 chr2 16080996 16080996 C T ncRNA_exonic GACAT3448 chr2 113979920 113979920 C T ncRNA_exonic LINC01191,LOC100499194465
2006 May 12
7
RJS and page.select collection size
I need to implement a conditional in my RJS template which looks something like: if (page.select(''row1'').first != null) page << "new TableRow.MoveAfter(''row1'', ''newrow'');" else page << "new TableRow.MoveAfter(''row2'', ''newrow'');" end Now, dumb question.. My ''if'' doesnt work, how should I properly check if the returned collection found row1 or not? (Note: row1 is unique)...
2011 Apr 28
1
Trying to perform an inner loop a random number of times
...c(1:6)) { + i<-1 + while (i <= 5) { + rn<-0 + rn<-round(runif(1, 1, 5)) + if (i > rn) { break } + + else { + iter[i]<-i + newrow<-data.frame(sp, iter, rn) + i<-( i + 1) + } + } + ds<-rbind(ds, newrow) + } > print(ds) sp iter rn 1 1 1 3 >> sp #1 should appear 3x, not 2x 2 1 2 3 3 2...
2017 Aug 25
1
splitting a dataframe in R based on multiple gene names in a specific column
...BCDF5,CDFG6", > header=TRUE,stringsAsFactors=FALSE) > > multgenes<-grep(",",df.sample.gene$Gene.refGene) > rep_genes<-strsplit(df.sample.gene$Gene.refGene[multgenes],",") > ngenes<-unlist(lapply(rep_genes,length)) > dup_row<-function(x) { > newrows<-x > lastcol<-dim(x)[2] > rep_genes<-unlist(strsplit(x[,lastcol],",")) > for(i in 2:length(rep_genes)) newrows<-rbind(newrows,x) > newrows$Gene.refGene<-rep_genes > return(newrows) > } > for(multgene in multgenes) > df.sample.gene<-rbind(df.sampl...
2011 Nov 23
2
SPSS F-test on change in R square between hierarchical models
...quot;myinfo") > > ### creating col level attribute for 'age' column ### > attr(mydata$age,"mycolattr")<-c("mycolinfo") > > #### Checking attributes ### > attributes(mydata) > attributes(mydata$age) > > ### creating new row ##### > newrow <- data.frame(age=16, weight= 42) > > #### Inserting newrow as first row to my data frame #### > mydata<- rbind(newrow, mydata) > > #### Checking attributes again ### I lost my custom attributes > attributes(mydata$age) > attributes(mydata) > > > Thanks in advan...
2011 Oct 29
1
Add col in data.frame
...ary(foreign) mydf<-read.spss(file="C:/myspss.sav",use.value.labels=FALSE, to.data.frame=TRUE,use.missings=FALSE) attr(mydf,"variable.labels") ## it gives you all the labels ##Adding a new variable(col) to mydf newcolm <- list(frt="grapes") mydf <- cbind(mydf, newrow) ##Now checking to see labels again attr(mydf,"variable.labels") ## And you get NULL Can anyone please help me to achieve this without loosing any default attribute that was there? Thanks and Regards -- SmartG [[alternative HTML version deleted]]
2007 May 15
1
Effect.dropout and Too Much Recursion Error
...wStaffForm''); var staffName = $F(''formName''); form.request(); form.request({ onLoading: notice.update("saving data .. ..."), onComplete: function(transport){ notice.update("Form data saved..."); var newID = transport.responseText; newRow = Builder.node(''tr''); td1 = Builder.node(''td'',staffName); td2 = Builder.node(''td'', [Builder.node(''a'', {href: ''#'',onclick:"deleteUser(''"+newID+"'')"}, ''delete'...
2010 Aug 13
1
loop for inserting rows in a matrix
...following for the total number of transects that there are (1 to 9) NewDat <-subset(AerialSurveysm, AerialSurveysm[,1]== m[i]) #select date to work on beginning with 1st indx<-which(AerialSurveysm[,1]==m[i]) indx<-indx[[1]] Check<-which(NewDat[,2]==k) NewRow<-c(c(m[i]),k,0) if(is.empty(Check)==TRUE)#if the selected date does not have a transect equal to transect k AerialSurveysm<-insertRow(AerialSurveysm,indx,NewRow) #add a row to AerialSurveys.m in the location of the correct date } i=i+1 } Thanks for any hints or thoughts...
2010 Feb 06
1
duplicating records
Dear friends, I need to fill in (duplicate the whole record) the missing days with the same record values as long as AE is the same value (i.e. "1"), once AE value changes, the process of duplication should proceed with the new AE value till it changes again. e.g. I need to fill in records: day 18-day 44, all the records are carried with the new AE value of "0". At the
2011 Apr 25
1
Trouble Passing a for loop variable (iteration #) to a data frame
...} + spStep<-paste("sp Value is ", sp) + print(spStep) + iterStep<-paste("iter Value is ", iter) + print(iterStep) + + newrow<-data.frame(sp, iter, ti, to, actdur) + ct=ct+1 + } #END INNER LOOP + ds<-rbind(ds, newrow) + } [1] "sp Value is 1" [1] "iter Value is 1" [1] "sp Value is 1" [1] "iter Value is...
2011 Nov 12
1
With an example - Re: rbind.data.frame drops attributes for factor variables
...quot; $class [1] "factor" $newattr1 [1] "custom-attr1" $newattr2 [1] "custom-attr2" However as soon as I add a row to this data frame ("dataset") by rbind(), it loses the custom attributes ("newattr1" and "newattr2") I have just added newrow = c(gender="Female", count = 5, answer = "great") dataset <- rbind(dataset, newrow) > attributes(dataset$answer) $levels [1] "bad" "good" "great" $class [1] "factor" the two custom attributes are dropped!! Any suggestion why t...
2001 Dec 19
2
How to create a data.frame "like" another, but longer?
Hello, does anyone know of a quick way to create a data frame "like" another, but with more rows? What I'd like to do is this: if mydata is a data.frame like a b c 1 TRUE yes 2 FALSE no 3 TRUE yes I'd like to get mydata2 with the same column names and column types, but without the values and with more rows. All I could think of was to manually do