mercredi 23 septembre 2020

How to build data.frame from text contained in one single column?

The issue is a single row of data that needs to be formatted into a R data.frame with appropriate columns to store the row data into column data. The original data is format is a text file with 2 rows of headers, and N rows of data. The data is in a single column. It needs to be formatted into separate columns. Basically, how to split text from each single column to columns into a new data.frame?

INPUT EXAMPLE:

The input contains, for example, two rows which consists of a combined 1) header names, 2) sub-header names, and then N number of rows that contain one single column with all the data, e.g., RD,I,01,027,0001,88101,1,7,105,120,19990103,00:00....

OUTPUT EXPECTATION

A new R data.frame which would have column headers (sub-header) and columns that would be parsed from the single column data rows. For example: one single column data row looks like this: RD,I,01,027,0001,88101,1,7,105,120,19990103. But this single column data would need to be formatted into separate data columns.

A view of this resource from the R Studio environment, is below image.

large single row data

Aucun commentaire:

Enregistrer un commentaire