[R] Calculate mean/var by ID

2008-09-11 Thread liujb
Hello, I have a data set that looks like this. IDvalue 111 5 111 6 111 2 178 7 178 3 138 3 138 8 138 7 138 6 . . . I'd like to calculate the mean and var for each object identified by the ID. I can in theory just loop through the whole thing..., but is th

[R] quantile

2008-09-29 Thread liujb
Hello, I need to assign a number to each x[i], i=1:100, based on the value of x[i] and where they are in the distribution of x[i]. For example 1 for x[4] means x[4] is below 25%. I can obtain the quantile using quantile command, and just loop through the 1:100 and assign the correct number. But I

[R] Adding legends to a plot

2008-09-30 Thread liujb
Hello, I have a time series plot drawn using 3 different colored lines, each line corresponds to different category group. I'd like to put legends on the plot. I am using "legend" to do this, however, I can either specify lty or col in legend. Will I be able to do the following in the legend box:

[R] detect repeated number in a vector

2008-10-08 Thread liujb
Dear R users, I have this vector that consists numeric numbers. Is there a command that detects the repeated numbers in a vector and returns the index of the repeated numbers (or the actual numbers)? For example, v <- c(3,4,5,7,4). The command would return me index 2 and 5 (or the repeated number

Re: [R] detect repeated number in a vector

2008-10-08 Thread liujb
Duncan, Thank you so much. It is exactly what I was looking for. However, for some reason, indices() does not work ("Error: could not find function "indices"). I used which(), it worked. Thanks again for the help, Julia Duncan Murdoch-2 wrote: > > On 08/10/2008

[R] how to store lme/lmer fit result

2008-10-09 Thread liujb
Dear R users, I am building a hierarchical model on a large data set. It can take quite some time to finish one fit, I was just wondering whether it is possible to store the fit object (the result) to a file for later (offline) analysis. thanks Julia -- View this message in context: http://w

[R] roll weekly data to monthly level

2009-01-12 Thread liujb
Dear R users: I have a data set that looks something like this: IDtime y 12/01/20084 12/09/200812 19/01/20088 21/06/20083 23/01/20084 23/09/20089 26/03/20084 31/02/20083 31/10/20088 32/02/20087 32/10

[R] increase memory limit in R

2008-10-16 Thread liujb
Dear R users, I am running lmer() and having memory problem: "reached total allocation of 1535Mb". The lmer() function was successful (no errors or warnings). However when I do "summary(fit.lmer), I got this "Error: cannot allocate vector of size 19.5 Mb). I used memory.size() and got 1880. I us

[R] How to increase iteration limit for lmer()?

2008-10-30 Thread liujb
Dear R users: I am running lmer(), and I had the following warning message: "In mer_finalize(ans): iteration limit reached without convergence (9) What is the default limit for lmer()? And how do I increase the limit? Many thanks, Julia -- View this message in context: http://www.nabble.com/

Re: [R] How to increase iteration limit for lmer()?

2008-10-30 Thread liujb
e syntax to increase iteration limit? Thank you so much, Julia Dieter Menne wrote: > > liujb yahoo.com> writes: > >> I am running lmer(), and I had the following warning message: >> "In mer_finalize(ans): iteration limit reached without convergence (9) >> >>

[R] two scatter plots in one

2009-02-11 Thread liujb
Dear R users, I need to compare two scatter plots, plot(x1, y1) plot(x2, y2) and would like to plot them in the same figure. How do I do it? Thank you. -- View this message in context: http://www.nabble.com/two-scatter-plots-in-one-tp21963375p21963375.html Sent from the R help mailing list a

Re: [R] extracting dispersion parameter from quasipoisson lmer model

2009-03-10 Thread liujb
Hello, I have the exact same question: how to extract dispersion parameter from lmer() quasipoisson model? I did a search here and saw this post. However, I do not see answer. Could somebody please help? Thank you very much, Julia wayne hallstrom wrote: > > Hi, > I would like to obtain the

[R] frequence of patterns in a vector

2009-05-29 Thread liujb
Dear R users, Suppose I have a vector that consists of characters like ABC, A02, RCA, etc., and there are about 700 of possible characters. For example, x <- c("ABC", "ABC", "ABC", "A02", "ABC", "RCA", "ABC", "ABC") I'd like to get a frequency matrix that looks something like this: ABC 6 A02

[R] how to checking whether elements of a vector changed or not.

2009-06-01 Thread liujb
Hello, I have a vector: x <- c("A", "A", "A", "B", "A", "A", "C") I'd like to compare each of elements of vector x from its previous element (except for the 1st element which does not have previous element). So I'd like to get a vector y (of same length) that looks something like (0, 0, 0, 1, 1,

[R] how to read in only some columns of a data file

2009-06-17 Thread liujb
Hello, I have a data file (.csv) that has a size of about 2.6 GB. I am not able to read in the whole data set because of the memory limit. I actually only need some columns (3 columns) of the data set, is there a way to read in specified columns? I am using windows. Thanks, Julia -- View this

[R] how to transform m/d/yyyy to yyyymmdd?

2009-07-21 Thread liujb
Hello, I have a set of data that has a Date column looks like this: 12/9/2007 12/16/2007 1/1/2008 1/3/2008 1/12/2008 etc. I'd like the date to look something like the follow (so that I could sort by date easily). 20071209 20071216 20080101 20080103 20080112 How to do it? Thank you very much Jul

[R] how to calculate time interval between dates

2009-08-01 Thread liujb
Dear R users: I have a vector of dates as follows: t <- c("2007-01-05", "2007-05-14", "2007-12-28", "2008-01-09", "2008-04-24", "2009-02-14") I'd like to calculate number of days between those dates (time interval). How to do it? Thank you, Julia -- View this message in context: http://www.n

[R] multinormial runs tests?

2009-09-24 Thread liujb
Dear R users, I would like to test the randomness in a series of N values (N>=2). I know that runs.test works for dichotomous factor only: x <- rep(c(1,2), 50) runs.test(factor(x)) However it doesn't work for series that can take any N values (N>2): x <- rep(c(1,2,5,4),50) runs.test(factor(x))