This is a very simple question, so I apologize I couldn't find it online:

I want to shorten the string 'apples.pears' to 'apples'.

string='apples.pears'
string1=substr(string,0,x)

For x above, I would like to have a command like charAt(string,"."), i.e.
the position of the period in the word, but I can't seem to find a charAt
command in R.

Thank you.

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to