psu-spatial / Stat462-2024

Lab book for STAT462, SP2024
https://psu-spatial.github.io/Stat462-2024/
0 stars 0 forks source link

2.6 Overwrite? #54

Open rudrabengali opened 8 months ago

rudrabengali commented 8 months ago

What do you mean by remove and overwrite in question 2.6? Does that mean just replace all with NA?

hgreatrex commented 8 months ago

I mean - remove the data I ask, then save the result to the same variable name. For the removal part, see https://psu-spatial.github.io/Stat462-2024/T9_wrangling.html#Missing

For example, here I calculate 2+2 and save the answer to the variable 'a'. Then in the second line, I add 3 to the answer - then overwrite a.

a <- 2+2
print(a)
> 4
a <- a + 3
print(a)
> 7

Does that answer the bit you were confused about?

Created on 2024-02-29 with reprex v2.0.2

rudrabengali commented 8 months ago

Not completely since we're first removing for that portion, and I'm not sure what removing means. Do you want us to use na.omit?

aboudazz commented 8 months ago

It sounds like you're dealing with missing data and considering how best to handle it for your analysis. Using na.omit() is one approach to removing rows with NA values from your dataset. This function will indeed omit any row containing at least one NA, helping to ensure that subsequent data analysis isn't skewed by missing values. However , Omitting rows with missing values can lead to significant data loss, especially if NAs are widespread. Assess how much of your data would be discarded by using na.omit() and whether this loss is acceptable for your analysis.