1

I have a csv file that I loaded to R. It is built in long format with each subject underwent several observations. Therefore, in the column "subject", subject number 1 appeared in 30 cells in this column, for example, and so the other 51 subjects. R is relating to the total number of subjects as 1530 instead of 51!!

How can I tell R to count the number of subjects correctly?

itsMeInMiami
  • 2,324
  • 1
  • 13
  • 34
Ranin
  • 11
  • 1
  • 1
    `length(unique(data$subject))` – bouncyball Aug 17 '20 at 17:10
  • great it worked!! thanks – Ranin Aug 17 '20 at 17:15
  • but in the analysis will it take into account the 51 subjects automatically? – Ranin Aug 17 '20 at 17:16
  • 5
    Ranin, welcome to SO! Questions on SO (especially in R) do much better if they are reproducible and self-contained. By that I mean including attempted code (please be explicit about non-base packages), sample representative data (perhaps via `dput(head(x))` or building data programmatically (e.g., `data.frame(...)`), possibly stochastically after `set.seed(1)`), perhaps actual output (with verbatim errors/warnings) versus intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Aug 17 '20 at 17:30
  • thank you for the clarification, i'll try to be more specific in the next questions :) – Ranin Aug 18 '20 at 06:55

0 Answers0