Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在r中提取给定url字符串中的项目和产品ID_R - Fatal编程技术网

如何在r中提取给定url字符串中的项目和产品ID

如何在r中提取给定url字符串中的项目和产品ID,r,R,如何从r中给定的url字符串中提取项目id和产品id 解析URL是大多数企业语言已经有了特殊的库来处理的事情,R也不例外。R有一个库,可在以下方面提供帮助: url <- "http://www.exploratorystore.io/cart.do?action=addtocart&itemId=EST-12&categoryId=STRATEGY&productId=DC-SG-G02" parameter_values <- param_get(url,

如何从r中给定的url字符串中提取项目id和产品id

解析URL是大多数企业语言已经有了特殊的库来处理的事情,R也不例外。R有一个库,可在以下方面提供帮助:

url <- "http://www.exploratorystore.io/cart.do?action=addtocart&itemId=EST-12&categoryId=STRATEGY&productId=DC-SG-G02"
parameter_values <- param_get(url, c("itemId", "productId"))

urlA
base R
选项是使用
regmatches/gregexpr

regmatches(str1, gregexpr("(?<=itemId\\=)[^&]*|(?<=productId\\=)[^&]*",
           str1, perl = TRUE))[[1]]
#[1] "EST-12"    "DC-SG-G02"

regmatches(str1,gregexpr(“(?好的,谢谢!现在我想把这些ID存储在colnames项和产品的数据框中…如何使用dplyr实现这一点。。
 str1 <- "http://www.exploratorystore.io/cart.do?action=addtocart&itemId=EST-12&categoryId=STRATEGY&productId=DC-SG-G02"