Re: [R-sig-eco] How to remove space among columns

2013-03-27 Thread Bret Collier
l=data.frame(col1=c(0,1,0), col2=c(1,0,1), col3=c(1, 0, 1), col4=c(0, 0, 
1), col5=c("a", "a", "b"), col6=c("c", "d", "d"))

ll=paste(l$col1, l$col2, l$col3, l$col4, sep="")
data.frame(ll, a=l$col5, b=l$col6)

see ?paste

bret

On 3/27/2013 8:15 AM, Manuel Spínola wrote:

Thank you very much to all that answered my question, some one of you asked
me to be more specific, here is my question again:

I hava a data frame:

col1  col2 col3 col4 col5 col6
01  1 0 ac
10  0 0 ad
01  1 1 bd

I want to end with a data frame like this (the first 4 columns without
space):

0110 ac
1000 ad
0111 bd


Best,

Manuel



2013/3/26 Roman Luštrik 


How do you want to remove the space, so that when you print a data frame
that the columns are closer together? Pr perhaps you're trying to merge
column names into a single string? Perhaps something third? Can you expand
your answer?

Cheers,
Roman



2013/3/27 Manuel Spínola 


Dera list members,

How to remove spaces among columns in a data frame.

1 2 3 4  to become 1234

Best,

Manuel

--
*Manuel Spínola, Ph.D.*

Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.ac.cr
mspinol...@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río <
https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS 

 [[alternative HTML version deleted]]


___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology





--
In God we trust, all others bring data.







___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Recode several variables with conditions in a data frame

2012-07-03 Thread Bret Collier
Not very elegant or efficient, but for only a couple of columns needing 
left out something simple like this should work.


xx=data.frame(x=c(2, 10), y=c(2, 0), z=c(4, 3))
yy=xx[,2:3]
yy[yy!=0]=1
data.frame(x=xx[,1], yy)

bret



On 7/3/2012 9:18 PM, Manuel Spínola wrote:

Thank you Bret.

What if I need to leave out some variables from my data frame.  I have 22
variables and I need to leave the 2 first variables out of the condition.

Best,

Manuel

2012/7/3 Bret Collier 


Manuel,
Something like this should work for your example.

xx=data.frame(x=c(2, 10), y=c(2, 0))
xx[xx!=0]=1
xx
   x y
1 1 1
2 1 0

Bret


On 7/3/2012 8:12 PM, Manuel Spínola wrote:


Dear list members,

I want to recode a data frame but do it for several variables at the same
time.  I want to give all the values > or equal than 1 a value of 1 and
all
the remaining values (0) keep in 0.

data.frame: newdf

var1 var2 var3 var4
A   1  0 4
B   3  2 1
C   0  5 1

My real data frame has several more variables.

I am using the recode function from the epicalc package:

  recode(vars=newdf[, 2:4], old.value= newdf[, 2:4] >= 1, new.value=1)




Error en recode.default(vars = newdf[, 2:4], old.value = newdf[, 2:4] >=
  :
objeto '.data' no encontrado

I guess I am not setting the condition in a proper way.

Best,

Manuel



__**_
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/**listinfo/r-sig-ecology<https://stat.ethz.ch/mailman/listinfo/r-sig-ecology>



__**_
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/**listinfo/r-sig-ecology<https://stat.ethz.ch/mailman/listinfo/r-sig-ecology>







___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Recode several variables with conditions in a data frame

2012-07-03 Thread Bret Collier

Manuel,
Something like this should work for your example.

xx=data.frame(x=c(2, 10), y=c(2, 0))
xx[xx!=0]=1
xx
  x y
1 1 1
2 1 0

Bret

On 7/3/2012 8:12 PM, Manuel Spínola wrote:

Dear list members,

I want to recode a data frame but do it for several variables at the same
time.  I want to give all the values > or equal than 1 a value of 1 and all
the remaining values (0) keep in 0.

data.frame: newdf

var1 var2 var3 var4
A   1  0 4
B   3  2 1
C   0  5 1

My real data frame has several more variables.

I am using the recode function from the epicalc package:


recode(vars=newdf[, 2:4], old.value= newdf[, 2:4] >= 1, new.value=1)


Error en recode.default(vars = newdf[, 2:4], old.value = newdf[, 2:4] >=  :
   objeto '.data' no encontrado

I guess I am not setting the condition in a proper way.

Best,

Manuel



___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Help with nonlinear population trends & binomialregression

2010-12-17 Thread Bret Collier

Matt,
Check out the SemiPar package maintained by Matt Wand and see the book: 
Semiparametric Regression.  2003, Ruppert, Wand, and Carroll.  There are 
some nice code in the book and  online for Bayesian logistic modeling 
using penalized splines as well.


Bret

On 12/17/2010 3:04 AM, Alexandre Villers wrote:

Hey Matthew,

You should have a look at the Zuur et al. 2009 and the chapter 6 dealing
with Violation of Independance (page 143). They explain how to fit GAMMs
for different locations (species in your case). You can select models
through AIC (but I guess you have to be pretty cautious with this type
of model in model selection process).
You should also consider adding a temporal correlation structure given
you have times series (this is also explained in this book).

HTH

Alex

On 17/12/2010 10:55, Aitor Gastón wrote:

Matthew,

A more flexible model may be a better option than fitting two separate
lines (e.g. restricted cubic splines, rcs function of the rms package
or a generalized additive model, mgcv package). A restricted cubic
spline with 4 knots may be enough to model the response curve that you
describe.

Hope that helps,

Aitor


--
From: "Matthew Forister" 
Sent: Friday, December 17, 2010 7:19 AM
To: 
Subject: [R-sig-eco] Help with nonlinear population trends &
binomialregression


Hello, I'm hoping someone can point me in a new direction with this
particular issue...

I have count data for many species across 20-30 years. I know that many
species are declining, probably in association with habitat
destruction, and
I have been using binomial regression to model the declines
(e.g. glm(cbind(presence,visits-presence)~years,binomial). I have
also used
the glm.binomial.disp function for overdispersion. So far so good, but
here's the issue: not all species decline in the same way...

Some go down steadily over the years, while others will be holding
steady
and then suddenly start on a decline. There are other patterns, but
those
two are dominant and I would like to be able to say that different
species
have these different dynamics. But how do I quantify those different
curves? I have played with fitting quadratic and cubic terms within the
binomial
regression (e.g.
glm(cbind(presence,visits-presence)~years+I(years^2),binomial)),
and then comparing models with AIC to think about the better fit of the
model with the quadratic. That kinda makes sense for some species,
but it's
far from satisfying... In the case I described (a species holding
steady for
2 decades and then going into a steady decrease for another 10), what it
really looks like is two different lines, one flat and one precipitous.

Is there a way to ask if a given relationship is better fit by two lines
than one? any other hints on how to describe these kinds of dynamics?

thanks!
Matt


--
Matthew L Forister
Assistant Professor
Department of Biology / MS 314
1664 N. Virginia St.
University of Nevada, Reno
Reno, Nevada 89557
--
E-mail: foris...@gmail.com
Office phone: (775) 784 - 6770
Lab phone: (775) 784 - 7083
Fax: (775) 784 - 1302
Office: room 257 Fleischmann Agriculture Building
--
Webpage:
https://sites.google.com/site/greatbasinbuglab/
--

[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology





___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Multi-state models

2008-09-06 Thread Bret Collier

Krzysztof,
I probably just beat Jeff to it, but you should look into RMark, it is 
an interface to MARK using R, I use it all the time and it works great, 
help is very detailed, and multi-strata models are implemented in it.


http://www.phidot.org/software/mark/rmark/


Bret

Krzysztof Sakrejda-Leavitt wrote:

Dear colleagues,

I am am starting work on a project using multi-state models based on 
capture-mark-recapture data to create parameter estimates for matrix 
population models.  The software the group is currently using is MSurge, 
but I am interested in packages within R which would substitute for that 
function.  I am aware of pomp and msm, but i have experience with 
neither.  Any comments on functionality and robustness in real 
applications (or in testing) would be appreciated, especially coming 
from anyone who has also worked with MSurge/MARK.

Best,

Krzysztof

--
Krzysztof Sakrejda-Leavitt

Organismic and Evolutionary Biology
University of Massachusetts, Amherst
319 Morrill Science Center South
611 N. Pleasant Street
Amherst, MA 01003

work (cell): 413-325-6555
email: [EMAIL PROTECTED]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology