[R] transposing a column table

Joshua Wiley jwiley.psych at gmail.com
Fri Oct 29 04:00:15 CEST 2010


Hi Penny,

If I understand you correctly, you have a vector, and you want it to
be a column in an Excel file with 8768 rows (one for each entry).
Easy ways to transport data from R to Excel are with the write.csv
function.  For example:

write.csv(x = data.frame(myclustfactor = 1:10), file = "yourfilename.csv")

I just created a column called "myclustfactor" that consists of 1 -
10.  Since your data is already in a vector, you could just do
something like data.frame(yourdata) or data.frame(columnname =
yourdata) so that it would have a nice name.

HTH,

Josh

On Thu, Oct 28, 2010 at 6:51 PM, Penny Adversario <penadv at yahoo.com> wrote:
> Dear R-user,
> I need help on how to transpose this column of clustering vector in R with 8768 entries derived from a PAM clustering output in a vertical  view to an excel file
>
> Clustering vector:
>    [1] 1 1 2 2 1 2 1 2 1 1 2 2 1 2 2 2 2 1 1 1 1 2 2 1 2 2 1 2 2 2 2 2 2 2 2 1 2
>   [38] 2 1 1 2 2 2 2 2 1 2 1 2 2 2 2 1 2 1 2 2 1 2 2 2 2 2 2 1 2 1 2 2 2 1 1 2 2
>   [75] 2 1 2 2 2 2 2 2 2 1 1 2 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 2 2 1 2 2 2 1 2 2
>  [112] 1 1 1 2 2 1 2 1 2 2 2 2 1 2 2 1 2 2 1 2 1 2 1 2 1 2 2 1 2 2 2 2 1 2 2 1 2
> .
> .
> .
> .
> [8659] 1 2 2 1 1 2 1 2 2 2 1 2 2 2 1 1 2 1 2 2 2 1 1 1 2 1 1 2 2 2 1 2 1 2 2 2 2
> [8696] 2 1 1 2 1 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 2 2 2 2 2 2 1 2 2 2
> [8733] 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 2 1 2 2 2 2 1 2 2 2 1 2 1 2 2 2 1 2 1 1
>
> Thanks,
> Penny
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.

-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list