Tell me how to create a function in arguments using apply() in R?
Submitted by: MuhammadWhat if we want to be able to find how many data points (n) are in each column of m?
We are using columns, MARGIN = 2, thus, we can use length function to do this:
apply(my.matrx, 2, length)
There isn't a function in R to find n-1 for each column. So if we want to, we have to create our own Function. Since the function is simple, you can create it right inside the arguments for applying. In the arguments, I created a function that returns length – 1.
apply(my.matrx, 2, function (x) length(x)-1)
The function returned a vector of n-1 for each column.
Submitted by: Muhammad
We are using columns, MARGIN = 2, thus, we can use length function to do this:
apply(my.matrx, 2, length)
There isn't a function in R to find n-1 for each column. So if we want to, we have to create our own Function. Since the function is simple, you can create it right inside the arguments for applying. In the arguments, I created a function that returns length – 1.
apply(my.matrx, 2, function (x) length(x)-1)
The function returned a vector of n-1 for each column.
Submitted by: Muhammad
Read Online Lead Data Scientist Job Interview Questions And Answers
Top Lead Data Scientist Questions
☺ | Can you write the syntax to set the path for a current working directory in R environment? |
☺ | Do you know how to Merge the files into a single dataframe? |
☺ | Tell me how do you define big data? |
☺ | Tell me what is bias, variance trade off? |
☺ | Tell me what is Random Forest? How does it work? |
Top Data Warehouse Job Categories
☺ | Warehouse Assistant Interview Questions. |
☺ | Ab Initio Interview Questions. |
☺ | Data Stage Interview Questions. |
☺ | ColdFusion Interview Questions. |
☺ | Data Warehouse Supervisor Interview Questions. |