How can one concisely change a numeric R variable (keeping it numeric) so that, e.g.,
“-0.34” becomes simply “-.34”?
How can one concisely change a numeric R variable (keeping it numeric) so that,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Only when you output a numeric value do you have to choose a concrete representation (i.e., how the number should be formatted). You cannot change a numeric variable from “-0.34” to “-.34”; both are representations for the same number.
However, when you output an expression
e, you can choose how it should be formatted. I don’t know of any build-in way to leave off the leading “0”, but you could always just remove it manually:You can define a function for convenience, e.g.,