Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201941

How can I create a function that creates a matrix using values from my dataset in R?

$
0
0

I have a dataset containing 120 observations of 6 variables. Five variables are factors, 1 variable is my target variable. I need to write a function that will creates a matrix (for each factor) which contains each level of the factor as columns, and the maximum value of the target variable as first row, and the minimum value of the target variable as the second row.

I know how to create a matrix, however I am lost when I need to make it through a function. Is there someone who can help?

Here is a simple example of what I want to reach with a fictive easy dataset. Example

As you can see, for each level of the factor (on the picture factor 1), I want to indicate the highest value of the target, and the lowest value of the target.


Viewing all articles
Browse latest Browse all 201941

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>