I have two small data frames of baseball data. The first one is the mean
number of runs that will score in each half inning for the 2018 Arizona
Diamondbacks. The second data frame is the same information but for only
one player. As you will see the individual player did not come up to bat
a
Can someone out there run the following code from the book Analyzing Baseball
Data with R – Chapter 7 page 164?
library(tidyverse)
db <- src_sqlite(“data/pitchrx.sqlite”,create=TRUE)
Over the past two weeks this code has run correctly twice but I have gotten the
following error dozens o
Can’t get past first step of Chapter 7 page 164.
Opened a new RStudio window. Loaded tidyverse and keyed in library(tidyverse)
which of course includes dplyr. The working directory is:
C:/Users/Owner/Documents.
Then keyed in: db <- src_sqlite(“data/pitchrx.sqlite”,create=TRUE)
And got the fo
I am continuing to have problems downloading data as prescribed in books
about R such as “Analyzing Baseball Data with R”.
In chapter 3 (page 67) the instructions to download baseball Hall of Fame
data from the package tidyverse are:
library(tidyverse)
-- Attaching packages --
Working my way through a tutorial named Data Carpentry
(https://datacarpentry.org/R-ecology-lesson/). for the most part it is
excellent but I’m stuck on the very last section
(https://datacarpentry.org/R-ecology-lesson/05-r-and-databases.html).
First, below are the packages I have loaded:
[1]
Row Outs RunnerFirst RunnerSecond RunnerThird R1 R2 R3
1 0
2 1
3 1
4 1 arenn001
5 2 arenn001
6 0
7 0 perad001
8 0 polla001 perad001
9 0 goldp001 polla001 perad001
10 0 lambj001
In the Source window of RStudio (upper left) I save my code (File/Save) but can
not reload it. There is a file labeled (RECode.R) but neither File/Open file
or File/Recent Files gets me anywhere.
Any ideas what I’m doing wrong.
[[alternative HTML version deleted]]
_
With the snippet of data below I’m trying to do an if/then type of thing:
row 1 – if all five variables equal 0 then code equals 1;
row 3 – if v1 = 1 and v2 = 1 then code = 5;
row 7 – if v1 = 0 and v2 = 1 and v3 = 2 then code = 10
There are 24 codes in the complete database.
v1 v2
Just when I think I’m starting to get the hang of R I run into something that
sends me back to Go without collecting $200.
The working directory seems to be correct when I load an .rda file but it is
not there and it is not in the Global Environment in the upper right hand
window in RStudio.
ge
The date is imbedded in the GameID character field so I created a date vector
with the following code:
ari18.test3$date <- substring(ari18.test3$GameID,4,11) And then created a new
dataframe with just the Game ID and date vectors. The date field is a
character as shown by the str() command. s
Still putzing around trying to increment a count vector when the date changes.
Date count
1 2018-03-29 1
2 2018-03-29 1
3 2018-03-29 1
81 2018-03-30 1
82 2018-03-30 1
83 2018-03-30 1
165 2018-03-31 1
166 2018-03-31 1
167 2018-03-31 1
I can
With the data snippet below I’m trying to increment the “count” vector by one
each time the date changes.
Date count
1 2018-03-29 1
2 2018-03-29 1
3 2018-03-29 1
81 2018-03-30 1
82 2018-03-30 1
83 2018-03-30 1
165 2018-03-31 1
166 2018-03-31 1
1
Attached is every at bat for the Arizona Diamondback’s first three games of
2018 – BBdata1.rda. I added the Date and DHCode variables by parsing the first
variable labeled GameID.
BBdata2 is a reduced dataset with five variables as shown in the str() command.
data.frame':234 obs. of 5 var
13 matches
Mail list logo