[R] Implementing A Formula

Frede Aakmann Tøgersen frtog at vestas.com
Wed Jan 8 07:18:35 CET 2014


Hi

Is is something like this that you want?


mydata <- data.frame(a=1:10, b=11:20, c=21:30, d=31:40, e=41:50)

myfun <- function(a,b,c)a*b+c

mydata$cool <- do.call(myfun, mydata[,c("a", "b", "c")])

mydata
##     a  b  c  d  e cool
## 1   1 11 21 31 41   32
## 2   2 12 22 32 42   46
## 3   3 13 23 33 43   62
## 4   4 14 24 34 44   80
## 5   5 15 25 35 45  100
## 6   6 16 26 36 46  122
## 7   7 17 27 37 47  146
## 8   8 18 28 38 48  172
## 9   9 19 29 39 49  200
## 10 10 20 30 40 50  230

Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Norman McBride
> Sent: 7. januar 2014 23:46
> To: r-help at r-project.org
> Subject: [R] Implementing A Formula
> 
> Hello R Mailing List Members,
>       My name is Peter. I am a high school student who is doing a senior
> thesis in statistical analysis. As you can see that I have chosen R. So for
> the project I am working with a member of the US Navy and analyzing some
> data. So for this data I am using a formula to find a cooling coefficient.
> This formula gets it own column in the table/display frame. So I wanted to
> know if put this formula into the display frame would I need to go row by
> row plugging this formula in to only take data from that individual row or
> would it just do that for me? If I did have to do it row by row would there
> be anyway I could expedite the process because it is over 2000 rows. Thank
> you for any help you are able to give me.
> 
>       -Peter
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.




More information about the R-help mailing list