alperyilmaz / dav-assignments

Assignment contents for Data Analysis and Visualization course
0 stars 0 forks source link

DataCamp yanlış kodu hata olarak veriyor olabilir mi ? #3

Open OgunMorkoc opened 6 years ago

OgunMorkoc commented 6 years ago

https://github.com/alperyilmaz/dav-assignments/blob/aff59347e23297d4f7ad1bc76e9db44bbe2a8fdc/week04/assignment-next-week-dplyr#L53

Aggregate function kısmında aşağıdaki kodu yazdığım zaman ;

Remove rows that have NA ArrDelay: temp1

temp1 <- filter(hflights, !is.na(ArrDelay))

Generate summary about ArrDelay column of temp1

summarise(temp1, earliest = min(ArrDelay), average = mean(ArrDelay), latest = max(ArrDelay), sd = sd(ArrDelay))

Keep rows that have no NA TaxiIn and no NA TaxiOut: temp2

temp2 <- filter(hflights, !is.na(TaxiIn), !is.na(TaxiOut))

Print the maximum taxiing difference of temp2 with summarise()

temp2 <- mutate(temp2, taxi_diff = abs(TaxiIn - TaxiOut)) summarise(temp2, max_taxi_diff = max(taxi_diff))

üçüncü kısım ile ilgili şu hatayı alıyorum ; Incorrect submission There is something wrong with your code to calculate temp2. Use both !is.na(TaxiIn) and !is.na(TaxiOut) inside filter().

fakat hata nın bu olduğu düşünmüyorum. ipucu aldığım zaman ise ; Hint You'll need !is.na() inside filter() to remove observations that have NA variables. For temp2, you need !is.na() twice in combination with & (or with commas inside filter()).

zaten yaptığımdan farklı bir şey söylemiyor.

sorunun doğru cevabı ise aşağıdaki gibiymiş;

Remove rows that have NA ArrDelay: temp1

temp1 <- filter(hflights, !is.na(ArrDelay))

Generate summary about ArrDelay column of temp1

summarise(temp1, earliest = min(ArrDelay), average = mean(ArrDelay), latest = max(ArrDelay), sd = sd(ArrDelay))

Keep rows that have no NA TaxiIn and no NA TaxiOut: temp2

temp2 <- filter(hflights, !is.na(TaxiIn), !is.na(TaxiOut))

Print the maximum taxiing difference of temp2 with summarise()

summarise(temp2, max_taxi_diff = max(abs(TaxiIn - TaxiOut)))

doğru cevabı incelediğim zaman ise verilen hata nın (# Keep rows that have no NA TaxiIn and no NA TaxiOut: temp2 ) ile ilgili değil son kısım (Print the maximum taxiing difference of temp2 with summarise()) ile ilgili olduğunu görüyorum. Fakat bu şekilde bile benim yazdığım kodun sonucu (141) ile doğru cevabın sonucu da aynı çıkıyor. Acaba datacamp tan kaynaklanan bir problem mi mevcut yoksa ben mi durumu yanlış anladım ?

Teşekkürler

yukarıdaki kodların ekran alıntıları ;

image image

canankolakoglu commented 6 years ago

Benzer bir problemle bende karşılaştım. Aslında aynı sonucu almıştım ama görüntülemek için vs. ekstradan işlem eklemiştim hata verdi cevaba baktığımdaysa aslında eksik bişey yazmadığımı gördüm. Sadece kodu tek satırda değilde birkaç satırda yazmıştım. Burda da anladığm kadarıyla "Incorrect submission There is something wrong with your code to calculate temp2. Use both !is.na(TaxiIn) and !is.na(TaxiOut) inside filter()." hatasını senin yazdığın koddaki 14. satır için veriyor. Sanırım sen temp2 yi dördüncü kısımdaki kod için ara basamak yapmışsın ve değerini değiştirmişsin. temp2 değeri değiştiği için de hata vermiş yani aslında hatayı dördüncü kısımda alıyorsun anladığım kadarıyla. Dördüncü kısım için temp2 değerini değiştirmeden direk olarak "summarise(mutate(temp2, taxi_diff = abs(TaxiIn - TaxiOut)), max_taxi_diff = max(taxi_diff))" yazınca hata vermiyor.

OgunMorkoc commented 6 years ago

Öncelikle yorumun için teşekkür ederim. Fakat benim kafamı karıştıran hatanın dördüncü kısımda olmasına rağmen hata mesajının beni ikinci kısma yönlendirmesi olmuştu. Ayrıca evet dediğin gibi dördüncü kısım da temp2 değerini ara basamak yapmayınca bu şekilde de ; "a <- mutate(temp2, taxi_diff = abs(TaxiIn - TaxiOut)) summarise(a, max_taxi_diff = max(taxi_diff))" hata vermiyormuş.

alperyilmaz commented 6 years ago

Actually, DataCamp is expecting an operator between multiple conditions. There should be AND (&) or OR (|) operator. So the expected answer is:

temp2 <- filter(hflights,!is.na(TaxiIn) & !is.na(TaxiOut) )
alperyilmaz commented 6 years ago

Sorry, filter() accepts both comma and AND, so comma is not the problem.

DataCamp compares your code with the solution and it does not check only the results. So, If you arrive the same solution with different commands, it will complain about it.

In your case, even though your result is correct, the additional mutate() step triggers error message, since only summarise() based solution is expected.

OgunMorkoc commented 6 years ago

Thank you for the attention. Eventually ı understand that DataCamp compare my code with solution but As my friend canan state above my problem is more about use of temp2 value as an intermediate step because when ı run ; a <- mutate(temp2, taxi_diff = abs(TaxiIn - TaxiOut)) summarise(a, max_taxi_diff = max(taxi_diff))" instead of ; "temp2 <- mutate(temp2, taxi_diff = abs(TaxiIn - TaxiOut)) summarise(temp2, max_taxi_diff = max(taxi_diff))" it also work. However when ı did this mistake DataCamp direct me to the row 10 by saying; "You'll need !is.na() inside filter() to remove observations that have NA variables. For temp2, you need !is.na() twice in combination with & (or with commas inside filter())."

which confuse me initially but now ı am clear about that ı should not use temp2 as an intermediate step
in the row 13. Again thank you for your attention the screen shot of my answer is below; image