Error: Object "seat1" Not Found

Hello, I am new to learning R (mostly through datacamp) and it appears the dataset I'm trying to work with is loaded correctly. It is a .csv file with variable names as the columns and data for each participant in each row. Each column is an item from a scale (e.g. SEAT1-SEAT24, RSE1-RSE10). I'm a psychologist and created a scale with my psych testing class in the spring. I'm also much more used to programs like SPSS, JASP, and JAMOVI, so this has been challenging.

I'll try to include screen capture, but the data set looks like this....

SEAT1 SEAT2 SEAT3
5 7 1
2 6 5

I attempted to sum the SEAT items by entering (for example)

sum(SEAT1, SEAT2, SEAT3)

and I get back an error stating that the object 'seat1' is not found. When I call up variable names it lists all of the 60 columns for the different variables I have. So its all in there.

I'm sure I'm missing something and appreciate any thoughts you may have. Thank you!!

I would usually reshape the data to have a column describing the variable and a column for the value. Nevertheless, here are some ways to sum an entire data frame or a subset of the columns.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
df <- data.frame(Seat1 = 1:5, Seat2 = 6:10, Seat3 = 11:15, NotSeat1 = 1:5)
df
#>   Seat1 Seat2 Seat3 NotSeat1
#> 1     1     6    11        1
#> 2     2     7    12        2
#> 3     3     8    13        3
#> 4     4     9    14        4
#> 5     5    10    15        5
sum(df)
#> [1] 135

#select columns whose name starts with Seat
df2 <- df %>% select(starts_with("Seat"))
df2
#>   Seat1 Seat2 Seat3
#> 1     1     6    11
#> 2     2     7    12
#> 3     3     8    13
#> 4     4     9    14
#> 5     5    10    15
sum(df2)
#> [1] 120

Created on 2019-08-14 by the reprex package (v0.2.1)

Hi @ericphd! Yours is a common situation. You might find these articles, examples, and books helpful, since they're aimed directly at people trying to translate their prior experience with other statistical software into R terms: http://r4stats.com/

We also have a whole thread on this site where people chimed in with their favorite resources for people new to R:

And of course, please keep asking questions here :grinning:

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