Skip to content

error while using shapiro.test()

4 messages · R. Michael Weylandt, spicymchaggis101, Peter Ehlers +1 more

#
Mr McHaggis,

I'm not sure what "  i'm having issues when it comes to reading my
data in rows rather than columns " means, but here's some thoughts on
your problem:

ExData <- structure(list(Noun = c(21L, 26L, 31L, 37L, 22L, 12L, 22L, 12L,
27L, 20L, 21L, 29L, 16L, 23L, 29L, 33L, 29L, 24L, 28L, 32L, 19L,
19L, 19L, 29L, 34L, 27L, 13L, 17L, 21L, 28L), Verb = c(4L, 4L,
6L, 4L, 3L, 8L, 5L, 11L, 7L, 4L, 6L, 1L, 19L, 6L, 5L, 7L, 4L,
7L, 2L, 5L, 6L, 7L, 4L, 8L, 9L, 9L, 11L, 7L, 6L, 4L), adverb = c(9L,
5L, 6L, 6L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 2L, 0L, 0L, 0L,
0L, 1L, 0L, 0L, 3L, 1L, 3L, 0L, 1L, 5L, 0L, 0L, 0L), Adjective = c(1L,
3L, 0L, 0L, 10L, 9L, 5L, 12L, 10L, 10L, 6L, 8L, 8L, 5L, 2L, 3L,
2L, 7L, 3L, 7L, 5L, 4L, 5L, 4L, 1L, 3L, 9L, 10L, 7L, 5L), Preposition = c(1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Total = c(36L,
38L, 43L, 47L, 36L, 29L, 32L, 35L, 45L, 36L, 34L, 38L, 43L, 36L,
36L, 43L, 35L, 39L, 34L, 44L, 30L, 33L, 30L, 44L, 44L, 40L, 38L,
34L, 34L, 37L)), .Names = c("Noun", "Verb", "adverb", "Adjective",
"Preposition", "Total"), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
"25", "26", "27", "28", "29", "30"))

x1 <- data[1, 1:5] ## Why do you use c() here to combine a single line
with itself? This actually converts your data frame to a list, which
causes your problem

shapiro.test(x1) ## Still will not work because data frames don't
coerce to vectors, perhaps you meant to just extract the values, in
which case you need to add

shapiro.test(as.numeric(x1))

# but it seems more likely that you mean to get a column's worth of data:

shapiro.test(ExData[1:5,1])

Does this help?

Michael Weylandt

If you have some basic programming background, take a look at chapter
2 of the R language definition to get a solid explanation of what all
this talk of numeric/atomic/data frame/list is going on about.
On Fri, Sep 30, 2011 at 6:59 PM, spicymchaggis101 <jami5490 at mylaurier.ca> wrote:
1 day later
#
On 2011-10-01 09:24, spicymchaggis101 wrote:
You may want to review just what the test does. It certainly does not
give you the 'probability of normality'. A worthwhile exercise might
be to test several other distributions on your data.

Peter Ehlers
#
Em 1/10/2011 13:24, spicymchaggis101 escreveu:
You need to insure this assumption is reasonable for your problem domain 
as words types per page seems like count data for me and for this kind 
of data Gaussian distributions are at the very best last resort 
approximations.

--
Cesar Rabak