Re: [R] Problem with NA data when computing standard error

2012-04-05 Thread apcoble
I found a rather easy solution that circumvents this problem by: 1) creating your own length function using na.omit function 2) calculating variance using tapply 3) calculating length using new length function 4) calculating square root of variance by length *Code from LeCzar:*

[R] Problem assigning NA as a level name in a list

2008-12-16 Thread Cliff Behrens
I want to generate a list (called dataList below) where each of its levels is named. These names are assigned to nameList, which contains all possible permutations of size two taking letters from a larger alphabet, e.g., aa,...,Fd,..,Z1,... One of these permutations is the character string

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Peter Dalgaard
Cliff Behrens wrote: I want to generate a list (called dataList below) where each of its levels is named. These names are assigned to nameList, which contains all possible permutations of size two taking letters from a larger alphabet, e.g., aa,...,Fd,..,Z1,... One of these permutations is

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Dr Eberhard W Lisse
Quite irritating to me as the Manager of .NA too, when I used NA for .NA :-)-O el Peter Dalgaard wrote: Cliff Behrens wrote: One of these permutations is the character string NA. It seems that when I try to name one of the dataList levels NA, using names(dataList)- nameList, the names()

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Cliff Behrens
Peter, OK...here is reproducible, self-contained code: library(gregmisc) columnNames - c(A,B,C,D,N,a,b,c) namePerms- permutations(length(columnNames),2,columnNames,repeats=TRUE) nameList - paste(namePerms[,1],namePerms[,2],sep=) dataList - lapply(1:length(nameList), function(level) {})

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Peter Dalgaard
Cliff Behrens wrote: Peter, OK...here is reproducible, self-contained code: library(gregmisc) Relying on a 3rd party package is not kosher either... Whatever did list(NA=2) or l - list(2); names(l) - NA do to you? columnNames - c(A,B,C,D,N,a,b,c) namePerms-

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Cliff Behrens
Peter, I've inserted response inline below: Cliff Peter Dalgaard wrote: Cliff Behrens wrote: Peter, OK...here is reproducible, self-contained code: library(gregmisc) Relying on a 3rd party package is not kosher either... Whatever did list(NA=2) or l - list(2); names(l) - NA do to you?

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Peter Dalgaard
Cliff Behrens wrote: Peter, I've inserted response inline below: Cliff Peter Dalgaard wrote: Cliff Behrens wrote: Peter, OK...here is reproducible, self-contained code: library(gregmisc) Relying on a 3rd party package is not kosher either... Whatever did list(NA=2) or l - list(2);

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Cliff Behrens
Sorry...I didn't realize that there were such distinct lines drawn around core vs contributed packages. I merely thought that r-help put those with questions in touch with others who might have used or authored a package and experienced the same problem. I didn't intend to make more work for

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Ben Bolker
Cliff Behrens-3 wrote: For future reference, am I to assume that no contributed packages should be implicated in resolving a problem? It does bring things one step closer to minimal, reproducible. If you can identify the problem as specifically involving the package, then it's

Re: [R] Problem assigning NA as a level name in a list

2008-12-16 Thread Cliff Behrens
Very good...thanks! As you can tell, I really haven't made much (READ any) previous use of this list. Cliff Ben Bolker wrote: Cliff Behrens-3 wrote: For future reference, am I to assume that no contributed packages should be implicated in resolving a problem? It does bring

[R] problem with NA and if

2008-07-04 Thread Keld Jørn Simonsen
Hi I would like to sum a number of time series, some of them having NA's Standard action is here that if I sum a value with a NA, then the result is NA. I would like it to just keep the value. I then try to: a = NA; if (a == NA) { a = 0} just to try it out, but it says Error in if (a ==

Re: [R] problem with NA and if

2008-07-04 Thread Andrew Robinson
Hi Keld you should read ?sum. sum(c(1,2,NA), na.rm=TRUE) Cheers Andrew On Fri, Jul 04, 2008 at 08:29:34AM +0200, Keld J?rn Simonsen wrote: Hi I would like to sum a number of time series, some of them having NA's Standard action is here that if I sum a value with a NA, then the result

Re: [R] problem with NA and if

2008-07-04 Thread Bill.Venables
://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Keld Jørn Simonsen Sent: Friday, 4 July 2008 4:30 PM To: r-help@r-project.org Subject: [R] problem with NA and if Hi I would like to sum a number of time series, some

Re: [R] problem with NA and if

2008-07-04 Thread Albert Greinoecker
try is.na() regards, Albert Am Freitag, den 04.07.2008, 08:29 +0200 schrieb Keld Jørn Simonsen: Hi I would like to sum a number of time series, some of them having NA's Standard action is here that if I sum a value with a NA, then the result is NA. I would like it to just keep the

Re: [R] problem with NA and if

2008-07-04 Thread Keld J?rn Simonsen
On Fri, Jul 04, 2008 at 04:44:53PM +1000, Andrew Robinson wrote: Hi Keld you should read ?sum. sum(c(1,2,NA), na.rm=TRUE) Thanks, that solved my problem. Best regars keld Cheers Andrew On Fri, Jul 04, 2008 at 08:29:34AM +0200, Keld J?rn Simonsen wrote: Hi I would like to

[R] Problem with NA data when computing standard error

2008-04-08 Thread LeCzar
Hey, I want to compute means and standard errors as two tables like this: se-function(x)sqrt(var(x)/length(x)) object1-as.data.frame.table(tapply(Data[Year==1999],na.rm=T,list(Group[Year==1999],Season[Year==1999]),mean))

Re: [R] Problem with NA data when computing standard error

2008-04-08 Thread Jorge Velez
Hi there, Perhaps se-function(x)sqrt(var(x,na.rm=T)/sum(!is.na(x))) object1-as.data.frame.table(tapply(Data[Year==1999],list(Group[Year==1999],Season[Year==1999]),mean)) object2-as.data.frame.table(tapply(Data[Year==1999],list(Group[Year==1999],Season[Year==1999]),se)) Hope this helps, Jorge

Re: [R] Problem with NA data when computing standard error

2008-04-08 Thread Paul Johnson
On Tue, Apr 8, 2008 at 12:44 PM, LeCzar [EMAIL PROTECTED] wrote: Hey, I want to compute means and standard errors as two tables like this: se-function(x)sqrt(var(x)/length(x)) The missings are not your main problem. The command var computes the variance-covariance matrix. Some