pearselab / r-intro-jocelyn-cuthbert

r-intro-jocelyn-cuthbert created by GitHub Classroom
0 stars 0 forks source link

Broke my session #4 genetics #9

Closed jocelyn-cuthbert closed 7 years ago

jocelyn-cuthbert commented 7 years ago

So I thought I had totally got the genetics question - we worked on it in class a bit so I was able to get some help on the way to set up sapply to divide the sequence into portions of 3 for the codons which I struggled with. However I am getting some error messages I can't quite pin down when I try to run it that seem to stem from my function - it says I am trying to apply a non-function. Which I assume means I quite messed up in correctly putting together my function, but I am a bit confused as whether it is just the whole thing or one specific part, as the error seems to just generalize to the whole thing. I played with the way I had the DNA sequence put as an object, which changed the error message to the function. Thank you again for all the help! I am sorry if exactly none of that is written in the correct way!

willpearse commented 7 years ago

The error is coming from this line colnames(codontable)("ATG", "TAA", "TGT", "TCC") - can you see what's wrong about this? Hint: where's <-?

While here, I noticed something gone wrong with your answer to question 1: you've made a dataset of 10 variables each of length 1, which R is turning into a vector. That's fine for question 1 (although you might as well do 10 for 10) but it's not fine for the next few questions. You need to write functions that take data.frames and summarise them. See if using sapply on a data.frame to calculate column averages, or apply on a matrix to calculate column averages, will help you write a function that examines all the columns in a dataset at the same time.

willpearse commented 7 years ago

The error is coming from this line colnames(codontable)("ATG", "TAA", "TGT", "TCC") - can you see what's wroThe error is coming from this line colnames(codontable)("ATG", "TAA", "TGT", "TCC") - can you see what's wrong about this? Hint: where's <-?

While here, I noticed something gone wrong with your answer to question 1: you've made a dataset of 10 variables each of length 1, which R is turning into a vector. That's fine for question 1 (although you might as well do 10 for 10) but it's not fine for the next few questions. You need to write functions that take data.frames and summarise them. See if using sapply on a data.frame to calculate column averages, or apply on a matrix to calculate column averages, will help you write a function that examines all the columns in a dataset at the same time.ng about this? Hint: where's <-?

While here, I noticed something gone wrong with your answer to question 1: you've made a dataset of 10 variables each of length 1, which R is turning into a vector. That's fine for question 1 (although you might as well do 10 for 10) but it's not fine for the next few questions. You need to write functions that take data.frames and summarise them. See if using sapply on a data.frame to calculate column averages, or apply on a matrix to calculate column averages, will help you write a function that examines all the columns in a dataset at the same time.

jocelyn-cuthbert commented 7 years ago

Ok....so I think I fixed the codon issues but now I am getting no error messages...but either NULL or character 0 instead of actual protein lists. So I would assume my function is working but that I did something wrong in the return or match piece of it?