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.strings=TRUE) #occ data from 2007-2008 > occ.data[1:30,] Año Punto Especie Pres Ruta_com Point Site Rep 1 2012 30 TYSA 1 108 30 1086 5 2 2012 26 VACH 1 108 26 1086 1 3 2012 27 VACH 1 108 27 1086 2 4 2012 26 ZEAU 1 108 26 1086 1 5 2012 27 ZEAU 1 108 27 1086 2 6 2012 28 ZEAU 1 108 28 1086 3 7 2012 30 ZEAU 1 108 30 1086 5 8 2012 7 TYSA 1 111 7 1112 2 9 2012 6 ZEAU 1 111 6 1112 1 10 2012 10 ZEAU 1 111 10 1112 5 11 2012 24 TYSA 1 111 24 1115 4 12 2012 23 VACH 1 111 23 1115 3 13 2012 21 ZEAU 1 111 21 1115 1 14 2012 23 ZEAU 1 111 23 1115 3 15 2012 24 ZEAU 1 111 24 1115 4 16 2012 25 ZEAU 1 111 25 1115 5 17 2012 28 AMHU 1 111 28 1116 3 18 2012 29 AMHU 1 111 29 1116 4 19 2012 30 AMHU 1 111 30 1116 5 20 2012 27 TYSA 1 111 27 1116 2 21 2012 26 VACH 1 111 26 1116 1 22 2012 27 VACH 1 111 27 1116 2 23 2012 26 ZEAU 1 111 26 1116 1 24 2012 27 ZEAU 1 111 27 1116 2 25 2012 29 ZEAU 1 111 29 1116 4 26 2012 28 ZOCA 1 111 28 1116 3 27 2012 29 ZOCA 1 111 29 1116 4 28 2012 30 ZOCA 1 111 30 1116 5 29 2012 5 AMHU 1 205 5 2051 5 30 2012 3 SILU 1 205 3 2051 3 > > ######################################## > ###### RECODE SPECIES INTO GUILDS > ######################################### > > occ.data$guild<- recode(occ.data$Especie, "c('AMHU','SILU','ZOCA')='gui4b';else='OTHER'") > occ.data[1:30,] Año Punto Especie Pres Ruta_com Point Site Rep guild 1 2012 30 TYSA 1 108 30 1086 5 OTHER 2 2012 26 VACH 1 108 26 1086 1 OTHER 3 2012 27 VACH 1 108 27 1086 2 OTHER 4 2012 26 ZEAU 1 108 26 1086 1 OTHER 5 2012 27 ZEAU 1 108 27 1086 2 OTHER 6 2012 28 ZEAU 1 108 28 1086 3 OTHER 7 2012 30 ZEAU 1 108 30 1086 5 OTHER 8 2012 7 TYSA 1 111 7 1112 2 OTHER 9 2012 6 ZEAU 1 111 6 1112 1 OTHER 10 2012 10 ZEAU 1 111 10 1112 5 OTHER 11 2012 24 TYSA 1 111 24 1115 4 OTHER 12 2012 23 VACH 1 111 23 1115 3 OTHER 13 2012 21 ZEAU 1 111 21 1115 1 OTHER 14 2012 23 ZEAU 1 111 23 1115 3 OTHER 15 2012 24 ZEAU 1 111 24 1115 4 OTHER 16 2012 25 ZEAU 1 111 25 1115 5 OTHER 17 2012 28 AMHU 1 111 28 1116 3 gui4b 18 2012 29 AMHU 1 111 29 1116 4 gui4b 19 2012 30 AMHU 1 111 30 1116 5 gui4b 20 2012 27 TYSA 1 111 27 1116 2 OTHER 21 2012 26 VACH 1 111 26 1116 1 OTHER 22 2012 27 VACH 1 111 27 1116 2 OTHER 23 2012 26 ZEAU 1 111 26 1116 1 OTHER 24 2012 27 ZEAU 1 111 27 1116 2 OTHER 25 2012 29 ZEAU 1 111 29 1116 4 OTHER 26 2012 28 ZOCA 1 111 28 1116 3 gui4b 27 2012 29 ZOCA 1 111 29 1116 4 gui4b 28 2012 30 ZOCA 1 111 30 1116 5 gui4b 29 2012 5 AMHU 1 205 5 2051 5 gui4b 30 2012 3 SILU 1 205 3 2051 3 gui4b > > ############################################# > ####The detection/non-detection data is reshaped into a four dimensional > #array "y" where the first dimension, j, is the point; the second > #dimension, k, is the rep; the third dimension, i, is the guild; and the last > #dimension t, is the year > > junk.melt=melt(occ.data,id.var=c("guild", "Site", "Rep", "Año"), measure.var="Pres") > y=cast(junk.melt, Site ~ Rep ~ guild ~ Año) Aggregation requires fun.aggregate: length used as default > y , , guild = gui4b, Año = 2012 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 2 2 2 2051 1 0 1 1 3 2055 1 0 0 3 2 2056 0 1 1 0 0 , , guild = OTHER, Año = 2012 Rep Site 1 2 3 4 5 1086 2 2 1 0 2 1112 1 1 0 0 1 1115 1 0 2 2 1 1116 2 3 0 1 0 2051 2 3 1 1 3 2055 1 2 2 1 0 2056 1 2 1 1 0 [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.