Answered Essay: setwd("C:/COM337_R_Programming2017Q2/COM337 exam/ExamStarterKit/Q22017_Question#1")

R PROGRAMMING USING R STUDIO

THIS IS THE INPUT IN NOTEPAD

SYMBOL,DATE,SP
GOOG,2017-03-01,829
APPL,2017-03-01,143
MSFT,2017-03-01,65
GOOG,2017-02-01,823
APPL,2017-02-01,136
MSFT,2017-02-01,63
GOOG,2017-01-03,796
APPL,2017-01-03,120
MSFT,2017-01-03,64
GOOG,2016-12-01,771
APPL,2016-12-01,115
MSFT,2016-12-01,61
GOOG,2016-11-01,758
APPL,2016-11-01,110
MSFT,2016-11-01,59
GOOG,2016-10-03,784
APPL,2016-10-03,112
MSFT,2016-10-03,59
GOOG,2016-09-01,777
APPL,2016-09-01,111
MSFT,2016-09-01,56
GOOG,2016-08-01,767
APPL,2016-08-01,105
MSFT,2016-08-01,56
GOOG,2016-07-01,768
APPL,2016-07-01,102
MSFT,2016-07-01,55
GOOG,2016-06-01,692
APPL,2016-06-01,94
MSFT,2016-06-01,50
GOOG,2016-05-02,735
APPL,2016-05-02,98
MSFT,2016-05-02,52
GOOG,2016-04-04,693
APPL,2016-04-04,91
MSFT,2016-04-04,48

a s a rerata axe COM337. D com27. | A com337. A coMB7D MODULE | Q COMB37. A coM37. | A con337. A week so | A COM337. 0 com 37 A COM x + V fileICUsers/AISIAZOUSANDesktop/COM33720t ExanslatteriCOM317-ExarnPaper-August2017-1220Cape Case20study:20liardoutpel t = A 1 ... 3 of 45 Case Study Task Specification You are REQUIRED to use for-each loop from 1 to length (vector of unique symbols), subset (), sum (), length (), range (), Inside the loop, you are expected i, Create (BEFORE THE LOOP) a variable averageStockPriceDF <. vector of Symbol, MaxDate , AverageSP, MinSP , MaxSP as DF (data Frame) header ii. Calculate The minimum and maximum SP (for each unique symbol) however you cannot use the mini ) and max ) functions; then use printſ) to display your values. ii, Calculate the average SP (for each unique symbol), however you cannot use the mean () function to do this; then use print () to display you computed value. iv. Calculate the latest SP date (for each unique symbolusing maxDate <. max (as. Date (subset of topDogVizDFSDATE where topDog VizDFSSYMBOL= unique sysmbol; then use print () to display the maxDate. Continued overleaf ... Page 3 of 45 a a a de R ENG 12/08/2011 1130

##START HERE

setwd(“C:/COM337_R_Programming2017Q2/COM337 exam/ExamStarterKit/Q22017_Question#1”)
topDogVizDF <- read.csv(“InputChallenge#2BV2.txt”)
head(topDogVizDF,10)
tail(topDogVizDF)

##Solution

a s a rerata axe COM337. D com27. | A com337. A coMB7D MODULE | Q COMB37. A coM37. | A con337. A week so | A COM337. 0 com 37 A COM x + V fileICUsers/AISIAZOUSANDesktop/COM33720t ExanslatteriCOM317-ExarnPaper-August2017-1220Cape Case20study:20liardoutpel t = A 1 … 3 of 45 Case Study Task Specification You are REQUIRED to use for-each loop from 1 to length (vector of unique symbols), subset (), sum (), length (), range (), Inside the loop, you are expected i, Create (BEFORE THE LOOP) a variable averageStockPriceDF

Expert Answer

 

setwd(“C:/COM337_R_Programming2017Q2/COM337 exam/ExamStarterKit/Q22017_Question#1”)
topDogVizDF <- read.csv(“InputChallenge#2BV2.txt”)
topDogVizDF$DATE <- as.Date(topDogVizDF$DATE)

averageStockPriceDF <- data.frame(“Symbol”=character(),
“MaxDate”=as.Date(character()),
“AverageSP”=numeric(), “MinSP”=numeric(), “MaxSP”=numeric())

by <- topDogVizDF$SYMBOL

for(i in 1:length(unique(by))){
sub.topDogVizDF <- topDogVizDF[by==unique(by)[i],]
minSP <- sub.topDogVizDF$SP[1]
maxSP <- sub.topDogVizDF$SP[1]
avgSP <- sub.topDogVizDF$SP[1]

for(j in 2:nrow(sub.topDogVizDF)){
if (minSP > sub.topDogVizDF$SP[j]){
minSP <- sub.topDogVizDF$SP[j]
}

if(maxSP < sub.topDogVizDF$SP[j]){
maxSP <- sub.topDogVizDF$SP[j]
}

avgSP <- avgSP + sub.topDogVizDF$SP[j]
}

avgSP <- avgSP/nrow(sub.topDogVizDF)
print(paste(by[i], paste(“MINSP = “, minSP)))
print(paste(by[i], paste(“MAXSP = “, maxSP)))
print(paste(by[i], paste(“AVGSP = “, avgSP)))

maxDt <- max(sub.topDogVizDF$DATE)

averageSP_record <- data.frame(“Symbol”=by[i],
“MaxDate”=maxDt,
“AverageSP”=avgSP,
“MinSP”=minSP,
“MaxSP”=maxSP)
print(paste(by[i], paste(“MAXDATE = “, averageSP_record$MaxDate)))
#print(averageSP_record)
averageStockPriceDF<- data.frame(rbind(as.matrix(averageStockPriceDF), as.matrix(averageSP_record)))
}

write.csv(averageStockPriceDF, “AverageStockPrice.txt”, row.names = FALSE, col.names = FALSE, sep=”.”)

topDocAverageSP <- read.csv(“AverageStockPrice.txt”)
print(paste(“ROWS topDocAverageSP= “, nrow(topDocAverageSP)))
print(paste(“COLS topDocAverageSP= “, ncol(topDocAverageSP)))

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?