Druhé rande s R, slzy a frustrace

Pokus posunout náš vztah s R na vyšší level tedy velmi bolel. Bez líbivého tutoriálu a odznáčků s obrázky chobotnice se jevil mnohem méně přístupný a musím přiznat, že jsem si na jeho záludnostech docela vylámala zuby.

Takhle vypadá rozhraní RStudia, které slouží k práci s R. Nemá zrovna vstřícnou povahu a rozhodně nikomu neradím vynechat přednášku o tom, jak s ním zacházet ;)

Naším úkolem bylo podle zadání pracovat s předem určenými proměnnými kterými byl název firmy, její obrat, zisk a konkrétní rok, ke kterému se tyto údaje vztahují. Zadání zahrnovalo celkem devět dílčích úkolů.

1. Vytvořte data frame z daných proměnných.

> companiesData <- data.frame(fy, company, revenue, profit)
> colnames(companiesData) = c(“fy”, “company”, “revenue”, “profit”)> str(companiesData)
'data.frame':   9 obs. of  4 variables:
 $ fy     : num  2010 2011 2012 2010 2011 ...
 $ company: Factor w/ 3 levels "Apple","Google",..: 1 1 1 2 2 2 3 3 3
 $ revenue: num  65225 108249 156508 29321 37905 ...
 $ profit : num  14013 25922 41733 8505 9737 ...

 

2. Převeďte fy (tj. zde rok) na factor.

> companiesData$fy <- factor(fy, ordered = T)
> str(companiesData)
'data.frame':   9 obs. of  4 variables:
 $ fy     : Ord.factor w/ 3 levels "2010"<"2011"<..: 1 2 3 1 2 3 1 2 3
 $ company: Factor w/ 3 levels "Apple","Google",..: 1 1 1 2 2 2 3 3 3
 $ revenue: num  65225 108249 156508 29321 37905 ...
 $ profit : num  14013 25922 41733 8505 9737 ...

 

3. Vypište jen hodnoty pro firmu Apple.

> companiesData[companiesData$company=='Apple',]
    fy company revenue profit
1 2010   Apple   65225  14013
2 2011   Apple  108249  25922
3 2012   Apple  156508  41733

 

4. Přidejte nový sloupec "margin", který bude obsahovat marži v procentech.

> companiesData$margin <- (companiesData$profit / companiesData$revenue) * 100
> companiesData$margin <- round(companiesData$margin, 1)
> companiesData
    fy   company revenue profit       V5 margin
1 2010     Apple   65225  14013 21.48409   21.5
2 2011     Apple  108249  25922 23.94664   23.9
3 2012     Apple  156508  41733 26.66509   26.7
4 2010    Google   29321   8505 29.00651   29.0
5 2011    Google   37905   9737 25.68790   25.7
6 2012    Google   50175  10737 21.39910   21.4
7 2010 Microsoft   62484  18760 30.02369   30.0
8 2011 Microsoft   69943  23150 33.09838   33.1
9 2012 Microsoft   73723  16978 23.02945   23.0

 

5. Najděte historicky nejvyšší marži.

> max(companiesData$margin)
[1] 33.1

 

6. Jaká firma a v jakém roce ji měla? (Aneb kde ani Google nepomůže.)

Error

7. Vytvorřte data frame obsahující pouze data pro Apple.

> apple <- companiesData[companiesData$company=='Apple',]
> apple
    fy company revenue profit       V5 margin
1 2010   Apple   65225  14013 21.48409   21.5
2 2011   Apple  108249  25922 23.94664   23.9
3 2012   Apple  156508  41733 26.66509   26.7

 

8. Vytvořte sloupcový graf revenue pro Apple po letech, nazvěte jej "Revenue for Apple by Year".

barplot(revenue[1:3], main = "Revenue of Apple by year", )
 

 

9. Do grafu vepište vodorovnou modrou čáru, která určije revenue firmy Google v roce 2012.

> (a = companiesData[companiesData$fy==2012 &  companiesData$company=="Google", ])
    fy company revenue profit margin
6 2012  Google   50175  10737   21.4
> a = a$revenue
> abline(h=a,col="blue")


 






 

Fotogalerie

Štítky: R, RStudio
Líbil se vám článek?
Stáhnout článek v PDF

16 komentářů

Obrázek uživatele Anonym
Anonym
30. 5. 2019

I am they are a lot of things from your article. <a href="https://cmgames.io/game/run-3">cool math run 3</a>

 

Obrázek uživatele Anonym
Anonym
30. 5. 2019

"Foo":http://foo.bar

 

Obrázek uživatele Anonym
Anonym
1. 7. 2019

Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information. http://maboot.com/

Obrázek uživatele Anonym
Anonym
5. 7. 2019

Hey what a splendid post I have run over and trust me I have been looking out for this comparative sort of post for recent week and barely ran over this. Much thanks and will search for more postings from you.  garage door repair Katy Texas

Obrázek uživatele Anonym
Anonym
7. 7. 2019

Much thanks to you so much Love your web journal..  안전토토

Obrázek uživatele Anonym
Anonym
8. 7. 2019

I’m impressed, I must say. Really rarely do you encounter a blog that’s both educative and entertaining, and let me tell you, you might have hit the nail on the head. Your concept is outstanding; the issue is something which not enough people are speaking intelligently about. My business is very happy i always stumbled across this within my try to find something relating to this. 다자바 검증

Obrázek uživatele Anonym
Anonym
12. 7. 2019

I went over this site and I trust you have a considerable measure of superb data, spared to my bookmarks  Tacoma locksmith

Obrázek uživatele Anonym
Anonym
16. 7. 2019

Wonderful paintings! That is the kind of information that are meant to be shared across the web. Disgrace on the seek for no longer positioning this submit upper! Come on over and visit my website . Thanks =) 사설토토사이트

Obrázek uživatele Anonym
Anonym
22. 7. 2019

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees manufacturers</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees manufacturers</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

https://www.madheswaransilkshop.com<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees manufacturers</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a><br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees manufacturers</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

<br><a href="https://www.madheswaransilkshop.com">kanchipuram silk sarees</a>

 

Obrázek uživatele Anonym
Anonym
2. 8. 2019

I just couldn't leave your site before letting you know that I really appreciated the top quality information you present to your guests? Will be back again as often as possible to determine the status of new posts.  garage floors adelaide

Obrázek uživatele Anonym
Anonym
5. 8. 2019

The greatest tribute to Roy’s skill and a sign of his attention to the human side of things is that he gets her to the wedding, after a few car explosions and chases and dozens of dead bodies. 5197.tw

Obrázek uživatele Anonym
Anonym
9. 8. 2019

Continue blogging. Hoping to perusing your next post. parc clematis review

Obrázek uživatele Anonym
Anonym
9. 8. 2019

I can see that you are a specialist at your field! I am propelling a site soon, and your data will be exceptionally valuable for me.. A debt of gratitude is in order for all your help and wishing all of you the accomplishment in your business.  parc clematis review

Přidat komentář

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.

Přečtěte si také

Přihlášení Registrace
RSS Facebook Twitter YouTube
Zobrazit standardní verzi webu

Taky děláme

Feedback