[R] Select cases of data.frame based on a long index

2009-06-03 Thread tsunhin wong
Dear R users, I know how to select a subset of a data.frame or a matrix by setting some criteria, but this time, I have a long index of cases not really related to 1 or 2 criteria. And I cannot find a simple way to select cases from another data.frame based on this index (sublst in this example).

[R] Barplot: annotations at tips of each bar?

2009-06-02 Thread tsunhin wong
Dear R-users, I have searched through examples of barplot in R. But there seems to be no advanced annotation options in R for their barplot. What I am trying to do is to do some annotations at the tip of each bar in a barplot, similar to the graph below: http://www.lakesuperiorstreams.org/understa

Re: [R] Within Subject ANOVA question

2009-06-01 Thread tsunhin wong
nce wrote: > On Mon, Jun 1, 2009 at 7:50 PM, tsunhin wong wrote: >> But I have some follow-up questions: >> 1. In aov, why IVs (subject & condition) cannot be in number format? > > Put simply, because that's the only way to obtain the values you > observe in the p

Re: [R] Within Subject ANOVA question

2009-06-01 Thread tsunhin wong
ll) > aov.recall <- aov(recall~condition + Error(subject/condition),data=example) > summary(aov.recall) Error: subject Df Sum Sq Mean Sq F value Pr(>F) Residuals 9 942.53 104.73 Error: subject:condition Df Sum Sq Mean Sq F valuePr(>F) condition 2 52.267 26.1

[R] Within Subject ANOVA question

2009-06-01 Thread tsunhin wong
Dear R users, I have copied for following table from an article on "Using confidence intervals in within-subject designs": Subject 1sec 2sec 5sec 1 10 13 13 12.00 2 6 8 8 7.33 3 11 14 14 13.00 4 22 23 25 23.33 5 16 18 20 18.00 6 15 17 17 16.33 7 1 1 4 2.00 8 12 15 17 14.67 9 9 12 12 11.00 10 8 9

Re: [R] Search for longest consecutive occurrence

2009-05-23 Thread tsunhin wong
t; with(rle(test), max(lengths[values==0])) [1] 7 Many thanks! - John On Sat, May 23, 2009 at 1:54 PM, Gabor Grothendieck wrote: > !! > > On Sat, May 23, 2009 at 1:52 PM, tsunhin wong wrote: >> Thanks! >> I tested it using: >> test<-c(1,1,1,1,1,0,0,0,0,0,0,0,1

Re: [R] Search for longest consecutive occurrence

2009-05-23 Thread tsunhin wong
max(lengths[!!values])) > > > On Sat, May 23, 2009 at 1:09 PM, tsunhin wong 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

[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 th

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 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 fl

[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

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

2009-05-21 Thread tsunhin wong
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 wrote: >> >> Dear R Users, >> >> I have created a 1500 x 2 data frame - DataSeq. Each of the 1500 >> rows represents a data

[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

[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 limi

[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 > subset(data1,(S

[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

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 wrote: > Dear R Users, > > I was running some data analysis script

[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 assume..

[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

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

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

2008-12-10 Thread tsunhin wong
>> x <- seq(0, 10) >> >> pdf(width=8, height=20) >> par(mfrow=c(45, 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.qu

[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] Transforming a string to a variable's name? help me newbie...

2008-12-09 Thread tsunhin wong
t; 019data$var1 >> plot(var1 ~ var2, data = 019data) >> lm(var1 ~ ., data = 019data) > etc. etc. > > HTH, > antonio. > > 2008/12/9 tsunhin wong <[EMAIL PROTECTED]>: >> I did really want to find make the suggestion work... it is going to >> save my t

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

2008-12-09 Thread tsunhin wong
ement of the list). This list will > not take up about the same amount of memory as if you read each file into a > dataframe in the global environment. And there is no transforming of data > frames (into 1 row or otherwise). > > -- > Gregory (Greg) L. Snow Ph.D. > Statistic

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

2008-12-09 Thread tsunhin wong
gt; dataframe in the global environment. And there is no transforming 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 M

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

2008-12-08 Thread tsunhin wong
ta Center > Intermountain Healthcare > [EMAIL PROTECTED] > 801.408.8111 > > >> -Original 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

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

2008-12-08 Thread tsunhin wong
John On Mon, Dec 8, 2008 at 10:40 AM, Jim Holtman <[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 ha

[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