我有一个数据框,其中第二列的某些元素放错了位置。例如:
"15365","JAS ONLINE SERVICES PRIVATE LIMITED"
"15366","KRESS ITALIAN FOOD SPECIALTIES PRIVATE LIMITED"
"15367","SHATAYU CRITICARE HOSPITAL AND RESEARCH CENTER PRI
VATE LIMITED"
"15368","WHITE HEARTS FOODIES PRIVATE LIMITED"
"15369","MAAHI LOGISTICS PRIVATE LIMITED"
...
...
"15376","G S LIFE SKILLS EDUCATION WORLDWIDE PRIVATE LIMITE
D"
"15377","RED LINE LOGISTICS PRIVATE LIMITED"
等等。行15367和15376需要编辑。有没有办法在不手动操作的情况下执行此操作?
答案 0 :(得分:0)
只需使用quote
的{{1}}参数即可。假设您在变量read.table
中包含字符串,并希望将结果ds
存储在data.frame
中:
my.df
如果要从结果列中删除换行符,可以使用以下代码,只需将my.df <- read.table(text=ds, sep=",", quote="\"")
替换为要用以及replacement
替换换行符的文本,并使用列名称你的V2
。
data.frame