Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Last active June 20, 2025 12:49
Show Gist options
  • Save thinkphp/56457f172765aaee391ec87dfd7c3b78 to your computer and use it in GitHub Desktop.
Save thinkphp/56457f172765aaee391ec87dfd7c3b78 to your computer and use it in GitHub Desktop.
Filtram companiile cu acțiuni peste 150 USD
#
# Se dă un tabel care conține numele unor companii listate la bursa din New York (NYSE) și prețul curent al acțiunilor acestora în dolari americani.
# a) Să se filtreze companiile care au un preț al acțiunii mai mare de 150 USD.
# b) Să se afișeze aceste companii într-un tabel.
# c) Să se construiască un grafic cu coloane verticale care să arate prețul acțiunilor pentru toate companiile din setul inițial
#
library(tidyverse)
# Cream un tabel (tibble) cu date despre companii de pe NYSE
df <- tibble(
companie = c("Apple", "Microsoft", "Amazon", "Tesla", "IBM"),
pret_actiune = c(180, 330, 125, 250, 145)
)
# Filtram companiile cu acțiuni peste 150 USD
df_filtrat <- df %>% filter(pret_actiune > 150)
# Afisam rezultatul filtrarii
print(df_filtrat)
ggplot(df, aes(x = companie, y = pret_actiune)) +
geom_col(fill = "steelblue") +
labs(
title = "Prețuri Acțiuni pe NYSE",
x = "Companie",
y = "Preț Acțiune (USD)"
) +
theme_minimal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment