"unused argument" error

Hello,

I am writing the results/discussion portion of a psychology research methods paper.

I am trying to include a table in which I am reporting the means, standard deviations, and correlations among all variables in the study. The variables are photos (categorical, IV#1), memory score (ratio, DV), neuroticism score average (interval, covariate), and virtual human emotion (categorical,IV#2).

In my script I have tried to use prop.table() with each variable in the parentheses: prop.table(data$photos, data$memory, etc). I am ending up with an error that says "unused arguments (data$humans, data$memory)" -- different arguments appear in the parentheses when I change the order.

First, I would like to know if this is the function that I want to get a table that expresses what I have stated above. Second, I would like to know, if this is the right function, how I go about running this without an error.

Hi @Scannell_1! I haven't used prop.table myself, but going by the documentation it looks like it only takes two arguments: one is the table you're operating on, and the other, margin, is a vector of all of the indices you want to generate a margin on.

I can't be sure without seeing the context of your code, but it seems like you're trying to provide each table column as a separate argument. Since prop.table only expects two arguments, it ignores the others, rather than saying, "Hey, I'm guessing these other arguments are probably meant to be for the margin too." Trying combining them into a vector with c(), like:

prop.table(
  data,
  c(data$photos, data$memory, data$humans, data$theotherone))

Lemme know how you go! :slightly_smiling_face:

1 Like

Assuming that photos, memory, etc. are variables (columns) in a data frame called data, then I'm afraid prop.table isn't going to work with @rensa's suggestion, either.

Here's what prop.table does: you give it a table of counts and tell it which margin(s) of the table you want to summarize over, then it converts the counts into proportions. If you give it a vector (a single list of values), it divides each value by the sum of all the values. If you combine a bunch of data frame columns into a vector using c(), then it will give you something pretty nonsensical — all the numbers from the different columns in one long list, divided by the sum of that list.

Aside: what I mean by "table"...

When you see the term "table" in this context, it doesn't mean any old information presented in columns and rows — here, it specifically means the result of cross tabulation. So in the typical case, you feed prop.table a matrix or the output from a cross tabulation function (e.g., table, xtabs).

It would help a lot to see a sample of your data and an example of the kind of table you have in mind — but in the meantime, I'm not sure I see how prop.table fits into your goals?

It sounds like you want to:

  1. Calculate summary stats about your dependent variable (and maybe also your covariate?)
  2. Fit a model? (I'm going off of "correlations among all variables" here)
  3. Report all this information in tabular form

But I don't know whether you're trying to figure out how to do all those steps, or if you've already done steps 1 and 2, and are just looking for a way to do 3?

1 Like