search for: newrows

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

Did you mean: 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
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
2011 Nov 23
1
Losing custom attributes
Hi All, I was adding a new row of data to my data frame using rbind(). I was surprised to see that after adding new row, I lost my data frame level attibute as well as col level attribute. Please help me to insert a new row at frist or middle position so that my custom attribute is not lost. Here is what I did. age<-c(15,20,18) weight<-c(40,42,30) ### creating my data frame
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[multg...
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
2011 Apr 28
1
Trying to perform an inner loop a random number of times
Grateful for any hints as to why I'm not getting the inner loop to cycle the expected number of times. Code and one run's results below. Thanks, Galen > # source("looptest.r") > sp<-numeric() > iter<-numeric() > rn<-numeric() > ds<-data.frame(sp, iter, rn) > > for (sp in c(1:6)) { + i<-1 +
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.sample...
2011 Nov 23
2
SPSS F-test on change in R square between hierarchical models
Hi, I am wondering if anyone knows how to perform an F-test on the change in R square between hierarchical models in R? SPSS provides this information and a researcher that I am working with is interested in getting this information. Alternatively, if someone knows how I can calculate the test statistic (SPSS calls it F-change?) and dfs that would be helpful as well. The output and the test I am
2011 Oct 29
1
Add col in data.frame
Hello Gurus, I am still new to R. Here is my issue. I was trying to add column to data frame that was populated by read.spss(). When I used cbind to add a new variable(column). library(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
2007 May 15
1
Effect.dropout and Too Much Recursion Error
Hi, I need some help again. :-) I have "Too much recursion error" prototype.js line 1288, I heve this error when I try to use Effect.dropout (script.aculo.us) if I remove table ID, there is no error, and the effect works fine (remove the tr from table) But I need this ID assign to this table, as table ID is used by other effect (Builder.node) Please help .... Thanks YUAN Here is
2010 Aug 13
1
loop for inserting rows in a matrix
Dear R friends, I have a matrix with 2060 rows and 41 columns. One column is Date, another is Transect, and another is Segment. I want to ensure that there are 9 Transects (1 to 9) for each Date, and 8 Segments (1 to 8) for each Transect in the matrix, by inserting rows where these are missing. I am new to coding, but am trying to write a loop which checks if each of the transects already
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
Greetings - I am working on a piece of code to simulate vehicle times in and out in each of a number of parking spaces. At this stage, my code basically does what it is supposed to do but for the sequential number of each new parking event for a given space (i.e., the index of the loop variable). Instead of passing the index of the loop variable (iter) to the data frame, it passes the value
2011 Nov 12
1
With an example - Re: rbind.data.frame drops attributes for factor variables
When I use rbind() or rbind.data.frame() to add a row to an existing dataframe, it appears that attributes for the column of type "factor" are dropped. See the sample example below to reproduce the problem. Please suggest How I can fix this. Thanks, Sammy a=c("Male", "Male", "Female", "Male") b=c(1,2,3,4) c=c("great", "bad",
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