RockefellerUniversity / Intro_To_R_1Day

Introduction to R training course
https://rockefelleruniversity.github.io/Intro_To_R_1Day/
3 stars 2 forks source link

Column Layout #34

Closed Nick-Poulton closed 4 years ago

Nick-Poulton commented 4 years ago

For the exercise reagarding "Reading and writing data in R" I had some trouble with the way the data was arranged.

I imported "GeneExpression.txt" and it looked similar to the example in the exercise, the difference is that I had 4 columns reading (Sample_1.hi, Sample_2.hi, Sample_3.hi, Sample_4.low) on top and 2 columns below (Sample_5.low, Sample_1.low). When I tried to take the mean specifying each of the 6 columns, it gave 4 values as an output.

I ended up with the right answer by using the colMeans function, but do you know why it was only giving me 4 mean values? Was it interpreting the stacked columns as a single column?

Thanks in advance!

ThomasCarroll commented 4 years ago

I think this may be the way this displayed in R. Could you provide a short code example?

Nick-Poulton commented 4 years ago

Hi Tom,

Thanks so much for your response and sorry for my delay. I've provided my code below and a screenshot of what my table looks like. I re-imported the file using "read.table" and ran everything again with the following command (which I was using before) and it gave out 6 values this time, instead of 4. I'm not sure what was happening earlier but it seems to be working now.

samplemeans <-c(mean(geneExpression[,1]),mean(geneExpression[,2]),mean(geneExpression[,3]),mean(geneExpression[,4]),mean(geneExpression[,5]),mean(geneExpression[,6]))

20200605 Bioinformatics Column Issue