Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DSCI 352 - Assignment 1 1) Create an R function called every.nth which will take in the following as inputs: 1) a vector and 2)

image text in transcribed

DSCI 352 - Assignment 1 1) Create an R function called every.nth which will take in the following as inputs: 1) a vector and 2) a number n. The function will return a new vector consisting of every nth element. 2) Create an R function called nth. sum which will take in the following as inputs: 1) a vector and 2) a number n. The function will return the sum of every nth element in the vector. (Hint: Use every.nth from the previous exercise as a building block). 3) Create an R function called every.nth.row which will take in the following as inputs: 1) a filename to a data set, and 2) a number n. The function will read in the file into a data frame and return a new data frame containing every nth row. (Hint: Use every.nth from one of the previous exercises as a building block). 4) Create an R function called duplicated.elements which will take in a vector as its only input. The function will return a new vector consisting of all elements which occur MORE THAN ONCE in the input vector. (Hint: consider using the built-in function table). 5) (CHALLENGE PROBLEM-worth 50 points) Create an R function called consec. sums which, given a vector of integers and a number n as inputs, will generate the sums of consecutive groups of numbers and return the resulting sums in a new vector. If the initial vector's length is not an exact multiple of n, use as many as remain in computing the last sum. (Note: You may use the built-in sum function as a building block if you like)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions