**Question:** 

How can you use R to remove all special characters from a dataframe, quickly and efficiently? 

**Progress:**

This SO [post](https://stackoverflow.com/questions/21641522/how-to-remove-specific-special-characters-in-r/21641569) details how to remove special characters. I can apply the gsub function to single columns (images 1 and 2), but not the entire dataframe.

**Problem:**

My dataframe consists of 100+ columns of integers, string, etc. When I try to run the gsub on the dataframe, it doesn't return the output I desire. Instead, I get what's shown in image 3.

```
df <- read.csv("C:/test.csv")
dfa <- gsub("[[:punct:]]", "", df$a) #this works on a single column
dfb <- gsub("[[:punct:]]", "", df$b) #this works on a single column
df_all <- gsub("[[:punct:]]", "", df) #this does not work on the entire df
View(df_all)

```

**df** - This is the original dataframe:

[![Original dataframe](https://i.stack.imgur.com/z3EaQ.png)](https://i.stack.imgur.com/z3EaQ.png)

**dfa** - This is gsub applied to column b. Good!

[![gsub applied to column b](https://i.stack.imgur.com/EE1fV.png)](https://i.stack.imgur.com/EE1fV.png)

**df\_all** - This is gsub applied to the entire dataframe. Bad!

[![gsub applied to entire dataframe](https://i.stack.imgur.com/Ciec5.png)](https://i.stack.imgur.com/Ciec5.png)

**Summary:**

Is there a way to gsub an entire dataframe? Else, should an apply function be used instead?