Question

I have a CSV file of all symbols listed on the NYSE, it is formated as follows:

   Symbol         Name           Last Sale
1  DDD            Company_name1  val_1
2  SSYS           Stratasys      val_2
3  GOOG           Google         val_3
4  GS             Goldman Sachs  val_4
5  AAPL           Apple          val_5

This is how it is displayed after importing my CSV file

companylist <- read.csv("~/Downloads/companylist.csv")
  View(companylist)

How would I go about retrieving company's specific symbol? For example if I wanted to get the symbol for the 2nd to last stock, what code should I use? I have been searching for an answer for the past 6 hours and have looked at the documentation but cant seem to find anything relevant.

Was it helpful?

Solution

You could get that using:

df[2:nrow(df), 'symbol']

assuming the data is in df. For example:

> mtcars[2:5, "mpg"]
[1] 21.0 22.8 21.4 18.7
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top