Plot daily data of a stock - r-markdown

I'm a little unsure where to ask this question but hope I got it right! If not, please correct me.
I am doing a lab in R Markdown (in school) where I have downloaded the historical (daily) values of the prices of one stock for a period that covers ten years, and then I am going to plot the daily data of the stock.
My question is what daily data of a stock is? Since the csv-file with the historical values contains the values Date, Open, High, Low, Close, Adj Close och Volume I am a little unsure on what it is I should really plot - my spontaneous thought is the closing prices during this 10-year period. Is this correct?
Thanks in advance!

Usually stock price is referred Adj Close since it takes into account events like stock splits and dividends.
So basically, if you see line chart of stock prices, you usually see something like that under the hood:
plot(x = my_data$Date, y = my_data$`Adj Close`, type = 'l')
However, Open, High, Low, Close can be used to make visualizations with more accent on daily movements (in case of daily data). Check out candlestick charts abd OHLC charts. It can be achieved with quantmod or plotly packages for instance:
quantmod::chartSeries(my_data)
plotly::plot_ly(my_data, x = ~Date, , open = ~Open, close = ~Close, high = ~High, low = ~Low type="ohlc")

Related

How to get multiple category lines with bar chart in Power Bi?

Sample Data.
CompanyA,2019-01-01,29000
CompanyA,2019-02-01,35000
CompanyA,2019-03-01,43000
CompanyA,2019-04-01,27000
CompanyA,2019-05-01,45000
CompanyA,2019-06-01,21000
CompanyA,2019-07-01,26000
CompanyA,2019-08-01,27285
CompanyA,2019-09-01,26035
CompanyA,2019-10-01,24785
Expected Output.
My Boss has asked me to show sale trend by companies and month. but he wants it to be shown like below.
X axis should have Month Names
Bar lines should tell overall sales amount by month.
multiple lines should represent company sales amount.
i have achived this output by replacing 2 charts on each other (hidden one background). 
First i have taken a CLUSTERED COLUMN CHART and place a Line chart on it with hidden background.
Sample File
But for me this is just an adhoc solution and One more problem is that both chart's y axis doesn't match.
seeking for a good solution on this. either another good chart to represent this kind of data or how to achive it any other way?
Thanks in advance.
You can create measures for individual company, if number of companies is not a big number, and then put them in "Line values" to achieve the same result as above.
So For ex, if you have 5 companies in the data then create 5 different measures like below
CompanyA = calculate(sum(sales), filter(tbl, [company] = "CompanyA"))
like the above ex create measures for other 4 companies also

PowerBI measure calculates average incorrectly - why?

To preface this, I'm fairly experienced in Excel and VBA but new to PowerBI and more than a bit confused.
I have a flat table with a [creationdate]-, [Prio] (Priority (1,2,3)) and a calculated [Days Open] column, among many irrelevant others. I need to create a chart that displays the average days a case was open by priority of the case.
To display the average "days required" per (opening-) month for the past 18 months, I created the following measure:
Prio 1 = CALCULATE(AVERAGE('SourceName'[Days Open]),'SourceName'[Prio]=1)
Then I used that as a value, and used the [creationdate] as the x-axis. (Later I changed the x-axis to a new date table linked to [creationdate] without it making a difference.) To display this as monthly averages, I used the hierarchy limited to years and months, and went down one level in the chart.
Something seemed off so I checked first in Excel, then in the data source in PowerBI and yep: The averages in the PowerBI chart are complete bullshit.
Where did I go wrong? I assume it has something to do with the date hierarchy... So I created a date table as recommended (which....why?!) and linked it. That didn't make a difference.
Meanwhile in the data panel if I filter by the date column and calculate the average with the filtered selection of numbers externally, everything works as expected, so its not like there's a date formatting issue.
Do I have to create a calculated column with something akin to
DATE(YEAR([DateColumn]),MONTH([DateColumn]),1)
, then use that as the x-axis without the hierarchy, and hope nobody cares about the day in the label? Or is there something wrong with the measure used? I'm completely lost.

Power BI - How to ignore a slicer for one measure, but apply it on another?

I'm new to power bi and DAX so I'll try to be as clear as I possibly can.
Here's the
Graph
I'm dealing with.
The X axis shows the hours of the day. Each bar shows data of a specific location, yet it's possible that two different bars would show the same location because of a time difference (hours on the X axis).
What I'm trying to do is to SUM a cloumn, grouped by location.
Example:
The number 704 (registered users) shown on the third bar (tooltip) also apears on the second because it's data from the same location. In this case I only want to sum it once. The first bar shows 540 registered users from a different location, so in total, the new measure I'm trying to display across all bars would show the number 1244 (704+540).
Any kind of help would be appreciated.
Gilad

How to estimates monthly/daily sales of an item using Amazon Advertising API

I have looked into the responses of "ItemSeach ()" and "lookUp()" functions in Amazon Advertising API and
could not find a possible way to get daily/monthly sales of an item.
Popular product research software like , JungleScout, ProfitPhonix, AMZ tracker etc do display Number of monthly sales but all of them show different results.
Does Amazon provide this information ? If not then how the above software are estimating it?
I think when they fetch the ASIN information, they do store "some thing" in their DB and next time when the same ASIN is pulled again then the estimated sales are roughly calculated based on DB previous value/score.
Any help will be highly appreciated .
Thanks
It is not a solution, but here is a reply from UnicornSmasher I found, it may help to save time searching for something that doesn't exist.
constantine We just took all of the bulk data from the products that are being tracked in AMZ Tracker and applied a formula to it all. If you have specific products that are way off please let us know! Certain categories we had less data on. This is version 1 of the research tool, so I'm sure it will continue to improve quickly over time.
Here is the link to question and answer:
amz forum
So, now, the question is 'What formula do they use?'
Let me know if you come up with an idea :)
Let me tell you first that if you're not the part of the Amazon data team you can't get the sales numbers of any product. And, its probably not easy to estimate sales using Amazon advertising API. You need to constantly track a huge number of products to estimate the sales. Here I can explain how AMZ Insight an Amazon tracking tool estimates the sales of any product.
They constantly track a few thousand products from all the categories and collect massive data. Then their in-house data scientist analyze the data to form the sales estimating algorithm. Relationship of multiple data points plots a scattered graph which means of course sales estimates are not 100 percent right.
Data is continuously gathered and analyzed by tracking the Best Seller Rank (BSR), Buybox, reviews and more factors. Then the relationship between this data is formed to come up with the unit sales. Once this relationship is in place then it is much easier to estimate monthly sales and revenue for the product.

Open Office find all bills labelled POWER and work average cost

So I have made a spreedsheet to help me keep track of my power and gas bill - well the total cost of the bill anyway. This way as the months go on I am able to see what the average Power and Gas bill have been.
I am using only sheet1 and prefer to do it this way, so when I show my partner they don't need to flick through pages of numbers. It's right in front of them with Power & Gas in the next row - take a look at the image below.
So as you can see from the above (not including the J3 row) I have everything laid out in the layout I would like. This way when I get a bill emailed to me I add it, and then I can pay X amount and record that.
I know how to do =sum() and =average() but how can I limit it to only the power rows automatically.
The query should be looking up G column for power or gas and then whichever one it is get the H column next to it and then work out the cost per month by looking at the date the bill came out.
Power bill is every month so that easy, gas is every 3 months.
I know in open office they have the =if() command and I made it return TRUE when it was power but it does not seem that i can use just that function? I am wondering if maybe a TUT or example that outlines how we get the result like this.
Another example would be replace gas and power with tech toys i.e batteries over a year what was the real cost per monthly.
Ok after thinking outside the square - the answer I am using is this.
=AVERAGEIF(G3:G100;"POWER";H3:H100)/COUNTIF(G3:G100;"POWER")
I divided power by it's count as we get it every month
=AVERAGEIF(G3:G100;"GAS";H3:H100)/COUNTIF(G3:G100;"GAS")/3
I divided gas by 3 as we get it every 3rd month