Wow, thanks! I'm actually a man, though coming from one of the few countries where "Andrea" is masculine, this happens to me frequently!
This reprex is a good start! However, note that the goal of creating a reproducible example is to provide others with code that they can run on their own machine, thus you shouldn't load data from your HD in your reprex:
eurdata <- read_csv("C:/Users/Stephanie Pugh/R/WEUR_GDP_SPSales.csv")
I wouldn't be able to reproduce the results on my machine, since I don't have that file. You should load the data on your machine, create eurdata_small
, apply dput
to eurdata_small
and then include only the output of dput
in the reprex. Similarly, the reprex
doesn't have to be included in your reproducible example: for more information, see for example Reprex do's and don'ts • reprex and [Video] Reproducible Examples and the `reprex` package. The final output would be something like
library(xts)
#> Error in library(xts): there is no package called 'xts'
library(zoo)
#> Error in library(zoo): there is no package called 'zoo'
library(astsa)
#> Error in library(astsa): there is no package called 'astsa'
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggplot2)
eurdata_small <- structure(list(Country = c("Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria",
"Austria", "Austria", "Austria", "Austria", "Austria", "Belgium",
"Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium",
"Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium",
"Belgium", "Belgium", "Denmark", "Denmark", "Denmark", "Denmark",
"Denmark", "Denmark", "Denmark", "Denmark", "Denmark", "Denmark",
"Denmark", "Denmark", "Denmark", "Denmark", "Denmark", "Finland",
"Finland", "Finland", "Finland", "Finland"), Year = c(2003L,
2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
2013L, 2014L, 2015L, 2016L, 2017L, 2003L, 2004L, 2005L, 2006L,
2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L,
2016L, 2017L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 2003L,
2004L, 2005L, 2006L, 2007L), GDP = c(261695L, 300904L, 315974L,
335998L, 388691L, 430294L, 400172L, 391892L, 431120L, 409425L,
430068L, 441885L, 382065L, 390799L, 416595L, 319002L, 370885L,
387365L, 409813L, 471821L, 518625L, 484552L, 483548L, 527008L,
497884L, 520925L, 530770L, 455039L, 467545L, 492681L, 218095L,
251373L, 264467L, 282884L, 319423L, 353361L, 321241L, 321995L,
344003L, 327148L, 343584L, 352993L, 301298L, 306899L, 324871L,
171071L, 196768L, 204436L, 216552L, 255384L), Sales = c(2.4,
2.93, 3.23, 3.39, 3.56, 3.56, 3.59, 3.98, 4.17, 4.32, 4.35, 4.32,
4.33, 4.37, 4.41, 3.34, 3.92, 4.36, 4.24, 4.22, 4.15, 4.36, 4.88,
4.9, 4.98, 5.02, 5.05, 5.1, 5.15, 5.21, 2.18, 2.25, 2.26, 2.69,
2.89, 2.68, 2.72, 3.02, 3.17, 3.23, 3.29, 3.31, 3.32, 3.35, 3.37,
1.39, 1.46, 1.78, 1.91, 1.98)), row.names = c(NA, -50L), class = c("tbl_df",
"tbl", "data.frame"))
lreg <- with(eurdata_small, lm(GDP ~ Sales))
summary(lreg)
#>
#> Call:
#> lm(formula = GDP ~ Sales)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -50703 -22525 -5056 11704 101281
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 61745 16590 3.722 0.000519 ***
#> Sales 85686 4477 19.141 < 2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 32510 on 48 degrees of freedom
#> Multiple R-squared: 0.8842, Adjusted R-squared: 0.8817
#> F-statistic: 366.4 on 1 and 48 DF, p-value: < 2.2e-16
Created on 2018-10-07 by the reprex package (v0.2.1)
However, this is mostly for your information. Let's come back to your question: what is the problem you're having, exactly? With your reprex, you were able to share a subset of those data with us: But I don't see any error message in your reprex: you successfully manage to fit a linear regression model to your data, so this is clearly not your stumbling block. What is it that you need help with? Can you 1) explain in words what you would like to do and 2) include in the reprex the commands that you try, and which fail?