Hi R user, I finally able to send you the table in readable format. I have seen that some of you do send tables in email when asking questions, but why i could not send. Any way some of you helped me to send you the example table in a readable format.
now, I want to concentrate on my problem. I am trying to get the information (dat 3) from dat 1 and 2 in R. I have very big data but these data are just hypothetical data. my data structures are exactly same as dat 1 and dat 2. I created dat 3 and dat4 manually to show what information I wanted to have. I am struggling to figure it out how I can do in R. I think it is not difficult. I hope any one can help me. dat1 is the table of species occurrence (o means species absence, 1 means species presence). dat1 <- structure(list(X = structure(1:4, .Label = c("Plot1", "Plot2", "plot3", "plot4"), class = "factor"), speciesX = c(1L, 0L, 1L, 0L), speciesY = c(0L, 1L, 0L, 0L), speciesZ = c(1L, 1L, 0L, 1L), speciesXX = c(0L, 0L, 1L, 0L)), .Names = c("X", "speciesX", "speciesY", "speciesZ", "speciesXX"), class = "data.frame", row.names = c(NA, -4L)) dat2 is the species tolerances value in each environmental variable dat2 <- structure(list(X = structure(c(1L, 3L, 2L), .Label = c("SpeciesX", "SpeciesXX", "SpeciesY"), class = "factor"), EnviA = c(0.21, 0.1, 0.14), EnviB = c(0.4, 0.15, 0.16), EnviC = c(0.17, 0.18, 0.19)), .Names = c("X", "EnviA", "EnviB", "EnviC"), class = "data.frame", row.names = c(NA, -3L)) ## note (here in dat 2 there is no "species Z" you can see that ) Now, I want to get the average value of tolerances in each grid. like dat 3 the dat3 is based on the column EnviA. dat3 <-structure(list(X = structure(1:4, .Label = c("plot1", "plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.21, NA, NA, 0.21), speciesY = c(NA, 0.1, NA, NA), speciesZ = structure(c(1L, 1L, 1L, 1L), .Label = "Nodata", class = "factor"), speciesXX = c(0.14, NA, 0.14, NA), average = c(0.175, 0.1, 0.14, 0.21)), .Names = c("X", "speciesX", "speciesY", "speciesZ", "speciesXX", "average"), class = "data.frame", row.names = c(NA, -4L)) dat4 is same thing as dat3 but here i used EnviB instead of EnviA. dat4 <- structure(list(X = structure(1:4, .Label = c("plot1", "plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.4, NA, NA, 0.4), speciesY = c(NA, 0.15, NA, NA), speciesZ = structure(c(1L, 1L, 1L, 1L), .Label = "Nodata", class = "factor"), speciesXX = c(0.16, NA, 0.16, NA), average = c(0.28, 0.15, 0.16, 0.4)), .Names = c("X", "speciesX", "speciesY", "speciesZ", "speciesXX", "average"), class = "data.frame", row.names = c(NA, -4L)) I hope you understand my problem and you can help me. Thanks Kristi [[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.