Carol.Kar
Carol.Kar

Reputation: 5355

Put unstructured data - each line - in new columns

I have the following unstructured data in a data.frame column:

<a href="https://bitcoin.org/" target="_blank">Website</a>
<a href="https://www.bitcoin.com/" target="_blank">Website 2</a>
<a href="http://blockchain.info" target="_blank">Explorer</a>
<a href="https://blockexplorer.com/" target="_blank">Explorer 2</a>

<a href="https://bitcointalk.org" target="_blank">Message Board</a>
<a href="https://forum.bitcoin.com/" target="_blank">Message Board 2</a>


<small><span class="label label-success"> Rank 1</span></small>
<small><span class="label label-warning">Mineable</span></small>
<small><span class="label label-warning">Currency</span></small>

My goal is to create for every line a new column.

Any suggestions how to do this? I currently have no clear idea about this problem.

Upvotes: 0

Views: 30

Answers (1)

Colin FAY
Colin FAY

Reputation: 5109

You can simply copy and paste your text in a .txt file.

Then call :

library(tidyverse)
a <- readLines("test.txt") %>%
  # Convert to df
  as.data.frame(stringsAsFactors = FALSE) %>%
  # Filter empty rows
  filter(nchar(.) != 0)

Colin

Upvotes: 1

Related Questions