R语言怎么定义数学上的周期函数?

Python032

R语言怎么定义数学上的周期函数?,第1张

举个栗子,不知道理解得对不对,假设周期为5:

x <- 1:100

y <- vector()

for (i in x) {

if(i <= 5) y[i] <- f(x[i])#此处f()表示y与x的函数关系式

else y[i] <- y[i-5]

}

-Usage

aggregate(x, by, FUN, ..., simplify = TRUE, drop = TRUE)

与tapply类似,但是x可以为data.frame或矩阵;

-Arguments

by

a list of grouping elements, each as long as the variables in the data frame x. The

elements are coerced to factors before use.

-Example

-Usage

by(data, INDICES, FUN, ..., simplify = TRUE)

-Example

将warpbreaks的一二列,根据tension这一列的(L、M、H)运行summary

aggregate与by的区别 :aggregate是对x的每一列分别根据因子进行分组计算,而by是根据因子将data整个分成几个小的data.frame,然后进行运算;