Re: [R] collapse a data column into a row

From: Ista Zahn <izahn_at_psych.rochester.edu>
Date: Wed, 09 Mar 2011 15:49:33 -0500

Hi,

On Wed, Mar 9, 2011 at 3:35 PM, Fahim Mohammad <fahim.md_at_gmail.com> wrote:
> I have a file with a data in columnar format like below:
>
> probeID
> rc_AI104113_at
> rc_AI178259_f_at
> rc_AI179134_i_at
> rc_AI179134_f_at
> rc_AI104113_at
> rc_AA819429_f_at
>
> How can I rewrite it in the  format below:
> 'rc_AI104113_at', 'rc_AI178259_f_at', 'rc_AI179134_i_at',
> 'rc_AI179134_f_at', 'rc_AI104113_at', 'rc_AA819429_f_at'

It's not clear to me what exactly this format is or what you want to do with it (but see below)
>
>
> Is there any function to do this. I can do it by using iterative paste but
> I just want to avoid it for efficiency reason as number of probes is very
> high.

paste() doesn't care how many probes you have:

dat <- read.table(textConnection("probeID

rc_AI104113_at
rc_AI178259_f_at
rc_AI179134_i_at
rc_AI179134_f_at
rc_AI104113_at
rc_AA819429_f_at"), header=TRUE)

closeAllConnections()

cat(paste("'", dat$probeID, "'", sep=""))

Best,
Ista

>
> Thanks
>
> --Fahim
>
>        [[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.
>

-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

______________________________________________
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.
Received on Wed 09 Mar 2011 - 20:55:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Mar 2011 - 21:00:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive