df <- data.frame(topic = c("xxx", "xxx", "yyy", "yyy", "yyy", "zzz", "zzz"),
high = c(52L, 27L, 89L, 99L, 43L, 21L, 90L),
low = c(56L, 98L, 101L, 21L, 98L, 40L, 43L),
stringsAsFactors = FALSE)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
for (variable in unique(df$topic)) {
assign(variable, df %>% filter (topic == variable), envir = .GlobalEnv)
}
xxx
#> topic high low
#> 1 xxx 52 56
#> 2 xxx 27 98
yyy
#> topic high low
#> 1 yyy 89 101
#> 2 yyy 99 21
#> 3 yyy 43 98
zzz
#> topic high low
#> 1 zzz 21 40
#> 2 zzz 90 43
Created on 2019-02-13 by the reprex package (v0.2.1)