Solved – How To Solve A Sequence Question

I'm taking a course on R on edx, but I have been stocked here for days. Please
Which integer values are between the maximum and minimum heights? For example, if the minimum height is 10.2 and the maximum height is 20.8, your answer should be x <- 11:20 to capture the integers in between those values. (If either the maximum or minimum height are integers, include those values too.)

You may benefit from using the floor() and ceiling() functions in R. Ceiling will take a number and round it up to the next highest integer (or leave it as-is if it is an integer). For example, ceiling(10.2) will return 11. Conversely, floor will round a number down to the next lowest integer, so floor(20.8) returns 20.

Let's say your minimum and maximum are defined in R as MIN and MAX, then x <- ceiling(MIN):floor(MAX) should return the sequence you're looking for.

Similar Posts:

Rate this post

Leave a Comment