Displaying 20 results from an estimated 2000 matches similar to: "subset"
2006 May 10
3
Unique?
Hello,
I have sample data set that looks like:
YEAR MONTH DAY CONTINUE SPL TIMEFISH
TIMEUNIT AREA COUNTY DEPTH DEPUNIT GEAR TRIPID
CONVUNIT
1992 1 26 1 SP0073928 8
H 7 25 4 NA 1000000
02163399054 161
1992 1 26 1 SP0073928 8
H 7 25 4 NA 1000000
02163399054 8
1992 1 26 2 SP0004228 8
H 7 25 4 NA 1000000
02163399054 161
1992 1 26 2 SP0004228 8
H 7 25 4 NA 1000000
02163399054 8
1992
2006 May 03
4
Aggregate?
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 data set with the new summed TRIPID.
So what I have is something like this:
YEAR MONTH DAY
2006 May 03
4
Aggregate?
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 data set with the new summed TRIPID.
So what I have is something like this:
YEAR MONTH DAY
2006 May 24
5
Joining variables
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.
Var1 Var2
SA100055113 19851113
And I want
NewVar
SA10005511319851113
Thanks in advance.
Cameron Guenther, Ph.D.
Associate Research Scientist
FWC/FWRI, Marine Fisheries Research
100 8th Avenue S.E.
St.
2006 Oct 19
2
randomize a matrix
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 anyone know how to accomplish this?
Thanks in advance
Cameron Guenther, Ph.D.
2005 Nov 21
3
Warning message help
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 warning message
Warning message:
number of items to replace is not a multiple of replacement length
Can
2005 Oct 18
3
Repeating lines in a data frame
Hello,
I have a much larger dataset that is similar in form to:
year species length count
1998 1 150 1
1998 2 200 1
1998 3 250 2
1999 1 150 3
1999 2 200 4
1999 3 250 5
2000 1 150 1
2000 2 200 1
2000 3 250 1
2001 1 150 2
2001 2 200 3
2001
2006 Mar 27
1
Glm poisson
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: couldn't find function "df.null"
When I do:
>
2006 Sep 26
1
How to "Pack" a matrix
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 1 1 1 0 1
site5 0 0 1 0 0 1
site6 0 0 1 0 1 0
And I want to pack that matrix so that the upper left corner contains
most of the ones and the bottom right corner contains most of the zeros
so that matrix b is
b= sp3 sp6 sp4 sp1 sp2 sp5
site1 1 1 1 1 0 0
site2
2006 Apr 06
1
Evaluating a function with another function
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]
}
return(data.frame(rangit,y,p))
}
And returns the following:
rangit y p
1
2006 Sep 19
1
-Need help with function
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
Bt[i+2]<-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i]. I don't quite understand why
since it should be
2006 Sep 20
1
help with function
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
Bt[i+2]<-(1-m)*Bt[i+1]+Rt[i]*Rerr-Ct[i]. I don't quite understand why
since it should be
2005 Nov 10
2
IF/Else
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) {bioden=Biomass/4120}}
else {if (Gear==170) {bioden=Biomass/2210}}
else {if (Gear==300)
2006 Nov 28
5
Counting zeros in a matrix
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
Sum
1 1 1 1 0 1 1 1 1 1
1 1 1 0 1 0 1 0 0 2
1 0 1 0 0 1 0 0 0 2
1 1 0 0 0 0 1
2006 Nov 30
3
Expression
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 I
get a syntax error.
I can't seem to find anything in the help files that explains it.
2005 Oct 25
1
file size limit for importing SAS file
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",
+ sascmd=file.path(sashome,"sas.exe")
2007 Mar 05
1
Matrix/dataframe indexing
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<- age1 age2 age3
Yr1 1 0.4 0.16
Yr2 1.5 0 0
Yr3 0.9 0 0
Yr4 1 0 0
Yr5 1.2 0 0
Yr6 1.4 0 0
Yr7 0.8 0 0
Yr8 0.6 0 0
Yr9 1.1 0 0
Now the rest of the cells need to be filled according to the previous
year and age
2012 Apr 03
2
Grouping and/or splitting
I have a dataframe imported from csv file below:
Houseid,Personid,Tripid,taz
1,1,1,4
1,1,2,7
2,1,1,96
2,1,2,4
2,1,3,2
2,2,1,58
There are three groups identified based on the combination of first and
second columns. How do I split this data frame?
I tried
aa <- split(inpfil, inpfil[,1:2])
but it has problems.
Output desired is
aa[1]
Houseid,Personid,Tripid,taz
1,1,1,4
1,1,2,7
aa[2]
2008 Oct 30
1
Trying to "expand" some data - Newbie needs help
I want to calculate "expansion factors" for elements in my dataframe
based on a 2-d cross classification. Since I'll have "missing values"
(many combinations will have no record) I'll need a second "expansion
factor" for each "row". I've included my "work to date" below, but I'm
not very close to getting this right.
My
2010 Feb 05
2
glm models with more than one response
Hi everyone,
I am trying to construct a glm and am running into a couple of questions.
The data set I am using consists of 6 categories for the response and 6
independent predictors representing nutrient concentrations at sample point
locations. Ultimately I'd like to use the probabilities for each response
category in a simulation model such that these probabilities are used to
define a