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.
Rに次のような列があります。
won <- c("\001", rep("\\0",3), "\001") won \001 \\0 \\0 \\0 \\0 \001
\0または\001の2つの可能な値があります
これらの値を0(\ 0の場合)および1(\ 001の場合)に変更するのが最も効率的なルートは何でしょうか。gsub()は1つのオプションであると確信しています。これが、2つの別々の文字列値を変更する方法であるかどうかは明確ではありません。
この特定のケースの場合:
2 - nchar(won)
別のオプションは次のとおりです。
ifelse(won == "\001", 1, 0)