Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Data Warehouse Job Interviews:Ab InitioActuateAnalysis ServicesBO DesignerBusiness ObjectsCognos Data WarehouseColdFusionCrystal Enterprise SuiteData IntegrationData ScientistData StageData Warehouse AnalystData Warehouse BIData Warehouse Data MartData Warehouse DeveloperData Warehouse ManagerData Warehouse SupervisorData Warehouses MicroStrategyData WarehousingData Warehousing BasicsDatabase PartitioningEnterprise Data WarehouseETL (Extract, transform, load)General DatawarehousingHyperionImpromptuInformatica Data WarehousingLead Data ScientistMicro StrategyOperational Data StoreReportnetSAS (Statistical Analysis System)Warehouse AssistantWarehouse ConceptsWarehouse DataStageWarehouse Operation ManagerWarehouse Worker
Copyright © 2018. All Rights Reserved
Lead Data Scientist Interview Question:
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
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.

https://InterviewQuestionsAnswers.ORG.
