[R] two sample chi-squared test

2010-01-29 Thread eric lee
Hello, Can you tell me what R function to use to do a two-sample chi-squared test? I want to see if two distributions are significantly different from each other, and I don't specify the theoretical distribution of either. For example, I have the following fake count data: x <- sample(1:10,50,r

[R] releasing memory when using the ncdf package

2009-09-15 Thread eric lee
Hello, I'm running R 2.7.2 in a windows XP environment and I run the following in an R console: library(ncdf) nc <-open.ncdf('c:/file.nc') aa <- get.var.ncdf(nc,'var1') This works fine, but 'aa' takes up about 100mb and I want to release the memory after using it. I try: rm(aa) close.ncdf(nc)

[R] maximum over one dimension of a 3-dimensional array

2009-05-28 Thread eric lee
Hi, I'm running R 2.7.2 on windows XP. I'd like to find the maximum of a 3-d array over it's third index to create a 2-d array. For example: > x <- array(c(1,2,3,10,11,12,3:8),c(2,3,2)) > x , , 1 [,1] [,2] [,3] [1,]13 11 [2,]2 10 12 , , 2 [,1] [,2] [,3] [1,]3

Re: [R] which zip file is the emulator package?

2009-02-26 Thread eric lee
Thanks, Duncan. The BACCO package worked. On Thu, Feb 26, 2009 at 11:22 AM, Duncan Murdoch wrote: > On 2/26/2009 11:08 AM, eric lee wrote: >> >> Hi.  I'm trying to run the elliptic package on my computer (windows >> platform, version 2.7.2).  I downloaded the ellipti

Re: [R] which zip file is the emulator package?

2009-02-26 Thread eric lee
n port 80. I assume it's something on my end because I've been having connectivity issues here. Thanks again for your help. eric On Thu, Feb 26, 2009 at 11:22 AM, Duncan Murdoch wrote: > On 2/26/2009 11:08 AM, eric lee wrote: >> >> Hi.  I'm trying to run the elliptic

[R] which zip file is the emulator package?

2009-02-26 Thread eric lee
Hi. I'm trying to run the elliptic package on my computer (windows platform, version 2.7.2). I downloaded the elliptic package zip file from http://lib.stat.cmu.edu/R/CRAN/ and installed it, but it says that it needs the "emulator" package. Can you tell me where to download this? The only simi

[R] how to generate multiple random variables that are correlated

2009-02-02 Thread eric lee
Hi. I have two variables, x and y, that are each normally distributed with mean 0 and have known standard deviations. The variables also have a known correlation, so I can represent their correlations in a matrix like so: a <- array(c(0.3,0.1,0.1,0.2),c(2,2)) a Is there an R function that gener

[R] difftime

2008-12-09 Thread eric lee
Hi. I'm trying to take the difference in days between two times. Can you point out what's wrong, or suggest a different function? When I try the following code, The following code works fine: a <- strptime(1911100807,format="%Y%m%d%H",tz="GMT") b <- strptime(1911102718,format="%Y%m%d%H",tz="GM

[R] lines, ecdf and colors

2008-11-08 Thread eric lee
Hi. I'm trying to plot two ecdf's on the same graph using two different colors. I can plot using the same color, but it doesn't work when I change colors? Any suggestions? Thanks in advance for your help. x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46) y <- c(1.15, 0.88, 0.9

[R] getting the p-value from lm as a list object

2008-10-31 Thread eric lee
Hi, I'm trying to get the p-value from the 'lm' regression function as a list object. For example, I can get r^2 from the following code by entering summary(fm)$r.squared. Is there a way to get the p-value? If not, is there a function where I can enter the f-value and degrees of freedom to get

[R] ad.test exponential distribution

2008-10-22 Thread eric lee
Hi, I'm trying to use ad.test or ad2.test to test whether a given data set is exponential. I see that one of the function inputs is "distn", but I try "exponential" and 5 other variants, but I still get the error message: ad.test(test2, distn="exponential", fit=list(estimate = 0.167685), H=NA, s

[R] find bayesian information criterion for all variable combinations

2008-10-17 Thread eric lee
Hi, I have data for one dependent variable and multiple independent variables y = b0 + b1*x1 + b2*x2 + ... I want to a list of all models that have some subset of the independents (just x1 x2, and not x3, etc.) and their corresponding BIC values. Is there a pre-existing function that does this?

[R] lapply where each list object has multiple parts

2008-10-01 Thread eric lee
Hi. I have a list where each object in the list has multiple parts. I'd like to take the mean of just one part of each object. Is it possible to do this with lapply? If not, can you recommend another function? Thanks. eric > x1 <- c(0,1,2,3) > x2 <- c(7,8) > x3 <- c(2,6,6,8) > x4 <- c(4,8) >

[R] merging a list and data frame

2008-09-30 Thread eric lee
Hi, I'd like to merge the following list and data frame by matching the first column in the data frame to the first number in each object of the list. I'd also like the merged object to be a list. Any suggestions? Thanks. eric a <- list(c(1,11), c(2,12), c(3,13), c(4,14), c(5,16)) b <- data.f

[R] adding labels to tapply results

2008-09-29 Thread eric lee
Hi, How do I get labels onto the output from tapply? I need the labels to merge the output with another data frame. Thanks. eric d <- data.frame(cbind(x=1:3, y=1:10)) a <- with(d, tapply(y, x, sum)) [[alternative HTML version deleted]] __ R

[R] using tapply on a data frame in a function

2008-09-28 Thread eric lee
Hello, I'm trying to use tapply to find group means in a function. It works outside of a function, but I get the error message from the following code: "Error in tapply(index, cluster, mean) : arguments must have same length." Any suggestions? Thanks. eric d <- data.frame(cbind(cluster=1:2, va

[R] data frame column name as a function argument

2008-09-26 Thread eric lee
Hello, I'd like to pass a column name as the argument for a function, but I'm getting "NULL" as a return value. Any suggestions? Thanks. > d <- data.frame(cbind(x=1, y=1:10)) > d x y 1 1 1 2 1 2 3 1 3 4 1 4 5 1 5 6 1 6 7 1 7 8 1 8 9 1 9 10 1 10 > testing <- function(var) {