I am trying to collect the n number of smallest values in a dataset sorted by rank.

Here is my code:

```
testscript <- function(num) {
df <- data.frame(State = paste0("State",sort(rep(1:2,10))),
City = rep(paste0("city",rep(1:10,2))),
Value = runif(n=20))
vec <- NULL
df$Rank <- ave(df$Value, df$State, FUN=rank)
for (i in 1:num) {
vec[i] <- df[df$Rank==[i],]
}
}
```

The argument num is the number of smallest values that I want to collect.

When I run the function, I get the following error:

```
Error: unexpected '[' in:
"for (i in 1:num) {
vec[i] <- df[df$Rank==["
```