R/pPart.R

Defines functions pPart

Documented in pPart

pPart <-
function(n=0) {
  if ((length(n) > 1 ) || (n<=0)) stop("The first parameter must be a positive integer");
  v<-MFB(n,1);                                # Call the MFB Function
  v<-MFB2Set( v );                            # Expression to vector 
  for (j in 1:length(v)) {
    # ----- read -----------[ fix block ]-----#---------------#
    c <- as.character(v[[j]][2]);             # coefficient
    x <-              v[[j]][3] ;             # variable
    i <-              v[[j]][4] ;             # subscript
    k <-       strtoi(v[[j]][5]);             # power
    # ----- change ---------------------------#---------------#
    if (x=="f") {
      c<-paste0(c,"/factorial(",n,")");
      x<-""; 
      i<-""; 
    } 
    else if (x=="g") {
      c<-paste0(c,"*(factorial(",i,")^",k,"*factorial(",k,"))");
      x<-"y";
      i<-"";
    }
    # ----- write ---------[ fix block ]------#---------------#
    v[[j]][2] <- c;
    v[[j]][3] <- x;
    v[[j]][4] <- i;
    v[[j]][5] <- k;
    # ----------------------------------------#---------------#
  }
  Set2expr(v);
}

Try the kStatistics package in your browser

Any scripts or data that you put into this service are public.

kStatistics documentation built on June 8, 2022, 5:05 p.m.