Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
Variables Mutate不会生成新变量。为什么?_Variables_Error Handling_New Operator_Mutate_Tibble - Fatal编程技术网

Variables Mutate不会生成新变量。为什么?

Variables Mutate不会生成新变量。为什么?,variables,error-handling,new-operator,mutate,tibble,Variables,Error Handling,New Operator,Mutate,Tibble,我想用以下代码生成一个新变量: w1 <- w1_data %>% as_tibble() w1_data_tb %>% mutate(f3roster = if_else(is.na(NameUniFreund1B3.y), NA_real_, 1*grepl("[a-z]", NameUniFreund1B3.y))) %>% select(NameUniFreund

我想用以下代码生成一个新变量:

w1 <- w1_data %>% as_tibble()

w1_data_tb %>% 
          mutate(f3roster = if_else(is.na(NameUniFreund1B3.y), 
                 NA_real_, 1*grepl("[a-z]", NameUniFreund1B3.y))) %>% 
          select(NameUniFreund1B3.y, f3roster)
然而,我的新问题是,即使我使用了mutate,它也不会生成新变量。至少我在数据框中找不到/看不到它

有人能帮忙吗


提前感谢

尽管在第一步中定义了
w1
,但为什么要使用
w1_-tb
?您是否尝试使用
ifelse()
而不是
if\u else()
NAME 1

Name 0

NA NA