[R] TRUNCATED error with data frame

Julian Burgos jmburgos at u.washington.edu
Wed Nov 14 01:07:05 CET 2007


Hi Amit,

Please read carefully the Mailing List Posting Guide (available at 
http://www.r-project.org/posting-guide.html).  In particular, this section:

"For new subjects, compose a new message and include the 
'r-help at lists.R-project.org' (or 'r-devel at lists.R-project.org') address 
specifically. (Replying to an existing post and then changing the 
subject messes up the threading in the archives and in many people's 
mail readers.)"

About your question.  You have a mistake in your model formula.  The 
basic way to code a formula in R is by doing y ~ 'model', where y is 
your dependent variable and 'model'.  Notice that '~' is not the same as 
'-'.  For details, see ?formula, or read the manual titled "An 
introduction to R" that can be found here 
http://cran.r-project.org/manuals.html.

Julian

apsawant wrote:
> Hi ,
> 
> I am trying to modify the same example script to calculate AOV.
> Below is the script file (aov.R) I am trying to execute:
> aov.R
> ------
> data1<-c(49,47,46,47,48,47,41,46,43,47,46,45,48,46,47,45,49,44,44,45,42,45,45,40
> ,49,46,47,45,49,45,41,43,44,46,45,40,45,43,44,45,48,46,40,45,40,45,47,40)
> 
> matrix(data1, ncol= 4, dimnames = list(paste("subj", 1:12),
> c("Shape1.Color1",
> "Shape2.Color1", "Shape1.Color2", "Shape2.Color2")))
> 
> Hays.df<-data.frame(rt = data1,
> subj=factor(rep(paste("subj", 1:12, sep=""), 4)),
> shape=factor(rep(rep(c("shape1","shape2"), c(12, 12)), 2)),
> color=factor(rep(c("color1","color2"), c(24, 24))))
> 
> aov(rt - shape * color + Error(subj/(shape * color)), data=Hays.df)
> 
> summary(aov(rt - shape * color + Error(subj/(shape * color)), data=Hays.df))
> 
> 
> Here is the error I get:
>> source("aov.R")
> Error in terms(formula, "Error", data = data) :
>         Object "shape" not found
> 
> I would appreciate your help as to why I am getting this error message.
> 
> Thanks,
> Amit.
> 
> 
> 
> Prof Brian Ripley wrote:
>> Try ?source: it is not an 'error'.
>>
>> max.deparse.length: integer; is used only if 'echo' is 'TRUE' and gives
>>            the maximal length of the printout of a single expression.
>>
>> So the 'echo' has been truncated at 150 characters, not the expression 
>> used.
>>
>> On Mon, 12 Nov 2007, apsawant wrote:
>>
>>> Hi ,
>>>
>>> I am new to R.
>>> I am trying to run a simple R script as shown below:
>>>
>>> aov.R
>>> ------
>>> data1<-c(49,47,46,47,48,47,41,46,43,47,46,45,48,46,47,45,49,44,44,45,42,45,45,40
>>> ,49,46,47,45,49,45,41,43,44,46,45,40,45,43,44,45,48,46,40,45,40,45,47,40)
>>>
>>> matrix(data1, ncol= 4, dimnames = list(paste("subj", 1:12),
>>> c("Shape1.Color1",
>>> "Shape2.Color1", "Shape1.Color2", "Shape2.Color2")))
>>>
>>> Hays.df<-data.frame(rt = data1,
>>> subj=factor(rep(paste("subj", 1:12, sep=""), 4)),
>>> shape=factor(rep(rep(c("shape1","shape2"), c(12, 12)), 2)),
>>> color=factor(rep(c("color1","color2"), c(24, 24))))
>>>
>>> I am getting the following error message:
>>>
>>> Output at the R prompt
>>> ----------------------
>>>
>>>> source("aov.R",echo=T)
>>>> data1 <- c(49, 47, 46, 47, 48, 47, 41, 46, 43, 47,
>>>    46, 45, 48, 46, 47, 45, 49, 44, 44, 45, 42, 45, 45, 40, 49,
>>>    46, 47, 45, 49, 45, 41, 43, 4 .... [TRUNCATED]
>>>
>>>> matrix(data1, ncol = 4, dimnames = list(paste("subj",
>>>    1:12), c("Shape1.Color1", "Shape2.Color1", "Shape1.Color2",
>>>    "Shape2.Color2")))
>>>        Shape1.Color1 Shape2.Color1 Shape1.Color2 Shape2.Color2
>>> subj 1             49            48            49            45
>>> subj 2             47            46            46            43
>>> subj 3             46            47            47            44
>>> subj 4             47            45            45            45
>>> subj 5             48            49            49            48
>>> subj 6             47            44            45            46
>>> subj 7             41            44            41            40
>>> subj 8             46            45            43            45
>>> subj 9             43            42            44            40
>>> subj 10            47            45            46            45
>>> subj 11            46            45            45            47
>>> subj 12            45            40            40            40
>>>
>>>> Hays.df <- data.frame(rt = data1, subj = factor(rep(paste("subj",
>>>    1:12, sep = ""), 4)), shape = factor(rep(rep(c("shape1",
>>>    "shape2"), c(12,  .... [TRUNCATED]
>>>
>>> I would appreciate if anyone could point out as to why I am getting this
>>> TRUNCATED message.
>>> Eventually, I want to run the following command:
>>> aov(rt - shape * color + Error(subj/(shape * color)), data=Hays.df)
>>> summary(aov(rt - shape * color + Error(subj/(shape * color)),
>>> data=Hays.df))
>>>
>>> Thanks,
>>> Amit.
>>>
>>>
>>>
>> -- 
>> Brian D. Ripley,                  ripley at stats.ox.ac.uk
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford,             Tel:  +44 1865 272861 (self)
>> 1 South Parks Road,                     +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>



More information about the R-help mailing list