[R] R truncating decimal places

2017-05-22 Thread Andrea Goijman
Hello list, I' trying to estimate a log likelihood function from my data. I apply the mean to all my simulations, and I get something like this: apply(likelihood, c(2, 3, 4), mean,na.rm=TRUE) , , 1 [,1] [,2] [,3] [,4] [,5][,6] [,7] [1,] 0.73162327 0.

Re: [R] Aggregate rows with same fields, within factors

2013-09-16 Thread Andrea Goijman
t; 16 C1 B1 BB1 NEUROPTERA 1 > 17 C1 B1 BB1 ORTHOPTERA 2 > 18 C1 B1 B B3 ORTHOPTERA 1 > > > A.K. > > - Original Message - > From: Andrea Goijman > To: R help > Cc: > Sent: Monday, September 16, 2013 11:09 AM > Sub

[R] Aggregate rows with same fields, within factors

2013-09-16 Thread Andrea Goijman
Dear R list, I want to aggregate the number of individuals 'IND' of the same ORDER, within each site and season CAMP,TRANS... but I also want to keep record of the habitat HAB and LOTE For example I have this: CAMP LOTE HAB TRANS IND ORDEN 1765 C1 B1 BB1 7 HEMIPTERA

Re: [R] Problems using lmer {lme4}

2013-05-17 Thread Andrea Goijman
here is I'm not sure this is what you mean to do... If you > could way simplify your example (for example, by including a small > number of mock observations with only the relevant variables, in a > table instead of in R syntax), that would be helpful. > > Patrick > &g

[R] Problems using lmer {lme4}

2013-05-17 Thread Andrea Goijman
Dear R list, I'm attaching a sample of my data which consists on the presence/absence ("punto6", binomial n=5 occasions) of different species ("sp"), on different sites ("site") within routes ('route"). First, I want to be able to find if there is autocorrelation of the response variable between

Re: [R] Changing frequency values to 1 and 0

2013-01-16 Thread Andrea Goijman
t; # 1115 1 0 2 2 1 > # 1116 2 3 0 1 0 > 2051 0 0 0 0 0 > library(plyr) > aaply(y,1,function(x) {x[x>1]<-1;x}) > #, , guild = gui4b > # > # Rep > #Site 1 2 3 4 5 > # 1086 0 0 0 0 0 > # 1112 0 0 0 0 0 > # 1115 0 0 0 0 0 > # 1116 0 0 1 1 1 >

Re: [R] Changing frequency values to 1 and 0

2013-01-16 Thread Andrea Goijman
Sure! Although I'm not sure how to use dput() Here is more detail and some data what I want is that the repetitions in Y (at the end) only have 1 or 0... > library(reshape) > library(car) > > ###Read in the occurence data > occ.data <- read.table("Occ_short.csv", header=TRUE,sep=",",na.string

[R] Changing frequency values to 1 and 0

2013-01-16 Thread Andrea Goijman
Dear list, I'm working with a large data set, where I grouped several species in one group (guild). Then I reshaped my data as shown below. Now, I just want to have "Rep" only as 1 or 0. I'm not being able to change the values of rep>=1 to 1... tried many things and I'm not being successful! >

Re: [R] help "reshaping" dataframe

2013-01-05 Thread Andrea Goijman
(reshape2) flat.occ<-dcast(occ.data1,Año+Site+Especie+Pres~Rep,value.var="Rep") flat.occ[,-c(1:4)]<-sapply(flat.occ[,-c(1:4)],function(x) as.integer(is.na (x))) flat.occ[1:10,] On Sat, Jan 5, 2013 at 12:26 AM, Jim Lemon wrote: > On 01/05/2013 10:15 AM, Andrea Goijman wrote: >

[R] help "reshaping" dataframe

2013-01-04 Thread Andrea Goijman
List, I want to reshape my data, but I'm not sure how to do it... it might be a simple task, but don't know which package does this. "occ.data" (see below) is how my original data are arranged, and I know that with melt() I can reshape it like "y" (see below). However, I just want to build a matri

[R] Listing elements of a 4D array

2012-11-21 Thread Andrea Goijman
Dear list, I'm having trouble to see how my elements on a 4 dimensional array are listed. For example, I generated the following array: junk.melt=melt(occ.data,id.var=c("Especie", "Site", "Rep", "Año"), measure.var="Pres") y=cast(junk.melt, Site ~ Rep ~ Especie ~ Año) Now, I want to be able to

Re: [R] Fwd: Simulate nested data

2012-11-09 Thread Andrea Goijman
vector of the length of the number of species: > p <- rep(NA, sum(species$groups)) > > # but that isn't clear to me because I'm not sure what you > # mean by species(group1), since there is no species() > # function defined > > > > > On Fri, Nov 9, 2012 at

Re: [R] Fwd: Simulate nested data

2012-11-09 Thread Andrea Goijman
about creating the R > object species. Thus, I changed the name of that R object to > speciesgroups and altered your code so that it runs by removing the > erroneous c(). > > Did you try my suggestion, and did or did it not help your problem? > > Sarah > > On Fri, Nov

Re: [R] Fwd: Simulate nested data

2012-11-09 Thread Andrea Goijman
ou're trying to use c() on something that's already a vector. > > Sarah > > On Fri, Nov 9, 2012 at 2:16 PM, Andrea Goijman > wrote: > > I know this seems like a very easy question (and maye it is) but I've > been > > trying to simulate nested data and be

[R] Fwd: Simulate nested data

2012-11-09 Thread Andrea Goijman
I know this seems like a very easy question (and maye it is) but I've been trying to simulate nested data and been unsucessful so far.. I want to simulate a varying number of species within a group; and then create an array to store the results of my for-loop. For example: groups<-3 species$group

Re: [R] Presence/ absence data from matrix to single column

2012-10-08 Thread Andrea Goijman
reshape(dat1,varying=4:6,v.name > ="Sp-value",times=colnames(dat1)[4:6],timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long") > #or > reshape(dat1,varying=4:6,v.name > ="Sp-value",times=names(dat1)[4:

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread Andrea Goijman
Ill try this one as well. And I guess the one below is not going to work, because all my species have different names. Thanks! #nms <- names(adat) nms <- c("Year", "Route", "Point", paste0("Sp", 1:250)) pattern <- "^Sp[[:digit:]]+$" whichCols <- grep(pattern, nms) whichNames <- nms[whichCols]

[R] Presence/ absence data from matrix to single column

2012-10-05 Thread Andrea Goijman
I've been trying to reshape this database but haven't succeed at it. I tried using loops but can't get it right. I just want to reshape my database from this matrix, to the one below, with only one column of data. Year Route Point Sp1 Sp2 Sp3 2004 123 123-1 0 1 0 2004 123 123-2 0 1 1 2004 123