I have a 1000*10 matrix showing cashflow of 10 years. For analytical purposes I want to examine the different percentiles/quantiles in terms of a variable

Part of my R-code

```plot(timeline, TOTKS[1,], ylim=range(-15000000,100000000), type="l", ylab="Cash Flow", xlab="year")
for (i in 1:total.simulations){
lines(timeline, TOTKS[i,])}```

I want to color the 10 % lowest cash flows in the plot above. Nov 16, 2018 14 views

## 1 answer to this question.

find the ten lowest total cash flows. Add up the columns:

`total.cashflow <- drop(colSums(TOTKS, na.rm=TRUE))`

Then find which are the 10% lowest:

```rank.cashflow.le10 <- which(
total.cashflow <= qualtile(total.cashflow, 0.1)
)```

Add them to the plot:

`matlines(timeline, TOTKS[,rank.cashflow.le10], col="red")`

To examine those as a separate matrix (but you might not need to, with a vector of indicies)

`low10TOTKS <- TOTKS[,rank.cashflow.le10]` answered Nov 16, 2018 by
• 10,040 points

## Save a plot as image on the disk using R

Consider for both the situations: 1. Image will ...READ MORE

## R language has several packages for solving a problem. How do you make a decision on which one is the best to use?

CRAN package ecosystem has more than 6000 ...READ MORE

## Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

## How to change the value of a variable using R programming in a data frame?

You are getting this error since the ...READ MORE

## Parallel programming In R using GPU

Check out the CRAN Task View on High-Performance ...READ MORE

## R programming: Naming the output file using a variable

Use the paste command: write.csv(max.hsi, paste0("Index_", i,".csv" ...READ MORE

## R Programming: Using iteration value to change field names

Remove the first and last column from ...READ MORE