Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.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中点后的字符?_R_Dplyr - Fatal编程技术网

如何删除R中点后的字符?

如何删除R中点后的字符?,r,dplyr,R,Dplyr,我有一个类似这样的数据集 df_A <- tribble( ~product_name, ~id, "xyz.com", 1, "bkrk.de", 4, ) df_A另一种方法: library(dplyr) library(stringr) df_A %>% mutate(product_name = str_remove(product_name, '\\..*')) #

我有一个类似这样的数据集

df_A <- tribble(
  ~product_name,   ~id,      
  "xyz.com",         1,  
  "bkrk.de",         4,
)
df_A另一种方法:

library(dplyr)
library(stringr)
df_A %>% mutate(product_name = str_remove(product_name, '\\..*'))
# A tibble: 2 x 2
  product_name    id
  <chr>        <dbl>
1 xyz              1
2 bkrk             4
库(dplyr)
图书馆(stringr)
df_A%>%突变(产品名称=str_移除(产品名称,\\\..*))
#一个tibble:2x2
产品名称id
1 xyz 1
2 bkrk 4
另一种方法:

library(dplyr)
library(stringr)
df_A %>% mutate(product_name = str_remove(product_name, '\\..*'))
# A tibble: 2 x 2
  product_name    id
  <chr>        <dbl>
1 xyz              1
2 bkrk             4
库(dplyr)
图书馆(stringr)
df_A%>%突变(产品名称=str_移除(产品名称,\\\..*))
#一个tibble:2x2
产品名称id
1 xyz 1
2 bkrk 4
library(dplyr)
library(stringr)
df_A %>% mutate(product_name = str_remove(product_name, '\\..*'))
# A tibble: 2 x 2
  product_name    id
  <chr>        <dbl>
1 xyz              1
2 bkrk             4