[R] Symbols to data set

jim holtman jholtman at gmail.com
Wed Jun 10 16:44:47 CEST 2015


Is this what you want:

> x <- read.table(text = "place          Rupees          Percentage
 Dollars
+ India          120000            52                    48
+ USA          78000              56                    40
+ UK             60000              50                   56"
+     , header = TRUE
+     , as.is = TRUE
+     )
> # add thousands separator
> x$Rupees <- formatC(x$Rupees, big.mark = ',')
> # add percent sign
> x$Percentage <- paste0(x$Percentage, "%")
> # add dollar sign
> x$Dollars <- paste0("$", x$Dollars)
> x
  place  Rupees Percentage Dollars
1 India 120,000        52%     $48
2   USA  78,000        56%     $40
3    UK  60,000        50%     $56
>




Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Wed, Jun 10, 2015 at 8:15 AM, venkadesan venky <venkynov10 at gmail.com>
wrote:

> Hello Friends,
>
> I have a data like this
>
> place          Rupees          Percentage      Dollars
>
> India          120000            52                    48
> USA          78000              56                    40
> UK             60000              50                   56
>
> and i want to make Rupees column as a thousand Separator(Commas) and
> Percentage column as a percentage symbol and Dollars column as a Dollars
> symbols. by using one line command.
>
> please help to find out this
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list