比较两个字符串和不同字符的情况
我正在尝试使用R.根据此比较将“主”字符串与字符串列表进行比较,我希望字符串中的所有字符都与主字符串更改为小写。
例如:主字符串为“ agg”
。将字符串与[“ ATT”,“ AGT”]
进行比较的列表。我想返回[“ att”,“ agt”]
。订单也很重要。因此,[“ GGA”]
应返回[“ GGA”]
。
任何帮助将不胜感激!
I'm trying to compare a "master" string to a list of strings using R. Based on this comparison, I'd like all characters in the string which differ from the master string changed to lowercase.
For example: the master string is "AGG"
. The list of strings being compared to is ["ATT", "AGT"]
. I want to return ["Att","AGt"]
. Order also matters. So ["GGA"]
should return ["gGa"]
.
Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将所有字符首先变成小写,然后将主字符串中的这些字符变成大写。
更新:如果要比较
x
和master
by-daracter,请尝试以下操作:You could turn all characters into lowercase first, and turn those characters in the master string back to uppercase.
Update: If you want to compare
x
andmaster
character-by-character, try this: