Question: Criteria - I prefer not to use any additional library, want to perform this with just pure javascript, but happy to use one if needed.

I want to add an additional class to anchor elements which have a query string of 'xyz=negate'. My page typically has more than 200 anchor elements. I am looking for the most efficient way to achieve this. 

The user base for my website still has a decent number of IE 8 (intranet site) and hence looking for the most efficient code. My page has anchor elements which look like the following

```
<a href="http://www.w3schools.com?id=43&xyz=negate">Visit W3Schools.com!</a>
<a href="http://www.w3schools.com?id=47&xyz=nonnegate">Visit W3Schools.com!</a>
<a href="http://www.w3schools.com?id=3&xy=negate">Visit W3Schools.com!</a>
<a href="http://www.w3schools.com?id=42&xyz=negate&yz=external">Visit W3Schools.com!</a>
<a href="http://www.w3schools.com?id=43&xyz=negate">Visit W3Schools.com!</a>

```

I want to add class to the first, fourth and fifth anchor element in the above example.

Answer: 
Having the extra headers will have turned all of your data into factors (or character if you used `stringsAsFactors=FALSE`):

```
dd <- read.table(text="var1    var2    var3    var4
   1       1       1     'ch'
   1       1       1     'ch'
   1       1       1     'ch'
var1    var2    var3    var4
   1       1       1     'ch'
   1       1       1     'ch'
   1       1       1     'ch'
var1    var2    var3    var4")

```

Convert all but last column to numeric (ignore warnings):

```
dd[,1:3] <- lapply(dd[,1:3],
                    function(x) as.numeric(as.character(x)))

```

Throw away rows where the first three columns are `NA`:

```
dd <- dd[apply(dd[,1:3],1,function(x)!all(is.na(x))),]

```
You can try this:

```
df[,1:3] <- sapply(df[,1:3], function(x) as.integer(as.character(x)))
df <- df[complete.cases(df),]

```