Open Taesian33 opened 5 years ago
Hello Taesian33, For the temperature question, I used the following code and it returned the appropriate value:
ConvertToCelsius <- function( fahrenheit )
{
celsius <- ( fahrenheit - 32 ) * 5/9
temp.in.fahrenheit <- round( celsius )
return( temp.in.fahrenheit)
}
temp.in.fahrenheit <- 212
ConvertToCelsius( temp.in.fahrenheit )
That works!
I think you mixed up your naming conventions though:
ConvertToCelsius <- function( fahrenheit )
{
celsius <- ( fahrenheit - 32 ) * 5/9
temp.in.celsius <- round( celsius )
return( temp.in.celsius ) # you should be returning in celsius
}
temp.in.fahrenheit <- 212
ConvertToCelsius( temp.in.fahrenheit )
@Taesian33 I will try to include solutions where I can. Feel free to post a question here if you are stuck or something doesn't make sense. Others probably have similar questions!
I was lost, then I thought I was found, but now I'm beyond lost. I feel like now I'm lost AND blind.
head( dat, 10 )
head( dat$owner, 10 ) # preview a vector
What does that mean?
This is Courtney's code:
ConvertToCelsius <- function( fahrenheit )
{
celsius <- ( fahrenheit - 32 ) * 5/9
temp.in.fahrenheit <- round( celsius )
return( temp.in.fahrenheit)
}
temp.in.fahrenheit <- 212
ConvertToCelsius( temp.in.fahrenheit )
If we think about it as a recipe instead of a function:
temp.in.fahrenheit <- 212
temp.in.celsius <- ( temp.in.fahrenheit - 32 ) * 5/9
temp.in.celsius <- round( temp.in.celsius )
temp.in.celsius
I just pointed out that in the middle of the function she had converted the temperature to Celsius, but then renamed it Fahrenheit.
ConvertToCelsius <- function( fahrenheit )
{
celsius <- ( fahrenheit - 32 ) * 5/9
temp.in.FAHRENHEIT <- round( celsius ) # should be CELSIUS
return( temp.in.FAHRENHEIT ) # should be CELSIUS
}
temp.in.fahrenheit <- 212
ConvertToCelsius( temp.in.fahrenheit )
The code still works, it's just confusing to someone trying to understand what it is actually doing. Why would rounding the celsius temperature change the value to fahrenheit? It doesn't actually, we are just labeling it incorrectly.
head()
prints the first six lines of a dataset or the first six values from a vector. tail()
does the same thing but for the last six lines or values. They are functions to let you peek at your dataset without printing the whole thing on your screen (like if you just type dat
).
On the lab, head( dat, 10 )
is what produces this data preview after knitting:
### I think I'm back in the game
This is Courtney's code:
ConvertToCelsius <- function( fahrenheit ) { celsius <- ( fahrenheit - 32 ) * 5/9 temp.in.fahrenheit <- round( celsius ) return( temp.in.fahrenheit) } temp.in.fahrenheit <- 212 ConvertToCelsius( temp.in.fahrenheit )
If we think about it as a recipe instead of a function:
temp.in.fahrenheit <- 212 temp.in.celsius <- ( temp.in.fahrenheit - 32 ) * 5/9 temp.in.celsius <- round( temp.in.celsius ) temp.in.celsius
I just pointed out that in the middle of the function she had converted the temperature to Celsius, but then renamed it Fahrenheit.
ConvertToCelsius <- function( fahrenheit ) { celsius <- ( fahrenheit - 32 ) * 5/9 temp.in.FAHRENHEIT <- round( celsius ) # should be CELSIUS return( temp.in.FAHRENHEIT ) # should be CELSIUS } temp.in.fahrenheit <- 212 ConvertToCelsius( temp.in.fahrenheit )
The code still works, it's just confusing to someone trying to understand what it is actually doing. Why would rounding the celsius temperature change the value to fahrenheit? It doesn't actually, we are just labeling it incorrectly.
Ah, thank you! I missed that detail.
@castower CAN you please explain what was the difference between yours and his? I'm going over it with a fine comb and failing to realize what was wrong or different btw the 2?
@lecy Regarding LAB 1, I am having problems in regards to I'm not sure what to type in, I'm not even sure where to look up the information.
@castower CAN you please explain what was the difference between yours and his? I'm going over it with a fine comb and failing to realize what was wrong or different btw the 2?
It's simply that I named the function temp.in.fahrenheit when it should have been named temp.in.celsius because the units had already been converted.
@castower right.
How are you doing on Lab 1?
@castower right.
How are you doing on Lab 1?
I was able to complete it, but I can't get it to knit for submission.
@castower right. How are you doing on Lab 1?
I was able to complete it, but I can't get it to knit for submission.
Knit?
This might help with knit:
I'm reviewing the Overview again.
Would it be possible to have the correct answer somewhere?
I'm not sure if I'm doing things correctly, obviously, when I get ERROR I'm not, but for example, the Temperature questions, I think it would be really helpful to see an example.