I need to create a function in R that transforms all entries of a dataframe, which are character strings, into integers, according to a previouly determined "translation code".

**Sample of input data:**

```
Question 1          Question 2    Question 3

Strongly Agree      Agree         Disagree

Strongly Disagree   Neutral       Don't Know

```

The dataset I'll work with will have over 1000 lines and 50 columns. Each answer needs to be translated into an integer value. The formula for translation is:

> 
> Strongly disagree = 1, Disagree = 2, Neutral = 3, Agree = 4, Strongly agree
>  = 5, Don't know = 0.
> 
> 
> 

**So the function output over this sample data would be**

```
Question 1  Question 2  Question 3

5           4           2

1           3           0

```

**My function attempt:**

```
transform <- function(x)

{
  for (i in x[i, ]

  {
  if (i == 'Discordo fortemente')  {i == 1}
  if (i == 'Discordo')  {i == 2}
  if (i == 'Não concordo nem discordo') {i == 3}
  if (i == 'Concordo')  {i == 4}
  if (i == 'Concordo fortemente')  {i == 5}
  if (i == 'Não sei dizer')  {i == 0}
  }

}

```

The language above is portuguese. Obviously the code doesn't work and I have been banging my head against the wall for nearly 2 hours. Any solution to my problem is welcome, although my idea is to build a function that works for one column, then use it with lapply.