实际上,我想根据列Region更改数据框。
我想检查列地区,如果有任何文字在列房子“!英国”在区域中,并为此添加一个新行,并粘贴文本在新行中的列房子。
library(tidyverse)
df <- tibble(Region = c("AU","USA","CA","USA","!UK","AU","USA","CA","!UK"),
lock = c(1,1,NA,1,NA,1,NA,1,NA),
type= c("sale",NA,NA,"target","target",NA,"sale",NA,"target"),
House =c("Tagore house","Gandhi house",NA,"Flexible;Tagore house;Gandhi house","Tagore house",NA,"Flexible;Gandhi house","Gandhi house","Gandhi house"))
1条答案
按热度按时间6jygbczu1#
我推断行顺序很重要。既然你没有任何暗示,我们将添加一个。
如果需要的话,可以使用
select(-rn)
(我保留它只是为了解释)。