Function to remove NA

master
Marc Gauch 2022-12-02 14:40:39 +01:00
parent 6584495be7
commit fc8d0245bc
2 changed files with 18 additions and 5 deletions

View File

@ -1544,6 +1544,12 @@ and adapted</em></p>
uniqv[which(x == max(x))]
}</code></pre>
</div>
<div id="remove-na" class="section level2" number="2.3">
<h2><span class="header-section-number">2.3</span> Remove NA</h2>
<pre class="r"><code>removeNA &lt;- function(d){
return(d[!is.na(d)])
}</code></pre>
</div>
</div>
<div id="load-data" class="section level1" number="3">
<h1><span class="header-section-number">3</span> Load Data</h1>
@ -2392,9 +2398,8 @@ gibt.</p>
<div id="selbststudium-2.1" class="section level1" number="6">
<h1><span class="header-section-number">6</span> Selbststudium 2.1</h1>
<p>We have the year 2021 ## Preparation</p>
<pre class="r"><code>birthyears &lt;- litdata$D7
# remove NAs
birthyears &lt;- birthyears[!is.na(birthyears)]
<pre class="r"><code># remove NAs
birthyears &lt;- removeNA(litdata$D7)
age &lt;- 2021 - birthyears</code></pre>
<div id="frequency" class="section level2" number="6.1">
<h2><span class="header-section-number">6.1</span> Frequency</h2>

View File

@ -71,6 +71,15 @@ getmode <- function(v) {
}
```
## Remove NA
```{r}
removeNA <- function(d){
return(d[!is.na(d)])
}
```
# Load Data
## Load from CSV
``` {r loadData}
@ -352,9 +361,8 @@ displayFunction1(litdata, "D8")
We have the year 2021
## Preparation
```{r}
birthyears <- litdata$D7
# remove NAs
birthyears <- birthyears[!is.na(birthyears)]
birthyears <- removeNA(litdata$D7)
age <- 2021 - birthyears
```