Help explaining basic R

image

Can someone please help me understanding this code.
Why is there a comma before the c and what does the number 5 do? I assume 23:28 takes the number from 23 to 28?

Sorry I'm new at this so I'm kinda lost

Hello and welcome in the forum,

the code you provided selects specific columns, but let's break the code down:

  • table[...,...] indicates, that you want to subset the table (here Mouse) by first rows and second columns
  • the empty space (e.g. nothing at all) before the comma says, that you want to have all (so no specific) rows
  • the c(5,23:28) creates a vector: (5,23,24,25,26,27,28)

combining everything yields to a subset of your Mouse table, with all rows and the columns of the specified vector, namely 5 and the columns 23 to 28.

Hope this helps you to understand some of the basics in R

Kind regards

2 Likes

Thanks!!!
If you have time I have another issue due to Fat_protein colonne isn't nummeric.
I have tried to fix it by using as.factor but it doesn't work....

Code:

Data:

Since this is a (completely) different question, you should open up a new request in the forum and provide at least the following:

  • all libraries you use for the functions which cause a problem for you
  • a bit of data to replicate the issue (e.g. with dput(mydata) and pasted into the forum)
  • a brief description of the concrete issue, e.g. what you try to do and what error exactly occurs

This way you help the forum members to understand your request and find suitable solutions. Try to avoid screenshots, since it's considered bad practice.

Kind regards

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.