Skip to content

Commit

Permalink
Submission for Lab 3 (as is)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-K-Addo committed Feb 2, 2023
1 parent 02f871a commit 58013b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ sispille(123, pi)

num 123
num 3.14
[1] "0000000008561368"
[1] "000000000a13dfb8"
[1] "0000000009942258"
[1] "000000000b50ca98"

Knit the document, commit your changes, and push them to GitHub.

Expand Down Expand Up @@ -147,6 +147,16 @@ Write a function that fits a linear regression model and saves the
result to the global environment using the `assign()` function. The name
of the output must be passed as a symbol using lazy evaluation.

``` r
fitRegModel <- function(x,y){
assign("fitLinear", y~x, envir = .GlobalEnv)
}

x <- 1:100
y <- rnorm(100,10,10)
fitRegModel(x,y)
```

Knit the document, commit your changes, and push them to GitHub.

# Part 3: Data.table
Expand All @@ -162,6 +172,8 @@ Knit the document, commit your changes, and push them to GitHub.
during the lecture to pre-process the stations’ data:

``` r
library(data.table)

# Download the data
stations <- fread("ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-history.csv")
stations[, USAF := as.integer(USAF)]
Expand Down
7 changes: 7 additions & 0 deletions README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ Knit the document, commit your changes, and push them to GitHub.
Write a function that fits a linear regression model and saves the result to the global environment using the `assign()` function. The name of the output must be passed as a symbol using lazy evaluation.

```{r}
fitRegModel <- function(x,y){
assign("fitLinear", y~x, envir = .GlobalEnv)
}
x <- 1:100
y <- rnorm(100,10,10)
fitRegModel(x,y)
```

Knit the document, commit your changes, and push them to GitHub.
Expand All @@ -140,6 +146,7 @@ Knit the document, commit your changes, and push them to GitHub.
```{r}
#| label: stations-data
#| eval: false
library(data.table)
# Download the data
stations <- fread("ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-history.csv")
Expand Down

0 comments on commit 58013b6

Please sign in to comment.