Hi R users, I was trying to estimate some values in r but could not figure out how to write the script in r. Although I was able to estimate it correctly in the excel. For example I have the following data set.
daT<-structure(list(sd = c(0.481, 0.682, 0.741, 0.394, 0.2, 0.655, 0.375), mcd = c(51.305, 51.284, 51.249, 51.2, 51.137, 51.059, 50.968), ca = c(49.313, 69.985, 75.914, 40.303, 20.493, 66.905,38.185)), class = "data.frame", row.names = c(NA, -7L)) head(daT) In this data set, I need to estimate in the column name "ca", In the excel I estimated the value using the following formula: IF(A2>B2*2,PI()*B2^2,((0.5*A2)*SQRT(B2^2-(0.5*A2)^2)+B2^2*ASIN((0.5*A2)/B2))*2) But when I wrote the following code in the R, it did not work attach(daT) daT$ca<-if(sd>mcd*2,pi()*mcd^2,((0.5*sd)*sqrt(mcd^2-(0.5*sd)^2)+mcd^2*asin((0.5*sd)/mcd))*2) Your suggestion would be highly appreciated. Sincerely, MW [[alternative HTML version deleted]] ______________________________________________ R-help@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.