[R] removing part of a string

Vito M. R. Muggeo vito@muggeo @ending from unip@@it
Mon May 21 15:33:49 CEST 2018


dear all,
I am stuck on the following problem. Give a string like

ss1<- "z:f(5, a=3, b=4, c='1:4', d=2)"

or

ss2<- "f(5, a=3, b=4, c=\"1:4\", d=2)*z"

I would like to remove all entries within parentheses.. Namely, I aim to 
obtain respectively

"z:f()" or "f()*z"

I played with sub() and gsub() but without success..
Thank you very much for your time,

best,
vito


-- 
==============================================
Vito M.R. Muggeo
Dip.to Sc Econom, Az e Statistiche
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 23895240
fax: 091 485726
http://dssm.unipa.it/vmuggeo
Associate Editor, Statistical Modelling
Chair, Statistical Modelling Society



More information about the R-help mailing list