Hello,
I've posted a question about this subject yesterday, but since there was no
R code to comment,
no one did.
I'm trying to have the print method for class 'htest' print some extra
information common in some test, like the time series linearity related
tests. Many of them have an 'order' parameter, representing a lag or
embedding dimension, and it would be a nice feature to pass a vector of
orders and have all corresponding tests run.
It's easy to do this, but the print method doesn't print those extra values.
Here the code goes:
#Some values from the McLeod-Li test, with x <- rnorm(100)
res <- data.frame(ord=2:4, df=ord, Q=c(0.0129, 0.049, 0.0684),
p=c(0.9936, 0.9972, 0.9994))
attach(res)
nr <- nrow(res)
# print.htest prints everything but 'all.orders'
# but when it's named 'null.value' it works and it's easier to make
# it work, all what's needed is 'null.value=res', whithout the need
# for a second 'structure()'
structure(
list(statistic=c(Q=Q[1]),
p.value=p[1],
parameter=c(df=df[1]),
alternative="It doesn't print 'all.orders' and I find 'null.value'
misleading",
method="Test the 'print.htest' method using McLeod-Li test values.",
data.name=deparse(substitute(x)),
all.orders=structure(
list(order=ord, df=df, Q=Q, p.value=p),
.Names=c("order", "df", "Q", "p.value"),
row.names=c(NA,-nr),
class="data.frame"
)
),
.Names=c("statistic","p.value","parameter","alternative",
"method","data.name","all.orders"),
class="htest"
)
Is there a way to have 'all.orders' printed by 'print.htest' ?
The problem is NOT the return values, at least the time wasn't wasted,
I can use them for whatever I'll do next.
If not, anyone has any suggestions?
Thank you in advance,
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/printing-all-htest-class-members-tp4200872p4200872.html
Sent from the R help mailing list archive at Nabble.com.
printing all htest class members
12 messages · Rui Barradas, David Winsemius, John Fox +2 more
On Dec 15, 2011, at 12:26 PM, Rui Barradas wrote:
Hello,
I've posted a question about this subject yesterday, but since there
was no
R code to comment,
no one did.
I'm trying to have the print method for class 'htest' print some extra
information common in some test, like the time series linearity
related
tests. Many of them have an 'order' parameter, representing a lag or
embedding dimension, and it would be a nice feature to pass a vector
of
orders and have all corresponding tests run.
It's easy to do this, but the print method doesn't print those extra
values.
Here the code goes:
#Some values from the McLeod-Li test, with x <- rnorm(100)
res <- data.frame(ord=2:4, df=ord, Q=c(0.0129, 0.049, 0.0684),
p=c(0.9936, 0.9972, 0.9994))
attach(res)
nr <- nrow(res)
My problem reading this is that you are using the attach function which generally confuses discussions and then you are not actually creating any object with a class of htest. Print methods are dispatched by class value.
# print.htest prints everything but 'all.orders' # but when it's named 'null.value' it works and it's easier to make # it work, all what's needed is 'null.value=res', whithout the need # for a second 'structure()'
You seem to be transcribing a conversation inside your head. Most of the four lines above has no connection to what you typed earlier.
structure(
This does nothing. No object is created.
list(statistic=c(Q=Q[1]),
p.value=p[1],
parameter=c(df=df[1]),
alternative="It doesn't print 'all.orders' and I find 'null.value'
misleading",
method="Test the 'print.htest' method using McLeod-Li test values.",
data.name=deparse(substitute(x)),
all.orders=structure(
list(order=ord, df=df, Q=Q, p.value=p),
.Names=c("order", "df", "Q", "p.value"),
row.names=c(NA,-nr),
class="data.frame"
)
),
.Names=c("statistic","p.value","parameter","alternative",
"method","data.name","all.orders"),
class="htest"
)
Is there a way to have 'all.orders' printed by 'print.htest' ?
The problem is NOT the return values, at least the time wasn't wasted,
I can use them for whatever I'll do next.
If not, anyone has any suggestions?
Yes. Give the code you are actually using!
David Winsemius, MD West Hartford, CT
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it. Rui -- View this message in context: http://r.789695.n4.nabble.com/printing-all-htest-class-members-tp4200872p4201395.html Sent from the R help mailing list archive at Nabble.com.
Hello,
Once again, and as simple as possible,
res <- data.frame(ord=2:4, df=2:4, Q=c(0.0129, 0.049, 0.0684),
p=c(0.9936, 0.9972, 0.9994))
ht2<-structure(
list(statistic=c(Q=res$Q[1]),
p.value=res$p[1],
parameter=c(df=res$df[1]),
alternative="It doesn't print 'all.orders'",
method="Test the 'print.htest' method",
data.name=deparse(substitute(x)),
null.value=res # this is printed
#all.orders=res # this wouldn't be if uncommented
),
.Names=c("statistic","p.value","parameter","alternative",
"method","data.name","null.value"),
class="htest"
)
ht2
class(ht2)
Creation? Conversation in my head? Have you heard about the experimental
method?
It's a very usefull device created by one Galileo Galilei some time ago.
--
View this message in context: http://r.789695.n4.nabble.com/printing-all-htest-class-members-tp4200872p4201793.html
Sent from the R help mailing list archive at Nabble.com.
On Dec 15, 2011, at 2:16 PM, Rui Barradas wrote:
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it.
Well, the function is stats:::print.htest. (Do not expect any further replies to emails sent without context.) #---------------------------------------------------#
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
#---------------------------------------------------#
David Winsemius, MD West Hartford, CT
hello, i need to recode a variable, however the contraction is causing problems. i had the code to change this written down somewhere and i just can't find it, of course. i am using the car library to recode. it's only 5 levels when it should have 6... when i do levels(trust). here is my recode: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; 'Can't choose' = 6; else=NA") thanks. ~nicole ----- Original Message ----- From: "David Winsemius" <dwinsemius at comcast.net> To: "Rui Barradas" <ruipbarradas at sapo.pt> Cc: r-help at r-project.org Sent: Thursday, December 15, 2011 2:33:32 PM Subject: Re: [R] printing all htest class members
On Dec 15, 2011, at 2:16 PM, Rui Barradas wrote:
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it.
Well, the function is stats:::print.htest. (Do not expect any further replies to emails sent without context.) #---------------------------------------------------#
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
#---------------------------------------------------#
David Winsemius, MD West Hartford, CT ______________________________________________ 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.
You can either use "\" to escape a character or you can mix two kinds of quotes. If you used double quotes around your text entries you can have singel quotes in the "interior of the text. > 'test of bslash-single-quote \' continues' [1] "test of bslash-single-quote ' continues" > "test of isolated single-quote ' continues" [1] "test of isolated single-quote ' continues"
On Dec 15, 2011, at 3:49 PM, Nicole Marie Ford wrote:
hello, i need to recode a variable, however the contraction is causing problems. i had the code to change this written down somewhere and i just can't find it, of course. i am using the car library to recode. it's only 5 levels when it should have 6... when i do levels(trust). here is my recode: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; 'Can't choose' = 6; else=NA") thanks. ~nicole ----- Original Message ----- From: "David Winsemius" <dwinsemius at comcast.net> To: "Rui Barradas" <ruipbarradas at sapo.pt> Cc: r-help at r-project.org Sent: Thursday, December 15, 2011 2:33:32 PM Subject: Re: [R] printing all htest class members On Dec 15, 2011, at 2:16 PM, Rui Barradas wrote:
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it.
Well, the function is stats:::print.htest. (Do not expect any further replies to emails sent without context.) #---------------------------------------------------#
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
#---------------------------------------------------#
David Winsemius, MD West Hartford, CT
______________________________________________ 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. ______________________________________________ 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.
David Winsemius, MD West Hartford, CT
Dear Nicole, On Thu, 15 Dec 2011 14:49:04 -0600 (CST)
Nicole Marie Ford <nmford at uwm.edu> wrote:
hello, i need to recode a variable, however the contraction is causing problems. i had the code to change this written down somewhere and i just can't find it, of course. i am using the car library to recode. it's only 5 levels when it should have 6... when i do levels(trust). here is my recode: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; 'Can't choose' = 6; else=NA")
Although it's awkward, you should be able to do what you want by "escaping" the quotation marks surrounding the level name; the following (untested) should work: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; \"Can't choose\" = 6; else=NA") I hope this helps, John ------------------------------------------------ John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/
thanks. ~nicole ----- Original Message ----- From: "David Winsemius" <dwinsemius at comcast.net> To: "Rui Barradas" <ruipbarradas at sapo.pt> Cc: r-help at r-project.org Sent: Thursday, December 15, 2011 2:33:32 PM Subject: Re: [R] printing all htest class members On Dec 15, 2011, at 2:16 PM, Rui Barradas wrote:
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it.
Well, the function is stats:::print.htest. (Do not expect any further replies to emails sent without context.) #---------------------------------------------------#
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
#---------------------------------------------------#
David Winsemius, MD West Hartford, CT
______________________________________________ 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. ______________________________________________ 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.
Dear John and David, Thanks so much for the advice. I have only come across this one other time in my research, so the code escaped me! Much obliged! ~Nicole Ph.D. Student University of Wisconsin Milwaukee c: 813.786.5715 e: nmford at uwm.edu ----- Original Message ----- From: "John Fox" <jfox at mcmaster.ca> To: "Nicole Marie Ford" <nmford at uwm.edu> Cc: r-help at r-project.org Sent: Thursday, December 15, 2011 3:16:58 PM Subject: Re: [R] removing contractions for recode in car Dear Nicole, On Thu, 15 Dec 2011 14:49:04 -0600 (CST)
Nicole Marie Ford <nmford at uwm.edu> wrote:
hello, i need to recode a variable, however the contraction is causing problems. i had the code to change this written down somewhere and i just can't find it, of course. i am using the car library to recode. it's only 5 levels when it should have 6... when i do levels(trust). here is my recode: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; 'Can't choose' = 6; else=NA")
Although it's awkward, you should be able to do what you want by "escaping" the quotation marks surrounding the level name; the following (untested) should work: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; \"Can't choose\" = 6; else=NA") I hope this helps, John ------------------------------------------------ John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/
thanks. ~nicole ----- Original Message ----- From: "David Winsemius" <dwinsemius at comcast.net> To: "Rui Barradas" <ruipbarradas at sapo.pt> Cc: r-help at r-project.org Sent: Thursday, December 15, 2011 2:33:32 PM Subject: Re: [R] printing all htest class members On Dec 15, 2011, at 2:16 PM, Rui Barradas wrote:
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it.
Well, the function is stats:::print.htest. (Do not expect any further replies to emails sent without context.) #---------------------------------------------------#
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
#---------------------------------------------------#
David Winsemius, MD West Hartford, CT
______________________________________________ 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. ______________________________________________ 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.
I think you should subclass "htest" and write a print method
for that subclass. E.g.,
> print.htest_rb <- function(x, ...) {
+ NextMethod(x, ...)
+ cat("all.orders =", x$all.orders, "\n")
+ invisible(x)
+ }
> ht2$all.orders <- "THIS IS THE 'all.orders' COMPONENT"
> class(ht2) <- c("htest_rb", class(ht2))
> ht2
Test the 'print.htest' method
data: x
Q = 0.0129, df = 2, p-value = 0.9936
alternative hypothesis: It doesn't print 'all.orders'
null values:
ord df Q p
1 2 2 0.0129 0.9936
2 3 3 0.0490 0.9972
3 4 4 0.0684 0.9994
all.orders = THIS IS THE 'all.orders' COMPONENT
If you want the 'all.order' information printed in the
middle of the htest printout then you will have to copy
the code in stats:::print.htest to your print.htest_rb
method and edit it to suit you.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Rui Barradas
Sent: Thursday, December 15, 2011 12:12 PM
To: r-help at r-project.org
Subject: Re: [R] printing all htest class members
Hello,
Once again, and as simple as possible,
res <- data.frame(ord=2:4, df=2:4, Q=c(0.0129, 0.049, 0.0684),
p=c(0.9936, 0.9972, 0.9994))
ht2<-structure(
list(statistic=c(Q=res$Q[1]),
p.value=res$p[1],
parameter=c(df=res$df[1]),
alternative="It doesn't print 'all.orders'",
method="Test the 'print.htest' method",
data.name=deparse(substitute(x)),
null.value=res # this is printed
#all.orders=res # this wouldn't be if uncommented
),
.Names=c("statistic","p.value","parameter","alternative",
"method","data.name","null.value"),
class="htest"
)
ht2
class(ht2)
Creation? Conversation in my head? Have you heard about the experimental
method?
It's a very usefull device created by one Galileo Galilei some time ago.
--
View this message in context: http://r.789695.n4.nabble.com/printing-all-htest-class-members-
tp4200872p4201793.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
Hello, all. I am encountering a new problem I have not seen before. I recoded my variable trust in the following manner (thank you John and David): trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; \"Can't choose\" = 6; else=NA") when I examine the variable, I find the following:
levels(Poland$trust)
[1] "1" "2" "3" "4" "6" level 5 is missing. i check again here:
levels(Poland$SN35B)
[1] "NAP:NOT ASKED/BALOT" "Strongly Agree" "Agree" [4] "Neither Agree nor Disagree" "Disagree" "Cant choose" [7] "Can't choose" "NO ANSWER" yes, 5 should be "Disagree". So I check to be sure people did answer "Disagree". I find they did:
summary(Poland$SN35B)
NAP:NOT ASKED/BALOT Strongly Agree Agree
12443 83 545
Neither Agree nor Disagree Disagree Cant choose
306 183 29
Can't choose NO ANSWER
62 13
I was wondering if anyone has any ideas as to why my 5th choice might be missing after I recode?
Thanks.
~Nicole
----- Original Message -----
From: "Nicole Marie Ford" <nmford at uwm.edu>
To: "John Fox" <jfox at mcmaster.ca>
Cc: r-help at r-project.org
Sent: Thursday, December 15, 2011 3:39:01 PM
Subject: Re: [R] removing contractions for recode in car
Dear John and David,
Thanks so much for the advice. I have only come across this one other time in my research, so the code escaped me! Much obliged!
~Nicole
Ph.D. Student
University of Wisconsin Milwaukee
c: 813.786.5715
e: nmford at uwm.edu
----- Original Message -----
From: "John Fox" <jfox at mcmaster.ca>
To: "Nicole Marie Ford" <nmford at uwm.edu>
Cc: r-help at r-project.org
Sent: Thursday, December 15, 2011 3:16:58 PM
Subject: Re: [R] removing contractions for recode in car
Dear Nicole,
On Thu, 15 Dec 2011 14:49:04 -0600 (CST)
Nicole Marie Ford <nmford at uwm.edu> wrote:
hello, i need to recode a variable, however the contraction is causing problems. i had the code to change this written down somewhere and i just can't find it, of course. i am using the car library to recode. it's only 5 levels when it should have 6... when i do levels(trust). here is my recode: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; 'Can't choose' = 6; else=NA")
Although it's awkward, you should be able to do what you want by "escaping" the quotation marks surrounding the level name; the following (untested) should work: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; \"Can't choose\" = 6; else=NA") I hope this helps, John ------------------------------------------------ John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/
thanks. ~nicole ----- Original Message ----- From: "David Winsemius" <dwinsemius at comcast.net> To: "Rui Barradas" <ruipbarradas at sapo.pt> Cc: r-help at r-project.org Sent: Thursday, December 15, 2011 2:33:32 PM Subject: Re: [R] printing all htest class members On Dec 15, 2011, at 2:16 PM, Rui Barradas wrote:
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it.
Well, the function is stats:::print.htest. (Do not expect any further replies to emails sent without context.) #---------------------------------------------------#
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
#---------------------------------------------------#
David Winsemius, MD West Hartford, CT
______________________________________________ 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. ______________________________________________ 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.
______________________________________________ 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.
I see the problem. So Sorry. ----- Original Message ----- From: "Nicole Marie Ford" <nmford at uwm.edu> To: "John Fox" <jfox at mcmaster.ca> Cc: r-help at r-project.org Sent: Friday, December 16, 2011 11:54:36 AM Subject: Re: [R] removing contractions for recode in car Hello, all. I am encountering a new problem I have not seen before. I recoded my variable trust in the following manner (thank you John and David): trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; \"Can't choose\" = 6; else=NA") when I examine the variable, I find the following:
levels(Poland$trust)
[1] "1" "2" "3" "4" "6" level 5 is missing. i check again here:
levels(Poland$SN35B)
[1] "NAP:NOT ASKED/BALOT" "Strongly Agree" "Agree" [4] "Neither Agree nor Disagree" "Disagree" "Cant choose" [7] "Can't choose" "NO ANSWER" yes, 5 should be "Disagree". So I check to be sure people did answer "Disagree". I find they did:
summary(Poland$SN35B)
NAP:NOT ASKED/BALOT Strongly Agree Agree
12443 83 545
Neither Agree nor Disagree Disagree Cant choose
306 183 29
Can't choose NO ANSWER
62 13
I was wondering if anyone has any ideas as to why my 5th choice might be missing after I recode?
Thanks.
~Nicole
----- Original Message -----
From: "Nicole Marie Ford" <nmford at uwm.edu>
To: "John Fox" <jfox at mcmaster.ca>
Cc: r-help at r-project.org
Sent: Thursday, December 15, 2011 3:39:01 PM
Subject: Re: [R] removing contractions for recode in car
Dear John and David,
Thanks so much for the advice. I have only come across this one other time in my research, so the code escaped me! Much obliged!
~Nicole
Ph.D. Student
University of Wisconsin Milwaukee
c: 813.786.5715
e: nmford at uwm.edu
----- Original Message -----
From: "John Fox" <jfox at mcmaster.ca>
To: "Nicole Marie Ford" <nmford at uwm.edu>
Cc: r-help at r-project.org
Sent: Thursday, December 15, 2011 3:16:58 PM
Subject: Re: [R] removing contractions for recode in car
Dear Nicole,
On Thu, 15 Dec 2011 14:49:04 -0600 (CST)
Nicole Marie Ford <nmford at uwm.edu> wrote:
hello, i need to recode a variable, however the contraction is causing problems. i had the code to change this written down somewhere and i just can't find it, of course. i am using the car library to recode. it's only 5 levels when it should have 6... when i do levels(trust). here is my recode: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; 'Can't choose' = 6; else=NA")
Although it's awkward, you should be able to do what you want by "escaping" the quotation marks surrounding the level name; the following (untested) should work: trust <- recode(Poland$SN35B, " 'Strongly Agree' = 1; 'Agree' = 2; 'Neither Agree nor Disagree' = 3; 'Disagree' = 4; 'Strongly Disagree' = 5; \"Can't choose\" = 6; else=NA") I hope this helps, John ------------------------------------------------ John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/
thanks. ~nicole ----- Original Message ----- From: "David Winsemius" <dwinsemius at comcast.net> To: "Rui Barradas" <ruipbarradas at sapo.pt> Cc: r-help at r-project.org Sent: Thursday, December 15, 2011 2:33:32 PM Subject: Re: [R] printing all htest class members On Dec 15, 2011, at 2:16 PM, Rui Barradas wrote:
You're right, David, The first line is wrong, it should be ... df=2:4 ... As for creating something, try
ht <- structure( ... etc ... ht class(ht)
See what is printed and what function prints it.
Well, the function is stats:::print.htest. (Do not expect any further replies to emails sent without context.) #---------------------------------------------------#
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
#---------------------------------------------------#
David Winsemius, MD West Hartford, CT
______________________________________________ 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. ______________________________________________ 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.
______________________________________________ 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. ______________________________________________ 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.