This can be done easily but it convert all of your sales numbers into characters which will be very inconvenient if you need to do further calculations.
library(dplyr)
DF <- data.frame(Name = LETTERS[1:6], Sales = c(55.3, 78.2, 64.9, 0.0, 78.2, 32.1))
DF
#> Name Sales
#> 1 A 55.3
#> 2 B 78.2
#> 3 C 64.9
#> 4 D 0.0
#> 5 E 78.2
#> 6 F 32.1
summary(DF)
#> Name Sales
#> A:1 Min. : 0.00
#> B:1 1st Qu.:37.90
#> C:1 Median :60.10
#> D:1 Mean :51.45
#> E:1 3rd Qu.:74.88
#> F:1 Max. :78.20
DF <- DF %>% mutate(Sales = ifelse(Sales == 0, "-", Sales))
DF
#> Name Sales
#> 1 A 55.3
#> 2 B 78.2
#> 3 C 64.9
#> 4 D -
#> 5 E 78.2
#> 6 F 32.1
summary(DF)
#> Name Sales
#> A:1 Length:6
#> B:1 Class :character
#> C:1 Mode :character
#> D:1
#> E:1
#> F:1
A data frame can only have one type of value in a column and I do not know of a way to format the value 0 to appear as "-" while remaining a number. Can you explain why you want to do this? There may be another solution.
now want to change if summary have 0 or 0.0 then it should replace by "-"
i have used tab[,2] <- replace(tab[,2],tab[,2]<0,"-")
but its not giving the required output
If you run the following code, you will see that appending a % to the numbers converts them to characters, which you want to avoid. I suspect you are trying to handle an R data frame as if it were a spreadsheet. If you need to use the numbers in calculations, do not attempt to format their appearance, just leave them as numbers.
yea you are right, i have values with decimal points also,
if am doing this so the values with 18.0 or 7.0 also converting to "-"
do we have any other sollution then