Re: [R-sig-eco] How to remove space among columns
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 roman.lust...@gmail.com 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 mspinol...@gmail.com 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 http://www.icomvis.una.ac.cr/ [[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. -- *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 http://www.icomvis.una.ac.cr/ [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] How to remove space among columns
Hi Manuel, You can use the function paste paste(col1,col2.col3,col4, sep = ) in a new data frame. data.frame( col1 = paste(col1,col2.col3,col4, sep = ), col2 = col5, col3 = col6) I think it will work Yu-Chun 2013/3/27 Manuel Spínola mspinol...@gmail.com: 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 roman.lust...@gmail.com 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 mspinol...@gmail.com 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 http://www.icomvis.una.ac.cr/ [[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. -- *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 http://www.icomvis.una.ac.cr/ [[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
Re: [R-sig-eco] How to remove space among columns
Manuel, you've been provided by a few alternatives. Here's mine. x - read.table(text =col1 col2 col3 col4 col5 col6 01 1 0 ac 10 0 0 ad 01 1 1 bd, header = TRUE) x$newx - apply(x[, 1:4], 1, paste, collapse = ) x col1 col2 col3 col4 col5 col6 newx 10110ac 0110 21000ad 1000 30111bd 0111 I opted for a new column, but you can construct your data.frame anyway you want. Cheers, Roman On Wed, Mar 27, 2013 at 2:32 PM, Pierre THIRIET pierre.d.thir...@gmail.com wrote: Hi Manuel, try this combination of paste(), which collapse your variables into a single one, and cbind() for binding this new variable with the others of your initial data frame mat=as.data.frame(matrix(1:18,3,6)) mat2=cbind(newV=with(mat,paste(V1,V2,V3,V4,sep=)),mat[,5:6]) is it what you wanted? cheers, Pierre PS: this kind of questions should go into general R help list Le 27/03/2013 14:15, Manuel Spínola a écrit : 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 roman.lust...@gmail.com 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 mspinol...@gmail.com 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 http://www.icomvis.una.ac.cr/ [[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 [[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
Re: [R-sig-eco] How to remove space among columns
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 roman.lust...@gmail.com 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 mspinol...@gmail.com 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 http://www.icomvis.una.ac.cr/ [[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] Adonis and Random Effects
Hi Steve, You mentioned that nested.npmanova won't test GrasslandPlot correctly for a split-plot design. However, does adonis test GrasslandPlot correctly, since it's using the split-plot error term to test all effects? Here are the formulas again. adonis(community_dist ~ Grassland*Treatment + GrasslandPlot, strata = GrasslandPlot) nested.npmanova(community_dist ~ Grassland + GrasslandPlot) Thank you, Erin On Mar 10, 2013, at 8:17 AM, JOHN S BREWER wrote: Erin, Please check the February 25 post I made called Permanova with nested data. It explains how to test whole plot and split plot effects correctly in adonis. But to answer your question, even if you treat Grassland as a fixed-plot effect (which seems perfectly reasonable), Grassland is a whole-plot effect. Using the model formula given and strata, adonis uses the split-plot error term (i.e., the residual error term) to test all effects. That's wrong because Grassland needs to be tested with the whole-plot error term. In the post I referred to, I describe how you can do a separate test for the whole plot using the BiodiversityR package and the nested.npmanova function. In this case, you would only include Grassland and GrasslandPlot as terms in the model. It's just doing a two-way nested manova. The whole-plot effect of Grassland will be tested correctly using the GrasslandPlot term. GrasslandPlot will be tested with the residual error term, which will be wrong, but you can ! ignore that. I've tried it with my own data and it works. One cautionary note. See the posts by Jari Oksanen and others about the versions of BiodiversityR and R used. Hope this helps Steve From: Erin Nuccio [enuc...@gmail.com] Sent: Saturday, March 09, 2013 9:09 PM To: JOHN S BREWER Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] Adonis and Random Effects Hi Steve and R list, I was hoping you could clarify something you mentioned in previous post. A quick recap... I have a split-plot design where I determined the microbial communities at 3 grasslands (see post script for design). I am trying quantify the how much of my community can be explained by Treatment or Grassland effect. After talking with a statistician, it seems like treating Grassland as a Fixed effect would be reasonable (because I have such a small number of grasslands). You mentioned that if I treat Grassland as a Fixed effect, and use the following formula, the Grassland effect would not be tested correctly: adonis(formula = community_distance_matrix ~ Treatment*Grassland + GrasslandPlot, strata = GrasslandPlot) Why is this? Is there any way to remedy this? Thanks for your feedback, Erin Experimental design: 4 split plots * 2 Treatments * 3 Grasslands = 24 observations Treatment: 2 levels (each within 1 split plot) Grassland: 3 levels GrasslandPlot: 12 levels (4 split plots nested in 3 Grasslands) On Feb 4, 2013, at 6:22 AM, Steve Brewer wrote: Erin, There have been a lot of similar queries (e.g., repeated measures, nested permanova). Jari can correct me if I am wrong, but as far as I know, no one has developed a way to define multiple error terms in adonis. You can use adonis, however, to get the split-plot effects. If you want to make a grassland a random effect, use the following statement adonis(formula = community_distance_matrix ~ Treatment + Grassland + GrasslandPlot, strata = GrasslandPlot) The treatment effect will be correct because the residual error term (which is equivalent to treatment x GrasslandPlot interaction nested within Grassland) is the correct error term. The Grassland effect, however, will not be tested correctly because it is using the residual error term when it should be using GrasslandPLot as the error term. You can determine what the F stat for Grassland should be, however, using the Ms Grassland and MS GrasslandPlot from the anova table to construct the F test. You just won't get a p-value for the test. If you want to treat Grassland as a fixed effect, the model is similar but defines the interaction adonis(formula = community_distance_matrix ~ Treatment*Grassland + GrasslandPlot, strata = GrasslandPlot) In this case, the treatment x grassland interaction will be tested correctly, as will the treatment effect, but not the Grassland effect. Unfortunately, you cannot just take averages of abundances across the treatment and control in each plot and then do a separate analysis of Grassland and GrasslandPLot (unless you're using Euclidean distances). I suspect you're not using Euclidean distances. Hope this helps some. Good luck, Steve J. Stephen Brewer Professor Department of Biology PO Box 1848 University of Mississippi University, Mississippi 38677-1848 Brewer web page - http://home.olemiss.edu/~jbrewer/ FAX - 662-915-5144 Phone - 662-915-1077