Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Let mylist=list(sex = c(1,1,1,1,2,2,2,2,2,2), smoking = c(1,0,1,0,1,0,1,0,1,1), age=c(21:30)). Give the results of these R commands: 1) x = lapply(mylist, max); print(x); y = sapply(mylist, min);

Let mylist=list(sex = c(1,1,1,1,2,2,2,2,2,2), smoking = c(1,0,1,0,1,0,1,0,1,1), age=c(21:30)). Give the results of these R commands:

1) x = lapply(mylist, max); print(x); y = sapply(mylist, min); print(y)

2) z = mapply(function(p1,p2,p3){c(p1,p2,p3)}, mylist$sex, mylist[[2]], mylist[['age']]); print(z)

3) class(x); class(y); class(z)

Please explain the difference among x, y and z in terms of the above results briefly.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started