Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-09 Thread PIKAL Petr
elp [mailto:r-help-boun...@r-project.org] On Behalf Of Curtis > Burkhalter > Sent: Friday, March 06, 2015 10:01 PM > To: Tom Wright > Cc: r-help@r-project.org > Subject: Re: [R] problem with function that adds rows to dataframe > based on conditional statement > > Hey Tom,

Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-06 Thread Curtis Burkhalter
Hey Tom, This solution works great, but if I try to then insert it in my function that I've displayed above and apply it to my split dataframe I get the error message: Error in `[.default`(xj, i) : invalid subscript type 'list' The reason why I need to try and get this to work within the functio

Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-06 Thread Tom Wright
If all you want is to add a row of na's could you just do something like: nExpectedRows<-length(unique(animals)) * length(unique(animalYears)) * 2 newDf<-data.frame(animals=rep(NA,nExpectedRows-nrow(comAn)), animalYears=rep(NA,nExpectedRows-nrow(comAn)), animal

Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-06 Thread Curtis Burkhalter
Petr, The reason I need to do this is that I'm going to be using some large datasets in WinBUGS, but there is some missing data for the files I'm using. In order to make the data files readable in WinBUGS there have to be NAs in place of missing data so I'm trying to add in NAs where there are mis

Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-06 Thread PIKAL Petr
Hi May I ask you why do you need such operation. I cannot imagine a situation where I would need to do this. The only imaginable procedure is to merge NA enhanced object with another object but for that situation usually ?merge is used Cheers Petr > -Original Message- > From: R-help

Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-05 Thread Sarah Goslee
Why should he? seq_len() is part of base R. On Thursday, March 5, 2015, JS Huang wrote: > Hi Curtis, > > Maybe you forgot to tell us how the function seq_len is defined. > > > > - > JS Huang > -- > View this message in context: > http://r.789695.n4.nabble.com/problem-with-function-that-add

Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-05 Thread JS Huang
Hi Curtis, Maybe you forgot to tell us how the function seq_len is defined. - JS Huang -- View this message in context: http://r.789695.n4.nabble.com/problem-with-function-that-adds-rows-to-dataframe-based-on-conditional-statement-tp4704228p4704237.html Sent from the R help mailing list

Re: [R] problem with function "polygon"

2014-11-07 Thread Eric Elguero
On 11/07/2014 04:35 PM, Duncan Murdoch wrote: You are not using the polygon() function from the graphics package, you're using one coming from somewhere else (maybe an old version of R, or some package). The polygon() function in the graphics package doesn't call .Internal(polygon(..., it calls

Re: [R] problem with function "polygon"

2014-11-07 Thread Duncan Murdoch
On 07/11/2014 10:05 AM, Eric Elguero wrote: Hi all, I'm trying to use the polygon function from the graphics package, and get this error message : > polygon(x=c(1,2,3,1),y=c(1,4,5,1)) Error in .Internal(polygon(xy$x, xy$y, col, border, lty, ...)) : there is no .Internal function 'polygon'

Re: [R] problem with function "qdagum"

2012-11-09 Thread Uwe Ligges
This is a bug in the unmentioned VGAM package and you have to report it to its maintainer (hence CCing Thomas Yee). Uwe Ligges On 09.11.2012 10:08, Alena888 wrote: I would like to ude the function "qdagum", to compite quantiles of dagum distribution, but if I use the form: >qdagum(0.1, 4, 7

Re: [R] problem with function

2012-07-18 Thread Rui Barradas
Hello, I believe that the answer to your final question is yes but you are making a really big confusion of what you want, of how you are explaining it and of the way R works. First, I have written a function to read the data from the post, without creating a disk file. In order to be comple

Re: [R] Problem with function

2012-05-21 Thread David Winsemius
On May 21, 2012, at 5:13 PM, acnunn wrote: Hi, I'm new to R, so apologies in advance for the triviality of this question, but I was wondering if anyone could tell me why this function doesn't return the expected output, i.e. a matrix containing two columns from a large data frame called

Re: [R] Problem with function

2012-05-21 Thread Rui Barradas
Hello, There's nothing wrong with having 'thisCol' and 'thatCol' already defined or not. The problem is that your function does NOT return a value. Get rid of the assignment and it will work. CompFunct <- function(thisCol, thatCol) {cbind(finalTable[, thisCol], finalTable[, thatCol])} I would

Re: [R] problem with function "Truncate" in package "distr"

2011-09-23 Thread Peter Ruckdeschel
Am 21.09.2011 17:05, schrieb Uwe Ligges: > > > On 21.09.2011 11:53, Duarte Viana wrote: >> Hello all, >> >> Can someone tell me why the following mixture of two log-normal >> distributions does not get truncated? What puzzles me is that the >> function works almost always, but for certain combina

Re: [R] problem with function "Truncate" in package "distr"

2011-09-21 Thread Uwe Ligges
On 21.09.2011 11:53, Duarte Viana wrote: Hello all, Can someone tell me why the following mixture of two log-normal distributions does not get truncated? What puzzles me is that the function works almost always, but for certain combinations (like the one below), it does not. # R code example

Re: [R] problem with function "rep"

2008-06-12 Thread Charilaos Skiadas
I believe this might do what you want a bit faster. I replaced the while loop with something that is likely to be faster. I saw no reason for the rounding you were doing, better to use as.integer at the end. test <- function(t){ x <- rexp(t,0.1) while(sum(x) <= t) { x <- c(x, rexp(

Re: [R] problem with function "rep"

2008-06-12 Thread Julien Hunt
Hi I believe this should provide an example of the confusing behavior. Run this with t=100 for example: test=function(t){ x=c() while(sum(x)<=t){ ###I simply generate some numbers from an exponential until the sum of these numbers gets to 100(without loss of generality) x=c(x,round(rexp(1,0.1)

Re: [R] problem with function "rep"

2008-06-12 Thread Erik Iverson
Berwin appears to be correct here. After you do x <- x / 0.0001, I inserted a call to round(x) - x, and received round(x) - x [1] 7.275958e-12 0.00e+00 0.00e+00 This is basically a case of FAQ 7.31. Julien Hunt wrote: Hi I believe this should provide an example of the confusing behav

Re: [R] problem with function "rep"

2008-06-12 Thread Marc Schwartz
on 06/12/2008 09:48 AM Julien Hunt wrote: To whom it may concern, I am currently writing a program where I need to use function rep. The results I get are quite confusing. Given two vectors A and B, I want to replicate a[1] b[1] times, a[2] b[2] times and so on. All the entries of vector B ar

Re: [R] problem with function "rep"

2008-06-12 Thread Berwin A Turlach
G'day Julien, On Thu, 12 Jun 2008 16:48:43 +0200 Julien Hunt <[EMAIL PROTECTED]> wrote: > I am currently writing a program where I need to use function rep. > The results I get are quite confusing. Given two > vectors A and B, I want to replicate a[1] b[1] > times, a[2] b[2] times and so on. >

Re: [R] problem with function "rep"

2008-06-12 Thread Erik Iverson
We need a reproducible example of this to tell you what is going on. Find a small example that exhibits the confusing behavior, and share it with the list. Julien Hunt wrote: To whom it may concern, I am currently writing a program where I need to use function rep. The results I get are quite

Re: [R] problem with function "rep"

2008-06-12 Thread Charilaos Skiadas
On Jun 12, 2008, at 10:48 AM, Julien Hunt wrote: Do you need more information on my specific program. Thanks for your time and help, Yes, as the posting guide says, we would probably need a reproducible self-contained example. Emphasis on "reproducible" and "self-contained. Best regards,