Friday, January 20, 2023

Example of Packages in R

 

#' Sr.1.Soil Weight Calculation

#'

#' Soil weight calculation is important to measure the soil nutrient status in

#' soil and its also predicts the erosion is soil.

#' @param x depth of soil (m)

#' @param y is the bulk density (Mg m-3)

#'

#' Equation: (Length * width * soil depth* bulk density)

#' @return

#' @export

#'

#' @examples soil_weight(0.3,1.25)

soil_weight <- function(x,y) {

  result <- 100 * 100 * x*y

  print(result)

}

##########################################################

#' Sr.2. Soil Nutrient in Soil

#'

#' @param x is soil weight (Mg)

#' @param y is Nutrients in soil (%)

#'

#' Equation used: (((x*y)/100) *1000))

#'

#' @return

#' @export

#'

#' @examples N_soil(3750,0.15)

N_soil <- function(x,y) {

  result <- (((x*y)/100) *1000)

  print(result)

}

#################################################################

#' Sr.3. Calculation of Field capacity moisture from saturation percentage

#'

#' @param x Saturation percentage in soil (%)

#'

#'  Equation used: 2.62+0.595(SP)

#'

#' @return

#' @export

#'

#' @examples FC(30)

FC <- function(x) {

  result <- 2.62+0.595*x

  print(result)

}

####################################################################

#' Sr.4. Permanent Wilting point moisture from saturation percentage

#'

#'It makes easy for researcher to calculate the wilting point from saturatio

#' saturation percentage

#' @param x Saturation Percentage (%)

#'

#' Equation used:-7.92+0.593 (SP)

#' @return

#' @export

#'

#' @examples PWP(30)

PWP <- function(x) {

  result <- -7.92+0.593*x

  print(result)

}

#####################################################################

#' Sr.5. Calculation of Bulk Density

#'

#' This function is developed to calculate bulk density

#' @param x  Mass of solid (g)

#' @param y Volume of core (cm3)

#'

#' Equation used: (Mass of solid/Volume of solid)

#' @return

#' @export

#'

#' @examples Bulk_density (930,785)

Bulk_density <- function(x,y) {

  result <- x/y

  print(result)

}

###################################################################

#' Sr.6. Soil Porosity

#'

#'The soil porosity is calculated from the bulk density

#' @param x is a Bulk density (g/cm3)

#'

#'  Equation used: 1- (Bulk density/Particle density)*100

#'

#' @return

#' @export

#'

#' @examples Porosity(1.18)

Porosity <- function(x) {

  result <- (1-(x/2.65))*100

  print(result)

}

####################################################################

#' Sr.7. Gravimeter Water Contents

#'

#' This function calculates the gravimetric moisture contents of soil

#' @param x is a mass of water (g)

#' @param y is a solid (g)

#'

#' Equation used: (Mass of water /Mass of solid)

#' @return

#' @export

#'

#' @examples Gravimetric_water(0.3,0.9)

Gravimetric_water <- function(x,y) {

  result <- x/y

  print(result)

}


#################################################################

#'Sr.8. Volumatric Water contents from Gravimetric water contents

#'

#' @param x is Gravimetric water contents (cm3 cm-3)

#' @param y is bulk density (g cm-3)

#'

#' @return

#' @export

#'

#' @examples volumatric_water2(0.33,1.2)

volumatric_water2 <- function(x,y) {

  result <- x *y/1.0

  print(result)

}

###############################################################

#'Sr.9. Volumatric air contents

#'

#' @param x is porosity (cm3 cm-3)

#' @param y is volumatric water contents (cm3 cm-3)

#'

#' @return

#' @export

#'

#' @examples volumatric_air(0.55,0.40)

volumatric_air <- function(x,y) {

  result <- x-y

  print(result)

}

################################################################

#' Sr.10. Stock's law: Settling Velocity of soil particle in water

#'

#' The settling velocity helps in determination of soil texture in hydrometer

#' method. The Particle density = 2650 kg m-3,

#' Density of water =998 kg m-3,Gravity = 9.8 m s-2,viscosity of liquid = 10-3 kg m-1 s-1

#' were considered fixed value.

#' @param a is radius of the particle (m)

#'

#'

#' Equation Used: (2*r^2*(ps-pl)*g)/(9*z)

#' @return

#' @export

#'

#' @examples settling_velocity(10^-6)

settling_velocity <- function(a) {

  result <- (2*r^2*(2650-998)*9.8)/(9*10^-3)

  print(result)

}

#################################################################


No comments:

Post a Comment