I have this code

```
```{r import csv}
gpa2 <- read.csv("~/Dropbox/aktuellaKurser/651econ/datorlabbar/econA2/ddata2.csv")
```
```{r library}
library(ggplot2)
library(stargazer)
library(memisc)
library(ascii)
```
```{r results='asis'}
model1 <- lm(formula = colgpa ~ athlete, data = gpa2)
stargazer(model1, type="html")
```
```

But I want to have this code

```
<<r import csv>>
gpa2 <- read.csv("~/Dropbox/aktuellaKurser/651econ/datorlabbar/econA2/ddata2.csv")
@
<<r library>>=
library(ggplot2)
library(stargazer)
library(memisc)
library(ascii)
@
<<r results='asis'>>=
model1 <- lm(formula = colgpa ~ athlete, data = gpa2)
stargazer(model1, type="html")
@
```

How do I do it? I have tried with regex to

find ```{.+}

replace <<.+>>=

or with * instead of .+

But I don’t get it right.

This is relevant because I want to transition from a knitr-document to a sweave-document.