Search
 
SCRIPT & CODE EXAMPLE
 

R

average of rows in Rstudio reduce count

df <- data.frame(a=1:12, b=13:24 );
df;
##     a  b
## 1   1 13
## 2   2 14
## 3   3 15
## 4   4 16
## 5   5 17
## 6   6 18
## 7   7 19
## 8   8 20
## 9   9 21
## 10 10 22
## 11 11 23
## 12 12 24
n <- 5;
aggregate(df, list(rep(1:(nrow(df) %/% n + 1), each = n, len = nrow(df))), mean)[-1];
##      a    b
## 1  3.0 15.0
## 2  8.0 20.0
## 3 11.5 23.5
Comment

PREVIOUS NEXT
Code Example
R :: ggplot2 color gradient 
R :: geom_abline vertical line 
R :: Non-redundant version of expand.grid 
R :: add padding to number r 
R :: How to remove duplicates based on the combinations of two columns r 
R :: R view storage size of variable 
R :: how to combine multiple time series in r 
Rust :: rust lang sleep 
Rust :: how to index a string in rust 
Rust :: read file buffer rust 
Rust :: rust timestamp 
Rust :: rust get crate version 
Rust :: rust string from bytes 
Rust :: rust•armanriazi•error•cannot be formatted using `{:?}` 
Rust :: rust lang start a new project 
Rust :: concat string rust 
Rust :: error handling rust 
Rust :: sort reverse rust 
Rust :: rust•armanriazi•iterator•index•avoid 
Rust :: armanriazi•rust•error•[E0046]: not all trait items implemented, missing: `summarize_author` 
Rust :: armanriazi•rust•error•E0605•non-primitive cast 
Rust :: armanriazi•rust•thread•rayon•join•workstealing 
Rust :: rust tuple vs vec 
Lua :: roblox jsonencode 
Lua :: roblox index and newindex 
Lua :: forever loop in lua 
Lua :: continue in lua 
Lua :: Lua numbers 
Lua :: how to access an index of a table lua 
Lua :: lua call custom function 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =