Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

From: Yasir Kaheil <kaheil_at_gmail.com>
Date: Tue, 06 May 2008 09:47:30 -0700 (PDT)

Hi Ottorino,
You could just use the modulus operator "%%" as follows:
> x<-c(1803.02, 193.51, 3.47);
> x-x%%c(50,5,1) #just using the modulus operator
[1] 1800 190 3

thanks

Dr. Ottorino-Luca Pantani wrote:
>
> Dear R-users,
> I have the following problem
>
> In a lab experiment I have to mix three solutions to get different
> concentrations of various molecules in a cuvette
>
> I've used R to calculate the necessary ┬Áliters for each of the level of
> the experiment and I must confess that it is more useful and easier to
> achieve the results than using spreadsheets.
>
> But there's a problem.
>
> Imagine that for a particular cuvette (I have 112 different cuvettes !!)
> you have to mix the following volumes of solution A, B, and C
> respectively.
>
> c(1803.02, 193.51, 3.47)
>

> Each solution is to be taken with 3 different pipettes (5000, 250 and 10
> ┬ÁL Volume max) and each of those delivers volumes in steps of 50 ┬ÁL, 5
> ┬ÁL or 1┬ÁL, respectively
> Since the above values would eventually become
>
> c(1800, 195, 3)
>
> it is then necessary to recalculate all the final concentrations

> of A, B and C, because the volumes are changed.
>
>
> I know that in most spreadsheets (Calc in Open Office, Gnumeric, Excel
> and so on)
> there's a function such as
>
> mround(num; num)
>
> that give the results I need, but I want to learn more on R functions.
>
>
> I played a little with R functions such as
>
> round, signif, ceiling, trunc, and floor
>
> but without success.
> Any hint to solve this problem ?
>
> Thanks a lot
>
> http://www.openofficetips.com/blog/archives/2005/04/rounding_to_the.html
> http://www.gnome.org/projects/gnumeric/doc/gnumeric-MROUND.shtml
>
> --
> Ottorino-Luca Pantani, Università di Firenze
> Dip. Scienza del Suolo e Nutrizione della Pianta
> P.zle Cascine 28 50144 Firenze Italia
> Tel 39 055 3288 202 (348 lab) Fax 39 055 333 273
> OLPantani@unifi.it http://www4.unifi.it/dssnp/
>
> ______________________________________________
> R-help_at_r-project.org 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.
>
>



Yasir H. Kaheil, Ph.D.
Catchment Research Facility
The University of Western Ontario
-- 
View this message in context: http://www.nabble.com/Is-there-in-R-a-function-equivalent-to-the-mround%2C-as-found-in-most-spreadsheets--tp17086856p17087399.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org 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.
Received on Tue 06 May 2008 - 17:49:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 06 May 2008 - 18:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive