An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20130326/170125a5/attachment.pl>
How to remove space among columns
8 messages · Manuel Spínola, Yu-Chun Kao, Pierre THIRIET +2 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20130327/b97fa237/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20130327/5f7b51c0/attachment.pl>
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 <mspinola10 at 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 0 1 1 0 a c 1 0 0 0 a d 0 1 1 1 b d I want to end with a data frame like this (the first 4 columns without space): 0110 a c 1000 a d 0111 b d Best, Manuel 2013/3/26 Roman Lu?trik <roman.lustrik at 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 <mspinola10 at 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 mspinola at una.ac.cr mspinola10 at 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 at 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 mspinola at una.ac.cr mspinola10 at 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 at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20130327/13fb0f20/attachment.pl>
Manuel, you've been provided by a few alternatives. Here's mine. x <- read.table(text ="col1 col2 col3 col4 col5 col6 0 1 1 0 a c 1 0 0 0 a d 0 1 1 1 b d", header = TRUE) x$newx <- apply(x[, 1:4], 1, paste, collapse = "")
x
col1 col2 col3 col4 col5 col6 newx 1 0 1 1 0 a c 0110 2 1 0 0 0 a d 1000 3 0 1 1 1 b d 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.thiriet at 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 0 1 1 0 a c 1 0 0 0 a d 0 1 1 1 b d I want to end with a data frame like this (the first 4 columns without space): 0110 a c 1000 a d 0111 b d Best, Manuel 2013/3/26 Roman Lu??trik <roman.lustrik at 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 <mspinola10 at 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 mspinola at una.ac.cr mspinola10 at 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 at 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 at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
-- In God we trust, all others bring data.
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 0 1 1 0 a c 1 0 0 0 a d 0 1 1 1 b d I want to end with a data frame like this (the first 4 columns without space): 0110 a c 1000 a d 0111 b d Best, Manuel 2013/3/26 Roman Lu??trik <roman.lustrik at 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 <mspinola10 at 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 mspinola at una.ac.cr mspinola10 at 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 at 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 at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20130327/4e7e586e/attachment.pl>