R - remove HTML tags from Dataframe

Viewed 46

I want to remove specific words from a column of my Dataframe in R. Such words include the following (but not limited to these):

div class="
;/div>;/div>;/div>;div
">;p>

How can I do that? I tried some of the other questions in the forum but I get some errors while executing.

The column entries I have look like this:

&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-source-link field-type-link-field field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;http://ec.europa.eu/social/main.jsp?langId=en&amp;amp;catId=89&amp;amp;newsId=2889&amp;amp;furtherNews=yes&quot; target=&quot;_blank&quot;&gt;Employment: Report confirms effectiveness of EU Globalisation Fund&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description> &lt;p&gt;This proves once again that EU funding, such as the Globalisation Adjustment Fund, can make a difference, especially for the most vulnerable people in our societies.&lt;/p&gt; &lt;p&gt;These positive results are encouraging, especially given the difficult context in which they have been achieved. The labour market situation in some EU countries was particularly challenging in the period covered by the report. Mass lay-offs occurred in territories that were already suffering from above average unemployment rates. Many supported workers were low-skilled or had other disadvantages as jobseekers.&lt;/p&gt; &lt;p&gt;&lt;!-- VIDEO FILTER - INVALID CODEC IN: [video:http://europa.eu/!Df66FB] --&gt;&lt;/p&gt; &lt;p&gt;EU countries also reported that the personal situation, employability and self-confidence of the workers concerned had visibly improved thanks to the Globalisation Adjustment Fund assistance and services. This was even the case for those who had not found new work immediately after the end of the measures.&lt;/p&gt; &lt;p&gt;9,072 workers, or close to half of the workers who participated in the Globalisation Adjustment Fund measures, had found new jobs or were self-employed after one year, at the end of the implementation period of the measures. An additional 645 people were at that time in education or training to increase their future employability.&lt;/p&gt; &lt;p&gt;European Commissioner for Employment, Social Affairs, Skills and Labour Mobility Marianne Thyssen,said: &quot;Today&#039;s results demonstrate the added value of the Globalisation Adjustment Fund in helping redundant workers who have difficulties to find a new job. The assistance worth €70 million of the Fund has paid off: in 2015 and 2016, 9,072assisted workers were re-employed, despite the challenging labour market situation these people faced. This year&#039;s tenth anniversary of the Globalisation Adjustment Fund marks it as a proof of European solidarity to workers falling victim to mass lay-offs caused by globalisation or the crisis.&quot;&lt;/p&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;The report reaffirms the role of the Fund as a flagship demonstration of European solidarity within the limits of its set-up and budgetary availabilities, having helped close to 19,500 workers to adjust to changing trade patterns and consequences of the economic and financial crisis in that period..&lt;/p&gt; &lt;p&gt;&lt;img src=&quot;http://ec.europa.eu/social/BlobServlet?mode=displayPicture&amp;amp;photoId=9897&quot; /&gt;&lt;/p&gt;     <description>&lt;div class=&quot;field field-name-title-field field-type-text field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;European Commission on Employment: Report confirms effectiveness of EU Globalisation Fund&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-date field-type-datetime field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;span class=&quot;date-display-single&quot; property=&quot;dc:date&quot; datatype=&quot;xsd:dateTime&quot; content=&quot;2017-10-31T00:00:00+01:00&quot;&gt;Tuesday, October 31, 2017&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-summary field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;The Commission has published its report on the performance of the European Globalisation Adjustment Fund (EGF) in 2015 and 2016.&lt;/p&gt;     <description>&lt;div class=&quot;field field-name-title-field field-type-text field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;European Commission on Employment: Report confirms effectiveness of EU Globalisation Fund&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-date field-type-datetime field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;span class=&quot;date-display-single&quot; property=&quot;dc:date&quot; datatype=&quot;xsd:dateTime&quot; content=&quot;2017-10-31T00:00:00+01:00&quot;&gt;Tuesday, October 31, 2017&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-summary field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;The Commission has published its report on the performance of the European Globalisation Adjustment Fund (EGF) in 2015 and 2016.&lt;/p&gt;

I want to remove all the elements such as &lt;/div&gt; etc.

1 Answers

You can use stringr.

library(stringr)

str_remove_all("&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;", 
               "&lt;/div&gt")

# [1] ";;;&lt;div class=&quot;"

Related