[R] Matrix/dataframe indexing

2007-03-05 Thread Guenther, Cameron
Hi all, I am hoping someone can help me out with this: If I have dataframe of years and ages and the first column and first row are filled with leading values: Df-age1age2age3 Yr1 1 0.4 0.16 Yr2 1.5 0 0 Yr3 0.9 0 0

[R] Matrix looping

2007-03-02 Thread Guenther, Cameron
Hi all, I am having a problem getting my fucntion to work correctly. Here is my problem. I have three ages: Nage-c(1,2,3) I have an weight matrix: Wt-c( 0.04952867, 0.23808432, 0.34263880) I have an age schedule of maturity: Mat-c(0,1,1) where 0 is not mature, and 1 is mature I have a

[R] Expression

2006-11-30 Thread Guenther, Cameron
Hi all, I have a question about expression. In a figure I want to include the term D*obs with the star as as superscript and obs as subscript. I have even just tried to get the star to be superscript. The code I tried was text(Dstar+7,120,expression(paste({}D,^*))), but that doesn't work and

[R] Counting zeros in a matrix

2006-11-28 Thread Guenther, Cameron
Hi All, If you could help me with this problem I would greatly appreciate it. Suppose I have a matrix A: 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 I would like, for each row, to sum the number of times a 0 appears in front of a 1. So what I would like is to have

[R] randomize a matrix

2006-10-19 Thread Guenther, Cameron
Hello everyone, If I have an incidence matrix of 0 and 1's P=[1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 0 0] I want to create a new uniform random matrix [a] that is filled with 0's and 1's but constrained so that the row and column sums are the same as in [P]. Does

[R] How to Pack a matrix

2006-09-26 Thread Guenther, Cameron
Hello, Suppose I have a matrix a where a= sp1 sp2 sp3 sp4 sp5 sp6 site1 1 0 1 1 0 1 site2 1 0 1 1 0 1 site3 1 1 1 1 1 1 site4 0

[R] help with function

2006-09-20 Thread Guenther, Cameron
Hello everyone, I have a function here that I wrote but doesn't seem to work quite right. Attached is the code. In the calib funcion under the for loop Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i+1] returns NA's for everything after years 1983 and 1984. However the code works when it reads

[R] -Need help with function

2006-09-19 Thread Guenther, Cameron
Hello everyone, I have a function here that I wrote but doesn't seem to work quite right. Attached is the code. In the calib funcion under the for loop Bt[i+2]-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i+1] returns NA's for everything after years 1983 and 1984. However the code works when it reads

[R] Joining variables

2006-05-24 Thread Guenther, Cameron
Hello, If I have two variables that are factors or characters and I want to create a new variable that is the combination of both what function can I use to accomplish this? Ex. Var1Var2 SA100055113 19851113 And I want NewVar SA10005511319851113 Thanks in

Re: [R] Joining variables

2006-05-24 Thread Guenther, Cameron
- From: Berton Gunter [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 24, 2006 2:54 PM To: Guenther, Cameron; r-help@stat.math.ethz.ch Subject: RE: [R] Joining variables What does combination of both mean exactly. I can think of two interpretations that have two different answers. If you give a small

[R] subset

2006-05-16 Thread Guenther, Cameron
Hello everyone, I have a large dataset (x) with some rows that have duplicate variables that I would like to remove. I find which rows are the duplicates with X1-which(duplicated(x)). That gives me the rows with duplicated variables. Now, how can I remove just those rose from the original data

Re: [R] subset

2006-05-16 Thread Guenther, Cameron
. 4305 [EMAIL PROTECTED] -Original Message- From: Marc Schwartz (via MN) [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 2:50 PM To: Guenther, Cameron Cc: r-help@stat.math.ethz.ch Subject: Re: [R] subset On Tue, 2006-05-16 at 14:37 -0400, Guenther, Cameron wrote: Hello everyone, I

Re: [R] subset

2006-05-16 Thread Guenther, Cameron
: Tuesday, May 16, 2006 3:01 PM To: Guenther, Cameron Subject: Re: [R] subset Cameron - Is X1 = which(duplicated(x)) x[-X1,] or x[!duplicated(x),] or subset(x,!duplicated(x)) what you're looking for? Remember that which() will always return indices, so negating them

[R] Unique?

2006-05-10 Thread Guenther, Cameron
Hello, I have sample data set that looks like: YEARMONTH DAY CONTINUESPL TIMEFISH TIMEUNITAREACOUNTY DEPTH DEPUNIT GEARTRIPID CONVUNIT 19921 26 1 SP0073928 8 H 7 25 4

[R] Aggregate?

2006-05-03 Thread Guenther, Cameron
Hello, I have a data set with a grouping variable (TRIPID) and several other variables. TRIPID is repeated in some areas and I would like to use a function like aggregate to sum the variable UNITS according to TRIPID. However I would also like to retain the other variables as they are in the

[R] Evaluating a function with another function

2006-04-06 Thread Guenther, Cameron
Hello all, I hope someone can help me with this. I have function that calculates two values based on input data. A simple example follows: test-function(x,s,rangit=seq(0,10,1)) { rangit-rangit y-vector() p-vector() for(i in 0:length(rangit)){ y[i]-x+s[1]+rangit[i] p[i]-x+s[2]+rangit[i] }

[R] Glm poisson

2006-03-27 Thread Guenther, Cameron
Hello, I am using the glm model with a poisson distribution. The model runs just fine but when I try to get the null deviance for the model of the null degrees of freedom I get the following errors: null.deviance(pAmeir_1) Error: couldn't find function null.deviance df.null(pAmeir_1) Error:

[R] apply

2006-01-13 Thread Guenther, Cameron
Hello, I have a dataset d which is d pop catch 1 66462.01 10807.757 2 87486.73 46257.885 3 57211.64 9345.058 4 71321.62 4892.868 5 100024.89 27334.248 6 104504.91 48535.092 7 95295.51 39348.195 8 93737.35 34343.489 9 89375.05 28750.743 10 95312.65

[R] Warning message help

2005-11-21 Thread Guenther, Cameron
I am trying to great a new column of effort data from an existing vector of gears used. It is a simple code where effort[Gear==300]=(DIST_TOW*7412) effort[Gear==301]=(DIST_TOW*7412) The code appears to work for some of the data but fails for others and inserts a NA value I also get this

[R] IF/Else

2005-11-10 Thread Guenther, Cameron
Hi, I am trying to write a for loop with if else statements to calculate biomass density estimates for different types of sampling gear. My code is: bmd=for (i in 1:length(Gear)){ if (Gear==20) {bioden=Biomass/141} else {if (Gear==23) {bioden=Biomass/68}} else {if (Gear==160)

[R] file size limit for importing SAS file

2005-10-25 Thread Guenther, Cameron
Does anyone know if there is a file size limit for inputting a SAS data set? The file size I am trying to import is 184 MB. The code is: library(foreign) sashome-C:/Program Files/SAS Institute/SAS/V8 input.data-read.ssd( file.path(G:/DATA/Cam/ECPATH/FIM),tbm_c, +

[R] Repeating lines in a data frame

2005-10-18 Thread Guenther, Cameron
Hello, I have a much larger dataset that is similar in form to: year species length count 1998 1150 1 1998 2200 1 1998 3250 2 1999 1150 3 1999 2200 4 1999 3250 5 2000 1150 1 2000 2