similar to: Is there way to add a new row to a data frame in a specific location

Displaying 20 results from an estimated 8000 matches similar to: "Is there way to add a new row to a data frame in a specific location"

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",
2011 Nov 11
1
rbind.data.frame drops attributes for factor variables
Hi all, 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. I see the following post with same problem. However i did not see any reply to the following posting offering a solution. Could someone please help.
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
Hi Bogdan, Messy, and very specific to your problem: df.sample.gene<-read.table( text="Chr Start End Ref Alt Func.refGene Gene.refGene 284 chr2 16080996 16080996 C T ncRNA_exonic GACAT3 448 chr2 113979920 113979920 C T ncRNA_exonic LINC01191,LOC100499194 465 chr2 131279347 131279347 C G ncRNA_exonic LOC440910 525 chr2 223777758 223777758 T A
2017 Aug 25
1
splitting a dataframe in R based on multiple gene names in a specific column
If row numbers can be dispensed with, then tidyr makes this easy with the unnest function: ##### library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(purrr)
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 +
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 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
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
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
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
2003 Feb 04
1
pulling tree : semantics problem
Hi, I'm trying to pull my home from a remote machine. I get a error 'failed to set permissions on home : Not owner' which is obvious: rsync -a remote:/home/foo/bar/zee / this create /home/foo/bar/zee here , but give above error I don't own /,/home but i own /home/foo/bar and lower. If i tell rsync to: rsync -a remote:/home/foo/bar/zee /home/foo/bar it creates
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]]
2007 Jun 10
1
Setup problems, /dev/net/tun FD in bad state
Hi all, I'm following the manual but I get the below error, and I believe tinc is clobbering my conf file. I've never set up VPN before, I'm just trying to connect to my work network from home. All the following is on my work computer. Thanks in advance for any help. $ ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:1A:A0:17:3A:50 inet addr:172.24.104.145
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 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
2009 Nov 11
1
lm and levels
Consider the following example: x <- c(2,4,3,6) y <- c(4,9,5,10) z <- factor(c(1,1,2,2)) summary(lm("y ~ x + z")) The above works fine. Suppose I change z so that x <- c(2,4,3,6) y <- c(4,9,5,10) z <- factor(c(1,1,2,NA)) summary(lm("y ~ x + z")) the last row/observation is not considered in the regression. I would like this to be treated as z with two
2012 Feb 28
1
Alphanumeric DTMF !?
Hi list, What possibilities are there in asterisk to send an *alphanumeric DTMF*from/to asterisk !? Regards, Sammy -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120228/e62e7890/attachment.htm>