similar to: -Need help with function

Displaying 20 results from an estimated 1000 matches similar to: "-Need help with function"

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
2010 Mar 12
5
Vertical subtraction in dataframes
Hello all, I have not been able to find an answer to this problem. I feel like it might be so simple though that it might not get a response. Suppose I have a dataframe like the one I have copied below (minus the 'calib' column). I wish to create a column like calib where I am subtracting the 'Count' when 'stain' is 'none' from all other 'Count' data for
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.
2008 Jan 18
1
Selecting rows conditionally between 2 data.frames
Hello everyone, I have two data.frames that look like calib: place zoom scale left 0.65 8 left 0.80 5.6 left 1.20 3 right 0.65 8.4 right 0.80 6 right 1.20 2.9 X: ... place zoom .... ... left 0.80 .... ... left 1.20 .... ... right 0.65 .... ... NA NA .... ... right 0.8 .... ... left 1.20 .... and I want to get the corresponding values of 'scale' in a new column
2001 Feb 19
2
problems sourcing in vs interactive
If I source in the function (see below) calib(), I get: > source("papers/helle/threshold.r") > calib() Error in eval(expr, envir, enclos) : Object "energy" not found But if I cut and paste the code for calib() one line at a time into the R window it works fine. calib<-function() { contrast<-c(.01,.02,.0325,.055,.0775,.1,.125,.15,.175,.2)
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 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
2006 May 16
3
subset
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 frame. I think I can create a new data frame without the duplicates using subset. I have tried:
2008 Aug 16
4
Lattice: problem using panel.superpose and panel.groups
Hi. I'm embarking on my first attempt at creating my own panel function for lattice graphics, and despite all of my online research and pouring through the documentation, I cannot figure out how to solve my particular problem. Hopefully, a generous fellow R user can help. I have some data that is split into two groups: some "actual" data, and some simulated data,
2002 May 15
1
ploting a linear model
Hi I have the result of a linear model "lm98" and I want to plot it to analyse the regression but I'm getting the folowing error message > lm98<-lm(log(U+1)~Bq+Gi+Lv+Tb+Bq:Gi+Bq:Lv+Bq:Tb+Gi:Lv+Gi:Tb+Lv:Bq) > plot(lm98) Error in plot.window(xlim, ylim, log, asp, ...) : need finite ylim values In addition: Warning message: NaNs produced in: sqrt(1 - hii) The
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 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 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 Jul 09
3
acts_as_ferret.. what does it actually do?
Okay in this plea for help I''m going to repeat some of what i posted before but with a larger amount of background info in the hope that i can get a decent grip on ferret before it wriggles away.. Firstly, what does installing the acts_as_ferret plugin actually do? I install it and add it to my model and then the index is automatically generated and a few methods are added to it and
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 Jul 14
3
Whitespace Issues
I am trying to build up a filtered search using the logic below. bq = Ferret::Search::BooleanQuery.new bq.add_query(Ferret::Search::TermQuery.new(Ferret::Index::Term.new("section",section.downcase!)), Ferret::Search::BooleanClause::Occur::MUST) filter = Ferret::Search::QueryFilter.new(bq) @vobjects = VoObject.find_by_contents(search_input,:filter => filter, :sort
2008 May 09
1
Searcher Explain
Hi, I am unable to use the Searcher''s explain method. Anytime I call it, I get Segmentation Faults and it kills the process I have running my Rails site. Has anyone else had this problem? Here is some code I am trying to use it in... search = Search.create(:query => query) @quotations = [] searcher = Ferret::Search::Searcher.new("index") # FerretConfig::INDEX bq =
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