Re: [R] Regular expressions: offsets of groups

2010-09-30 Thread Titus von der Malsburg
Ok, we decided to have a shot at modifying gregexpr. Let's see how it works out. If anybody is interested in discussing this please contact me. R-help doesn't seem like the right place for further discussion. Is there a default place for discussing things like that? Thanks everybody for your

Re: [R] Regular expressions: offsets of groups

2010-09-29 Thread Titus von der Malsburg
Bill, Michael, good to see I'm not the only one who sees potential for improvements in the regexpr domain. Adding a subpattern argument is certainly a step in the right direction and would make my life much easier. However, in my application I need to know not only the position of one group but

Re: [R] Regular expressions: offsets of groups

2010-09-29 Thread Titus von der Malsburg
On Wed, Sep 29, 2010 at 1:58 PM, Michael Bedward michael.bedw...@gmail.com wrote: How is your C coding ? Bill ? Anyone else ?  I could have a got at writing some prototype code to test in the next few days, though if someone else with decent C skills is itching to do it please speak up. We

Re: [R] Regular expressions: offsets of groups

2010-09-28 Thread Titus von der Malsburg
On Tue, Sep 28, 2010 at 9:46 AM, Michael Bedward michael.bedw...@gmail.com wrote: What Titus wants to do is akin to retrieving capturing groups from a Matcher object in Java. Precisely. Here's the description:

[R] Regular expressions: offsets of groups

2010-09-27 Thread Titus von der Malsburg
Dear list! gregexpr(a+(b+), abcdaabbc) [[1]] [1] 1 5 attr(,match.length) [1] 2 4 What I want is the offsets of the matches for the group (b+), i.e. 2 and 7, not the offsets of the complete matches. Is there a way in R to get that? I know about gsubgn and strapply, but they only give me the

Re: [R] Regular expressions: offsets of groups

2010-09-27 Thread Titus von der Malsburg
]]) # now determine where 'b' starts justA[[1]][indx] + attr(justA[[1]], 'match.length')[indx] [1]  2  7 17 On Mon, Sep 27, 2010 at 11:48 AM, Titus von der Malsburg malsb...@gmail.com wrote: Dear list! gregexpr(a+(b+), abcdaabbc) [[1]] [1] 1 5 attr(,match.length) [1] 2 4 What I want

Re: [R] Regular expressions: offsets of groups

2010-09-27 Thread Titus von der Malsburg
On Mon, Sep 27, 2010 at 7:16 PM, Henrique Dallazuanna www...@gmail.com wrote: You've tried: gregexpr(b+, abcdaabbc) But this would match the third occurrence of b+ in abcdaabbcbb. But in this example I'm only interested in b+ if it's preceded by a+. Titus

Re: [R] Regular expressions: offsets of groups

2010-09-27 Thread Titus von der Malsburg
On Mon, Sep 27, 2010 at 7:29 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this zero width negative look behind expression: gregexpr((?!a+)(b+), abcdaabbc, perl = TRUE) [[1]] [1] 2 7 attr(,match.length) [1] 1 2 Thanks Gabor, but this gives me the same result as gregexpr(b+,

[R] melt on OSX ignores na.rm=T

2010-02-06 Thread Titus von der Malsburg
Hi list, I run R on Linux and OSX. On both systems I use R version 2.9.2 (2009-08-24) and reshape version: 0.8.2 (2008-11-04). When I do a melt with na.rm=T on a data frame I get different results on these systems: library(reshape) x - read.table(textConnection(char trial wn p E10I13D0 4 r

Re: [R] melt on OSX ignores na.rm=T

2010-02-06 Thread Titus von der Malsburg
On Sat, Feb 6, 2010 at 8:23 PM, hadley wickham h.wick...@gmail.com wrote: The latest version of reshape is 0.8.3 - perhaps upgrading will fix your problem. Thanks for your response, Hadley! I just did the upgrade on the Linux system. On OSX I was already at 0.8.3. Now, I get the same result

Re: [R] melt on OSX ignores na.rm=T

2010-02-06 Thread Titus von der Malsburg
Ok, I studied the source code of melt.data.frame. With na.rm=T melt operates normally except that it deletes rows from the molten data.frame that have NAs in the value column. NAs in the id.vars are not touched. This could be clearer in the documentation especially as it seems that earlier

[R] estimating rho of Poisson distributed data

2010-01-15 Thread Titus von der Malsburg
Mean and variance of Poisson distributed data are specified by \rho. How can I estimate \rho for a set of measurements in R? Many thanks! Titus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] estimating rho of Poisson distributed data

2010-01-15 Thread Titus von der Malsburg
On Fri, Jan 15, 2010 at 09:19:23AM -0500, David Winsemius wrote: On Jan 15, 2010, at 5:59 AM, Titus von der Malsburg wrote: Mean and variance of Poisson distributed data are specified by \rho. How can I estimate \rho for a set of measurements in R? rho - mean(x) Yeah, thanks :-) I

Re: [R] estimating rho of Poisson distributed data

2010-01-15 Thread Titus von der Malsburg
On Fri, Jan 15, 2010 at 08:33:52AM -0700, Peter Ehlers wrote: Why would anyone complain? You're free to call it 'applesauce' if that suits you. Good idea, I will do this from now on! ;-) What do you mean by 'general way to fit a distribution'? Maximum likelihood might be one way. Somebody

Re: [R] conditionally merging adjacent rows in a data frame

2009-12-09 Thread Titus von der Malsburg
On Wed, Dec 9, 2009 at 12:11 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Here are a couple of solutions. The first uses by and the second sqldf: Brilliant! Now I have a whole collection of solutions. I did a simple performance comparison with a data frame that has 7929 lines. The

Re: [R] general question about functions

2009-12-08 Thread Titus von der Malsburg
http://www.rseek.org/ It is particularly useful to search the mailing list archives of r-help with rSeek. No matter what kind of problem you have, somebody has had it before and asked on r-help. Titus __ R-help@r-project.org mailing list

[R] conditionally merging adjacent rows in a data frame

2009-12-08 Thread Titus von der Malsburg
Hi, I have a data frame and want to merge adjacent rows if some condition is met. There's an obvious solution using a loop but it is prohibitively slow because my data frame is large. Is there an efficient canonical solution for that? head(d) rt dur tid mood roi x 55 5523 200 4 subj

Re: [R] conditionally merging adjacent rows in a data frame

2009-12-08 Thread Titus von der Malsburg
On Tue, Dec 8, 2009 at 4:50 PM, Gray Calhoun gray.calh...@gmail.com wrote: I think there might be a problem with this approach if roi, tid, rt, and mood are the same for nonconsecutive rows. True, but I can use the index of my reshape solution. Aggregate was the crucial ingredient. Thanks

Re: [R] conditionally merging adjacent rows in a data frame

2009-12-08 Thread Titus von der Malsburg
On Tue, Dec 8, 2009 at 5:19 PM, Nikhil Kaza nikhil.l...@gmail.com wrote: I suppose that is true, but the example data seem to suggest that it is sorted by rt. I was not very clear on that. Sorry. d$count - 1  a - with(d, aggregate(subset(d, select=c(dur, x, count),

[R] Sweave and license message when loading mclust package

2009-12-07 Thread Titus von der Malsburg
When loading mclust, it shows a license agreement message. This message shows up in my document when I use Sweave. I did the following: echo=FALSE,include=FALSE= library(mclust) @ Is this a problem with mclust, Sweave or with me? How can it be fixed? Thanks for any suggestions! Titus

[R] Splicing factors without losing levels

2009-06-09 Thread Titus von der Malsburg
Hi list! An operation that I often need is splicing two vectors: splice(1:3, 4:6) [1] 1 4 2 5 3 6 For numeric vectors I use this hack: splice - function(x, y) { xy - cbind(x, y) xy - t(xy) dim(xy) - length(x) * 2 return(xy) } So far, so good (?). But I also need

Re: [R] Splicing factors without losing levels

2009-06-09 Thread Titus von der Malsburg
On Tue, Jun 09, 2009 at 11:23:36AM +0200, ONKELINX, Thierry wrote: For factors, you better convert them first back to character strings. splice - function(x, y) { x - levels(x)[x] y - levels(y)[y] factor(as.vector(rbind(x, y))) } Thank you very much, Thierry! I

Re: [R] R command to join data.frames rows with identical keys?

2009-06-09 Thread Titus von der Malsburg
Have a look at the merge function. Merge two data frames by common columns or row names, or do other versions of database _join_ operations. Titus On Tue, Jun 09, 2009 at 05:48:05AM -0700, Jason Rupert wrote: I've got two data.frames and, when certain keys match, I would like to

Re: [R] R command to join data.frames rows with identical keys?

2009-06-09 Thread Titus von der Malsburg
An example: schoolZone1_df - data.frame(address=101, schoolZone=Sherman) schoolZone2_df - data.frame(address=108, schoolZone=Baker) schoolZone_df - rbind(schoolZone1_df, schoolZone2_df) schoolZone_df address schoolZone 1 101Sherman 2 108 Baker neighborhoodInfo1_df -

Re: [R] is it possible to combine multiple barplots?

2009-06-09 Thread Titus von der Malsburg
You can use barchart in package lattice. Here's a rough sketch: library(lattice) dataA - rep(1:4, c(3,2,2,4)) dataB - rep(1:4, c(5,4,3,2)) da - data.frame(table(dataA)) db - data.frame(table(dataB)) da$cond - a db$cond - b colnames(da)[1] - data

Re: [R] is it possible to combine multiple barplots?

2009-06-09 Thread Titus von der Malsburg
On Tue, Jun 09, 2009 at 04:39:29PM +0200, Titus von der Malsburg wrote: is there a way to plot both of them in one plot, so that the bars for value 1 (dataA: 3, dataB: 5) would appear side by side, followed by the bars for value 2 etc.? Oh, I see you want something different. I should've

Re: [R] Splicing factors without losing levels

2009-06-09 Thread Titus von der Malsburg
On Tue, Jun 09, 2009 at 11:04:03AM -0400, Stavros Macrakis wrote: This may seem like a minor point, but I think it is worthwhile using descriptive names for functions. Makes sense. I thought I've seen this use somewhere else (probably in Lisp?). What better name do you suggest for this

[R] What's the best way to tell a function about relevant fields in data frames

2009-05-12 Thread Titus von der Malsburg
Hi list, I have a function that detects saccadic eye movements in a time series of eye positions sampled at a rate of 250Hz. This function needs three vectors: x-coordinate, y-coordinate, trial-id. This information is usually contained in a data frame that also has some other fields. The names

Re: [R] What's the best way to tell a function about relevant fields in data frames

2009-05-12 Thread Titus von der Malsburg
Hi Zeljko, thanks for your suggestion! On Tue, May 12, 2009 at 12:26:48PM +0200, Zeljko Vrba wrote: Why not simply rearrange your data frames to have standardized column names (see names() function), and write functions that operate on the standardized format? Actually that's what I'm

[R] Applying functions to partitions

2009-02-16 Thread Titus von der Malsburg
Hi list! I have a large matrix which I'd like to partition into blocks and for each block I'd like to compute the mean. Following a example where each letter marks a block of the partition: a a a d g g a a a d g g a a a d g g b b b e h h b b b e h h c c c f i i

Re: [R] Applying functions to partitions

2009-02-16 Thread Titus von der Malsburg
looking for a way to get the means more or less at once because the matrix is pretty large and doing it block-wise is too slow. Thanks again! Titus On 2/16/09, Titus von der Malsburg malsb...@gmail.com wrote: Hi list! I have a large matrix which I'd like to partition into blocks

Re: [R] Adjusting the Axis in a histogram to the prespecified breaks

2009-02-16 Thread Titus von der Malsburg
On Mon, Feb 16, 2009 at 11:08:24AM -0800, Christian Langkamp wrote: I could of course log the whole data set, but then explaining that transformation within a presentation is generally not a pleasant exercise. You don't have to explain it. Just calculate the hist of the log and label the axis

[R] Variables captured in closures get copied?

2009-02-11 Thread Titus von der Malsburg
Hi list! I have a data frame called fix and a list of index vectors called rois: head(rois, 3) [[1]] [1] 2 1 [[2]] [1] 3 [[3]] [1] 6 7 28 26 27 24 25 The part that's causing the issue is the following line: lapply(rois, function(roi) fix$x[roi] - 100) So for every index

[R] Splitting a data frame with break points where factor changes value

2009-01-31 Thread Titus von der Malsburg
I have a data frame called s3. This data frame has a column called saccade which has two levels 1 and -1. head(s3$saccade, 100) [1] NA NA NA NA -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [26] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 [51]

Re: [R] Multidimensional scalling

2009-01-31 Thread Titus von der Malsburg
Hi Tomek, have a look at R News, Volume 3/3, December 2003. There you find an article about different algorithms that are available in R. Titus On Sat, Jan 31, 2009 at 01:36:29AM +0100, Tomek Wlodarski wrote: now I see that cmdscale is not the best option for my problem So I am wondering if

[R] melt stumbles over deleted columns

2009-01-22 Thread Titus von der Malsburg
I have a data frame that is the result of a cast (reshape) operation. I deleted the variable column and tried to melt the resulting data frame. Depending on which method I use to delete the column I get different error messages when melting: head(tinfos) vpn group trial_no item