我正在寻找一种将键值对数据帧转换为“参差不齐”列表的通用方法。
key <- c("1","1","2")
val <- c("101","102","101")
x <- data.frame(key,val)
期望的输出:
[[1]]
[1] "101" "102"
[[2]]
[1] "101"
答案 0 :(得分:1)
我们可以使用$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strpos($url,'this-is-an-example-post') !== false) {
if($_GET['utm_campaign']==testing123 && $_GET['utm_source']==testing456) {
function preserve_qs() {
if (empty($_SERVER['QUERY_STRING']) && strpos($_SERVER['REQUEST_URI'], "?") === false) {
return "";
}
return "?" . $_SERVER['QUERY_STRING'];
}
header("Location: http://example123.com/this-is-an-example-post" . preserve_qs());
exit;
}
}
split
或setNames(split(as.character(x$val), x$key), NULL)
#[[1]]
#[1] "101" "102"
#[[2]]
#[1] "101"
unstack