Michael,
i have no experience with the Bayesian models you use, but I could
imagine that the problem is that this classifiedPositive variable is a
list (as you suggest as well). With
unlist()
as.character()
as.factor()
you can convert the variable to anything you may need as an input.
HTH
Jannis
On 02/26/2011 12:40 PM, Michael Hecker wrote:> Hi,
> I have a problem with an invalid variable type.
>
> My sample dataset is looking like this:
> > str(factivaTDM.train)
> 'data.frame': 4 obs. of 14 variables:
> $ access : num 2 3 2 1
> $ billion : num 2 1 2 2
> $ compani : num 7 6 1 2
> $ data : num 6 2 3 4
> $ inc : num 5 3 3 2
> $ local : num 3 2 1 1
> $ mcleodusa : num 15 6 2 10
> $ network : num 9 1 2 1
> $ provid : num 4 3 1 2
> $ servic : num 11 4 3 6
> $ share : num 9 5 3 5
> $ splitrock : num 18 6 4 5
> $ stock : num 3 3 1 2
> $ classifiedPositive:List of 4
> ..$ : chr "yes"
> ..$ : chr "yes"
> ..$ : chr "yes"
> ..$ : chr "yes"
> ..- attr(*, "class")= chr "AsIs"
>
> and the command:
> NaiveBayes.model<- NB(classifiedPositive ~ ., data = factivaTDM.train)
> generates the error:
> invalid type (list) for variable 'classifiedPositive'
>
> Here is another dataset which causes no errors:
> > str(weatherNominal.train)
> 'data.frame': 13 obs. of 5 variables:
> $ outlook : Factor w/ 3 levels
"overcast","rainy",..: 3 3 1 2 2 2 1
> 3 3 2 ...
> $ temperature: Factor w/ 3 levels
"cool","hot","mild": 2 2 2 3 1 1 1 3
> 1 3 ...
> $ humidity : Factor w/ 2 levels "high","normal": 1
1 1 1 2 2 2 1 2 2 ...
> $ windy : logi FALSE TRUE FALSE FALSE FALSE TRUE ...
> $ play : Factor w/ 3 levels
"?","no","yes": 2 2 3 3 3 2 3 2 3 3 ...
>
> So I suppose, I have to convert classifiedPositive:List to
> classifiedPositive:Factor
> How can I do that?
>
> I will send you more information about my script if you need it.
>
> Thank you very much,
> Michael
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>