[R] How to round only one df row & how to keep 3rd sigdif if zero

bcrombie bcrombie at utk.edu
Thu Jun 18 15:09:29 CEST 2015


# How do I round only one row of a dataframe?
# After transposing a dataframe of counts & rates, all values took on the
most # of signif digits in the dataset (rates), but I want counts to remain
only one digit.
# Also, how can I keep 3 significant digits in R when the 3rd is a zero?
count <- c(1, 2, 3)
rate <- c(16.7, 33.3, 50.0)
a <- data.frame(count,rate)
a
# count rate
# 1     1 16.7
# 2     2 33.3
# 3     3 50.0
a <- t(a)
a
# [,1] [,2] [,3]
# count  1.0  2.0    3
# rate  16.7 33.3   50



--
View this message in context: http://r.789695.n4.nabble.com/How-to-round-only-one-df-row-how-to-keep-3rd-sigdif-if-zero-tp4708819.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list