[R] data reshape

Yuan Chun Ding ycd|ng @end|ng |rom coh@org
Fri Dec 20 03:01:00 CET 2019


Hi R users,

I have a folder (called genotype) with 652 files; the file names are  GTEX-1A3MV.out, GTEX-1A3MX.out, GTEX-1B8SF.out, etc; in each file,  only one column of data without a header as below
201
2/2
238
3/4
245
1/2
.....
983255
3/3
983766
None


A total of 20528 rows;

I need to read all those 652 files in the genotype folder and then reshape the one column in each file as:
SampleID             201        238        245        ....   983255         983766
GTEX-1A3MV     2/2         3/4        1/2                         3/3         None

There are 10264 data columns plus the sample ID column, so 10265 columns in total after data reshaping.

After reading those 652 file and reshape the one column in each file, I will stack them by the rbind function, then I have a file with a dimension of 653 row, 10265 column.


Thank you,

Ding

----------------------------------------------------------------------
------------------------------------------------------------
-SECURITY/CONFIDENTIALITY WARNING-  

This message and any attachments are intended solely for the individual or entity to which they are addressed. This communication may contain information that is privileged, confidential, or exempt from disclosure under applicable law (e.g., personal health information, research data, financial information). Because this e-mail has been sent without encryption, individuals other than the intended recipient may be able to view the information, forward it to others or tamper with the information without the knowledge or consent of the sender. If you are not the intended recipient, or the employee or person responsible for delivering the message to the intended recipient, any dissemination, distribution or copying of the communication is strictly prohibited. If you received the communication in error, please notify the sender immediately by replying to this message and deleting the message and any accompanying files from your system. If, due to the security risks, you do not wish to receive further communications via e-mail, please reply to this message and inform the sender that you do not wish to receive further e-mail from the sender. (LCP301)
------------------------------------------------------------

	[[alternative HTML version deleted]]



More information about the R-help mailing list