Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个包含相同信息的数据框。第一个包含唯一标识符。我想用户dplyr::inner_join按标题匹配。
dplyr::inner_join
不幸的是,其中一个数据框包含 {"} 来表示引号,而另一个仅使用单引号
例如,我想匹配下面显示的两个标题。
The {"}Level of Readiness{"} for HCV treatment The 'Level of Readiness' for HCV treatment
您可以使用 将它们变成单引号gsub,但您需要{"}用单引号和'双引号括起来。请注意,fixed = TRUE将'{"}'其视为文字字符串而不是正则表达式:
gsub
{"}
'
fixed = TRUE
'{"}'
gsub('{"}', "'", 'The {"}Level of Readiness{"} for HCV treatment', fixed = TRUE) # [1] "The 'Level of Readiness' for HCV treatment"