[R] Search for longest consecutive occurrence

2009-05-23 Thread tsunhin wong
Dear R Users, I am trying to write a script to count the longest consecutive occurring 1 in a sequence: test-c(1,1,1,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,1,1) In the case of the object test, 1 occurs 7 consecutive times which is the longest consecutive within the sequence. I know I can always do a

Re: [R] Search for longest consecutive occurrence

2009-05-23 Thread tsunhin wong
(test), max(lengths[!!values])) On Sat, May 23, 2009 at 1:09 PM, tsunhin wong thjw...@gmail.com wrote: Dear R Users, I am trying to write a script to count the longest consecutive occurring 1 in a sequence: test-c(1,1,1,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,1,1) In the case of the object test, 1

Re: [R] Search for longest consecutive occurrence

2009-05-23 Thread tsunhin wong
(lengths[values==0])) [1] 7 Many thanks! - John On Sat, May 23, 2009 at 1:54 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: !! On Sat, May 23, 2009 at 1:52 PM, tsunhin wong thjw...@gmail.com wrote: Thanks! I tested it using: test-c(1,1,1,1,1,0,0,0,0,0,0,0,1,1,0,1,0,1,0,1,1) that has

[R] index to select rows of a large matrix

2009-05-21 Thread tsunhin wong
Dear R Users, I have created a 1500 x 2 data frame - DataSeq. Each of the 1500 rows represents a data sequence. I have another data frame iData that stores the information of these 1500 data sequences in the same order, for example, condition, gender, etc. If I use subset to select certain

Re: [R] index to select rows of a large matrix

2009-05-21 Thread tsunhin wong
the list of indices into iData for the criteria, then you can use that to get the appropriate rows: indx - which(iData 5)  # or whatever your criteria is DataSeq[indx,, drop=FALSE]  # gives you a subset matrix of just the rows you are interested in. On Thu, May 21, 2009 at 10:10 AM, tsunhin wong

[R] Paste Strings as logical for functions?

2009-05-21 Thread tsunhin wong
Dear R Users, I have some dynamic selection rules that I want to pass around for my functions: rules - paste(g$TrialList==1 g$Session==2) myfunction - function(rules) { index - which(rules) anotherFunction(index) } However, I can't find a way to pass around these selection rules easily

Re: [R] index to select rows of a large matrix

2009-05-21 Thread tsunhin wong
Dear all, I found the answer: intersect() - John On Thu, May 21, 2009 at 7:32 PM, tsunhin wong thjw...@gmail.com wrote: Dear Jim, Thanks for your suggestion. I have a follow-up question for fellow R Users that have followed this thread: *I used to create two lists by some very flexible

[R] Replace / swap values of subset of a data.frame

2009-05-19 Thread tsunhin wong
Dear R users, I have 1 data.frame of 1500x80 - data1. I found out that there are a few cells of data that I have misplace, and I need to fix the ordering of them. In an attempt trying to swap column 22 23 of the Subject with misplaced data, I did the following: data2 - data1

[R] Too large a data set to be handled by R?

2009-05-19 Thread tsunhin wong
Dear R users, I have been using a dynamic data extraction from raw files strategy at the moment, but it takes a long long time. In order to save time, I am planning to generate a data set of size 1500 x 2 with each data point a 9-digit decimal number, in order to save my time. I know R is

[R] read.table or read.csv without row index?

2009-04-22 Thread tsunhin wong
Hello all, Probably my concepts about the data.frame and matrix and array in R are not clear, I need some clarification to help me understand them better. M - read.table(test1.csv,sep=,,row.names=NULL,header=T) gives me: M as M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 1 9 11 14 15 18 20 20 20 20 20 2

[R] cannot allocate vector of size... restructuring suggestion please...

2008-12-15 Thread tsunhin wong
Dear R Users, I was running some data analysis scripts and ran into this error: Error: cannot allocate vector of size 27.6 Mb Doing a memory.size(max=TRUE) will give me: [1] 1506.812 The current situation is: I'm working on a Windows Vista 32bit laptop with 4GB RAM (effectively 3GB I

Re: [R] cannot allocate vector of size... restructuring suggestion please...

2008-12-15 Thread tsunhin wong
Also,each data.frame of the 1500 working as data sources floating in the global environment is of a size ranging from 2000x36 to 9000x36 Please help...! THANKS!!! - John On Mon, Dec 15, 2008 at 1:12 PM, tsunhin wong thjw...@gmail.com wrote: Dear R Users, I was running some data analysis

[R] Resampling physiological data using R?

2008-12-11 Thread tsunhin wong
Dear all R users, I am going to use R to process some of my physiological data about eye. The problem is the recording machine does not sample in a reliably constant rate: the time intervals between data sampled can vary from 9msec to ~120msec, while most around in the 15-30msec range. The below

[R] Multpile (45x8) graphs of the same page / device: titles crammed

2008-12-10 Thread tsunhin wong
Dear R users, I'm trying to plot 45x8 graphs on the same pdf / device for the sake of visual comparison. par(mfcol=c(45,8)) par(mai=c(0,0,0,0)) In ?title, I can see there are cex and font settings: I set cex = 0.01 and font = 1: it is still very large, and then I tried setting font 1, e.g. font

Re: [R] Multpile (45x8) graphs of the same page / device: titles crammed

2008-12-10 Thread tsunhin wong
, 8), mai=c(0,0.1,0.1,0)) sapply(1:(45*8), function(ii) { plot(x, rnorm(x)) title(paste(test, ii), cex.main=0.5) }) - b.quiet dev.off() Hope this helps, baptiste On 10 Dec 2008, at 13:42, tsunhin wong wrote: Dear R users, I'm trying to plot 45x8 graphs

Re: [R] Multpile (45x8) graphs of the same page / device: titles crammed

2008-12-10 Thread tsunhin wong
I found I have to use font=1, and I found it works when I set: par(mfcol=c(45,8)) par(mar=c(0,0.5,1,0.5)) instead of par(mfcol=c(45,8)) par(mai=c(0,0,0,0)) On Wed, Dec 10, 2008 at 9:22 AM, tsunhin wong [EMAIL PROTECTED] wrote: What if cex=0.001 with font=1 will still have the title font too

Re: [R] Transforming a string to a variable's name? help me newbie...

2008-12-09 Thread tsunhin wong
Message- From: tsunhin wong [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2008 1:34 PM To: Greg Snow Cc: Jim Holtman; r-help@r-project.org; [EMAIL PROTECTED] Subject: Re: [R] Transforming a string to a variable's name? help me newbie... I want to combine all dataframes into one

Re: [R] Transforming a string to a variable's name? help me newbie...

2008-12-09 Thread tsunhin wong
of data frames (into 1 row or otherwise). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 -Original Message- From: tsunhin wong [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2008 1:34 PM To: Greg Snow Cc

Re: [R] Transforming a string to a variable's name? help me newbie...

2008-12-09 Thread tsunhin wong
/12/9 tsunhin wong [EMAIL PROTECTED]: I did really want to find make the suggestion work... it is going to save my time... I worked on trying to put all dataframes into a list() by: ###start of file rm(list=ls()) setwd(/Users/John/Programs/R) load(Expt108Master2008.Rdata) nms - ls(pattern

[R] Transforming a string to a variable's name? help me newbie...

2008-12-08 Thread tsunhin wong
Dear all, I'm a newbie in R. I have a 45x2x2x8 design. A dataframe stores the metadata of trials. And each trial has its own data file: I used read.table to import every trial into R as a dataframe (variable). Now I dynamically ask R to retrieve trials that fit certain selection criteria, so I

Re: [R] Transforming a string to a variable's name? help me newbie...

2008-12-08 Thread tsunhin wong
[EMAIL PROTECTED] wrote: ?get Sent from my iPhone On Dec 8, 2008, at 7:11, tsunhin wong [EMAIL PROTECTED] wrote: Dear all, I'm a newbie in R. I have a 45x2x2x8 design. A dataframe stores the metadata of trials. And each trial has its own data file: I used read.table to import every trial

Re: [R] Transforming a string to a variable's name? help me newbie...

2008-12-08 Thread tsunhin wong
Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of tsunhin wong Sent: Monday, December 08, 2008 8:45 AM To: Jim Holtman Cc: r-help@r-project.org Subject: Re: [R] Transforming a string to a variable's name? help me newbie... Thanks Jim and All