I'm pretty new to coding in R and am doing an assignment where my task is to create a contingency table. My sample data of News Inquiries in Texas examines the variables: Day,Section(News, Sports ,or Business), and number of Inquiries. From what I have looked up I should be able to use the table() command but that doesn't seem to be working. My code is as follows:
NewsData <- read.csv(file.choose(),header=TRUE,sep=',')
table(NewsData$Day,NewsData$Section)
But when I run it it returns this.
'''
Business News Sports
Monday 4 4 4
Tuesday 4 4 4
Wednesday 4 4 4
Thursday 4 4 4
Friday 4 4 4
'''
I have checked the numbers and those are not accurate. I'm not sure what its doing. Is there something I'm missing or forgetting to do?
Edit: I have attached a sample of my data using:
dput(NewsData[1:20,])
The output is as follows:
structure(list(X = 1:20, Day = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L),
.Label = c("Monday",
"Tuesday", "Wednesday", "Thursday", "Friday"), class = "factor"),
Inquiries = c(14L, 11L, 9L, 11L, 12L, 13L, 13L, 15L, 11L,
12L, 12L, 14L, 7L, 8L, 6L, 8L, 16L, 15L, 14L, 17L), Section =
c("News",
"News", "News", "News", "News", "News", "News", "News",
"News",
"News", "News", "News", "News", "News", "News", "News",
"News",
"News", "News", "News")), row.names = c(NA, 20L), class =
"data.frame")