Code Monkey home page Code Monkey logo

Comments (2)

cedavil avatar cedavil commented on July 17, 2024

Has anyone had issues running the code on page 31?
I keep getting the following error message.
Error in x[j] : invalid subscript type 'list'

from statistics-for-data-scientists.

michaelverano avatar michaelverano commented on July 17, 2024

I'm getting a different issue with the code on this page.

Running sp500_sym[sp500_sym$sector=="etf", 'symbol'] yields the etfs you find on page 32 when running corrplot in the book. HOWEVER, running

etfs <- sp500_spx[row.names(sp500_px)>"2012-07-01", sp500_sym[sp500_sym$sector=="etf", 'symbol]] yields a different set of etfs.

i.e.
> sp500_sym[sp500_sym$sector=="etf", 'symbol']
> [1] XLI QQQ SPY DIA GLD VXX USO IWM XLE XLY XLU XLB XTL XLV XLP XLF XLK

but

> colnames(etfs)
[1] "VAR" "PBCT" "CINF" "ALLE" "JCI" "ENDP" "THC" "IPG" "SYK" "MCK" [11] "CERN" "STJ" "BXLT" "ESRX" "CAH" "TMO" "ZBH"

I admit that I am still learning R, so could it be something in the code? The data I used were the csv files from this github page and read with read.csv.

from statistics-for-data-scientists.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.