similar to: bug and enhancement to split?

Displaying 20 results from an estimated 10000 matches similar to: "bug and enhancement to split?"

2011 Nov 03
1
Select columns of a data.frame by name OR index in a function
Dear all, Sometimes I have the situation where a function takes a data.frame and an additional argument describing come columns. For greater flexibility I want to allow for either column names or column indices. What I usually do then is something like the following: -------------8<------------- f <- function(datf, cols) { nc <- seq_along(datf) cn <- colnames(datf) colOK <-
2018 May 11
0
add one variable to a data frame
Sarah's solutions are good, and here's another, even more basic: tmp1 <- unique(dat1$B) tmp2 <- seq_along(tmp1) dat1$C <- tmp2[ match( dat1$B, tmp1) ] > dat1 N B C 1 1 29_log 1 2 2 29_log 1 3 3 29_log 1 4 4 27_cat 2 5 5 27_cat 2 6 6 1_log 3 7 7 1_log 3 8 8 1_log 3 9 9 1_log 3 10 10 1_log 3 11 11 3_cat 4 12 12 3_cat 4 As a single line
2011 Jun 17
3
rle on large data . . . without a for loop!
I think need to do something like this: dat<-data.frame(state=sample(id=rep(1:5,each=200),1:3, 1000, replace=T,prob=c(0.7,0.05,0.25)),V1=runif(1,10,1000),V2=rnorm(1000)) rle.dat<-rle(dat$state) temp<-1 out<-data.frame(id=1:length(rle.dat$length)) for(i in 1:length(rle.dat$length)){ temp2<-temp+rle.dat$length[[i]] out$V1[i]<-mean(dat$V1[temp:temp2])
2013 Apr 25
1
lsfit: Error in formatting error message
Hi, in R-3.0 I get the following error when calling lsfit with more observations than variables, which seems to come from an error in the formatting of the error message (note that this was not happening in 2.15.3): > nobs <- 5; nvar <- 6; lsfit(matrix(runif(nobs*nvar), ncol=nvar), runif(nobs), intercept=FALSE) Error in sprintf(ngettext(nry, "%d response", "%d
2019 May 22
0
print.<strorageMode>() not called when autoprinting
>>>>> William Dunlap >>>>> on Tue, 21 May 2019 12:11:45 -0700 writes: > Letting a user supply the autoprint function would be nice also. In a way > you can already do that, using addTaskCallback(), but that doesn't let you > suppress the standard autoprinting. > Having the default autoprinting do its own style of method dispatch
2008 Aug 19
0
Converting monthly data to quarterly dataMonday, August 18, 2008 11:38 AM
Dear Gavin, This is really great, thank you! I created some long loops to get rid of extra months at the beginning and the end of my data but your code is great for putting it then together quarterly. thanks again, Denise On Mon, 2008-08-18 at 14:31 +0100, Denise Xifara wrote: > Thank you very much Stephen, but how will aggregate deal with months that > fall outside annual quarters? eg,
2009 Apr 07
1
typo in R-ints.texi's description of P_ macro
I think there are some missing words in "R Internals"'s description of the P_ macro. It currently has "A macro as a wrapper for ngettext", which I think ought to be something like "The macro P_ may be used as a wrapper for ngettext". The following patch also makes the 2 alternate definitions of P_ have the same argument names, StringS and StringP. Expanding the
2011 Feb 28
0
Fwd: Re: speed up process
Dear Jim, Here is again exactly what I did and with the output of Rprof (with this reduced dataset and with a simpler function, it is here much faster than in real life). Thanks you again for your help! ## CODE ## mydata1<- structure(list(species = structure(1:8, .Label = c("alsen","gogor", "loalb", "mafas", "pacyn", "patro",
2009 Feb 08
0
recursive derivative a list of polynomials
Dear list, This is quite a specific question requiring the package orthopolynom. This package provides a nice implementation of the Legendre polynomials, however I need the associated Legendre polynomial which can be readily expressed in terms of the mth order derivative of the corresponding Legendre polynomial. (For the curious, I'm trying to calculate spherical harmonics [*]).
2008 Jul 11
1
Suggestion: 20% speed up of which() with two-character mod
Hi, by replacing 'll' with 'wh' in the source code for base::which() one gets ~20% speed up for *named logical vectors*. CURRENT CODE: which <- function(x, arr.ind = FALSE) { if(!is.logical(x)) stop("argument to 'which' is not logical") wh <- seq_along(x)[ll <- x & !is.na(x)] m <- length(wh) dl <- dim(x) if (is.null(dl)
2019 May 21
0
print.<strorageMode>() not called when autoprinting
FWIW it was the intention of the patch to make printing of unclassed functions consistent with other base types. This was documented in the "patch 3" section: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17398 I think we need a general way to customise auto-printing for base types and even classed objects as that'd be useful for both users and IDEs. However S3 dispatch may
2009 Sep 19
1
matrix operations on grobs and grid units
Dear list, As a minimal test of a more complex grid layout, I'm trying to find a clean and efficient way to arrange text grobs in a rectangular layout. The labels may be expressions, or text with a fontsize different of the default, which means that the cell sizes should probably be calculated using grobWidth() and grobHeight() as opposed to simpler stringWidth() and stringHeight().
2011 Feb 25
1
speed up process
Dear users, I have a double for loop that does exactly what I want, but is quite slow. It is not so much with this simplified example, but IRL it is slow. Can anyone help me improve it? The data and code for foo_reg() are available at the end of the email; I preferred going directly into the problematic part. Here is the code (I tried to simplify it but I cannot do it too much or else it
2019 May 21
3
print.<strorageMode>() not called when autoprinting
Letting a user supply the autoprint function would be nice also. In a way you can already do that, using addTaskCallback(), but that doesn't let you suppress the standard autoprinting. Having the default autoprinting do its own style of method dispatch doesn't seem right. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, May 21, 2019 at 10:50 AM Lionel Henry <lionel at
2005 Jun 24
1
r programming help II
Dear List, Suppose we have a variable K.JUN defined as (with 1=wet, 0=dry): K.JUN1984 = c(1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) K.JUN1985 = c(0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1) K.JUN1986 = c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1)
2018 May 11
3
add one variable to a data frame
Hi Sarah, Thank you so much!! I got your good ideas. Ding -----Original Message----- From: Sarah Goslee [mailto:sarah.goslee at gmail.com] Sent: Friday, May 11, 2018 11:40 AM To: Ding, Yuan Chun Cc: r-help mailing list Subject: Re: [R] add one variable to a data frame [Attention: This email came from an external source. Do not open attachments or click on links from unknown senders or
2012 Oct 16
2
cannot coerce class '"rle"' into a data.frame
why? > rle Run Length Encoding lengths: int [1:1650061] 2 2 8 2 4 5 6 3 26 46 ... values : chr [1:1650061] "4bbf9e94cbceb70c BG bg" "4fbbf2c67e0fb867 SK sk" ... > as.data.frame(rle) Error in as.data.frame.default(vertices.rle) : cannot coerce class '"rle"' into a data.frame it seems that rle.df <-
2011 Sep 28
0
Rle function to expand for many samples
Dear R experts, code: >m<-read.table("test.txt",sep='\t',header=TRUE,colClasses=c('character','integer','integer','rep('numeric',150)) > s<-data.frame(c(rle(m$Sample1)[[2]],rle(m$Sample2)[[2]],rle(m$Sample3)[[2]]),c(rle(m$Sample1)[[1]],rle(m$Sample2)[[1]],rle(m$Sample3)[[1]])) > names(s)=c("Values","Probes")
2013 Mar 26
2
Feed rle() output to hist()
I want to make a histogram from the lengths vector which is part of the output of rle. But I don't know how to access that vector so that I use it as an argument of hist(). What argument must I use so that I use the lengths vector as an input to hist()? Example output is: Run Length Encoding lengths: int [1:4] 1 2 3 3 values : num [1:4] -1 1 -1 1 A printout of the function rle() may
2019 May 21
2
print.<strorageMode>() not called when autoprinting
It also is a problem with storage.modes "integer" and "complex": 3.6.0> print.integer <- function(x,...) "integer vector" 3.6.0> 1:10 [1] 1 2 3 4 5 6 7 8 9 10 3.6.0> print(1:10) [1] "integer vector" 3.6.0> 3.6.0> print.complex <- function(x, ...) "complex vector" 3.6.0> 1+2i [1] 1+2i 3.6.0>