Showing posts with label log to one vector. Show all posts
Showing posts with label log to one vector. Show all posts

Friday, September 28, 2018

The simplest structure in R is the vector,log

VECTORS structure in R is the vector.

statistics,r studio,statistics in r,r programming,r statistics,r tutorial,descriptive statistics,statistics (field of study),r function for statistics,learn r,data manipulation in r,r tutorials,math in r,introduction to r,class function in r,r for beginners,matrices in r,r arithmetic,data frame in r,finding determinant in r,math,basic r tutorials,basic math operation in r programming


 A vector is an object that consists of a number of elements of the same type, for example all doubles or all logical, as is called an atomic object.

> x <- c(10,2,15,35)
> x
[1] 10  2 15 35
> y<- c(x,0.55.x,x)
The function c merges an arbitrary number of vectors to one vector. A single number is regarded as a vector of length one.
> y<- c(x,0.55,x,x)
> y
 [1] 10.00  2.00 15.00 35.00  0.55 10.00  2.00 15.00 35.00 10.00  2.00
[12] 15.00 35.00
> z <-c(x+1,9,x+0.5,7,x+5)
> z
 [1] 11.0  3.0 16.0 36.0  9.0 10.5  2.5 15.5 35.5  7.0 15.0  7.0 20.0
[14] 40.0
Use the function round to round the numbers in a vector
> round (z,4)
 [1] 11.0  3.0 16.0 36.0  9.0 10.5  2.5 15.5 35.5  7.0 15.0  7.0 20.0
[14] 40.0
> p <-x*x
> p
[1]  100    4  225 1225
> log(x)
[1] 2.3025851 0.6931472 2.7080502 3.5553481




Black-Scholes formula-R

 Black-Scholes formula-R > BlackScholes <- function(TypeFlag = c("c", "p"), S, X, Time, r, b, sigma) { TypeFla...