Result of function into dataframe. R beginner, first post

rstudio

#1

Hi, I'm very new to here and R:)

I'm using a function to make "moving average".
The variable is one, x, but I get four colomn results. I want to store them into a dataframe.
But I don't know how to do...

1, Made dataframe containing four colomns

2, executed function like this below (maybe..)
Moving_average <- function (x) {
Blablablar}

3, got [1, ] [2, ] [3, ] [4, ] in console screen.
Because using "for i" I get hundreds lines..

4, want to give names for each, and store into dataframe or maybe other useful style.

Thanks in advance! I'm waiting for your reply.


#2

Hi there, and welcome to community.rstudio.com!

Without knowing how your function is structured and what your output looks like, it's a little difficult to give good guidance. To help you get the right help for your question, can you please turn it into a reprex (reproducible example)? This will ensure we're all looking at the same data and code. A guide for creating a reprex can be found here.