rpietro / NSQIPageComplications

Analysis of surgical complications using the NSQIP data set
1 stars 1 forks source link

Variable levels - how to change reference level? #13

Closed mworni closed 12 years ago

mworni commented 12 years ago

relevel(diabetes, ref="none")

levels(diabetes) [1] "insulin" "none" "oral meds"

this command seems not really to work...

rpietro commented 12 years ago

can you remind me of the sequence you would like to have? in anticipation, here is how you do it: http://goo.gl/4WvKY

On Mon, Jun 25, 2012 at 5:31 PM, mworni < reply@reply.github.com

wrote:

relevel(diabetes, ref="none")

levels(diabetes) [1] "insulin" "none" "oral meds"

this command seems not really to work...


Reply to this email directly or view it on GitHub: https://github.com/rpietro/NSQIPageComplications/issues/13

mworni commented 12 years ago

I would like to have none as the reference category, then oral meds, then insulin.

rpietro commented 12 years ago

you forgot to throw the content into the original object:

levels(diabetes) # the original one diabetes <- relevel(diabetes, ref="none") #sending the relevel to the original diabetes object levels(diabetes) #releveled (if that is a word) object

another thing to keep in mind for the future: the advantage of attaching a data object as we are doing is that it saves on syntax. for example, i can write diabetes instead of nsqip.data$diabetes . the problem is that sometimes the attachment will have masked objects (think about the object recode from car confused with the object recode from HMisc). the same thing can happen with variables. so, if in the future you have any problems recoding variables, just detach the data and do your recoding using the data$variable syntax

last: thanks for grouping all the data management in a single session. what i do now is that i come in, run up to that section and have everything i need to fix the code. made my life and hopefully yours far easier

On Tue, Jun 26, 2012 at 5:32 PM, mworni < reply@reply.github.com

wrote:

I would like to have none as the reference category, then oral meds, then insulin.


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6588475

mworni commented 12 years ago

cool - works perfectly.

One more question - the order is now "none" "insulin" "oral meds" To even improve this, it would be great to have it "none" "oral meds" "insulin" - I tried diabetes <-(relevel(diabetes, ref="none", "oral meds", "insulin")) but this didn't work...

Any idea?

On Wed, Jun 27, 2012 at 12:23 PM, Ricardo Pietrobon < reply@reply.github.com

wrote:

you forgot to throw the content into the original object:

levels(diabetes) # the original one diabetes <- relevel(diabetes, ref="none") #sending the relevel to the original diabetes object levels(diabetes) #releveled (if that is a word) object

another thing to keep in mind for the future: the advantage of attaching a data object as we are doing is that it saves on syntax. for example, i can write diabetes instead of nsqip.data$diabetes . the problem is that sometimes the attachment will have masked objects (think about the object recode from car confused with the object recode from HMisc). the same thing can happen with variables. so, if in the future you have any problems recoding variables, just detach the data and do your recoding using the data$variable syntax

last: thanks for grouping all the data management in a single session. what i do now is that i come in, run up to that section and have everything i need to fix the code. made my life and hopefully yours far easier

On Tue, Jun 26, 2012 at 5:32 PM, mworni < reply@reply.github.com

wrote:

I would like to have none as the reference category, then oral meds, then insulin.


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6588475


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6599789

rpietro commented 12 years ago

relevel only works to set the referent, to reorder everything:

levels(diabetes) diabetes <- factor(diabetes, levels = c("none", "oral meds", "insulin")) levels(diabetes)

btw, this time i took your script out of gdrive and ran it from there. also, from now on i won't insert code anymore, will just throw it in github and then you can insert it into your file. of course i still have access to your latest scripts

On Wed, Jun 27, 2012 at 6:32 AM, mworni < reply@reply.github.com

wrote:

cool - works perfectly.

One more question - the order is now "none" "insulin" "oral meds" To even improve this, it would be great to have it "none" "oral meds" "insulin" - I tried diabetes <-(relevel(diabetes, ref="none", "oral meds", "insulin")) but this didn't work...

Any idea?

On Wed, Jun 27, 2012 at 12:23 PM, Ricardo Pietrobon < reply@reply.github.com

wrote:

you forgot to throw the content into the original object:

levels(diabetes) # the original one diabetes <- relevel(diabetes, ref="none") #sending the relevel to the original diabetes object levels(diabetes) #releveled (if that is a word) object

another thing to keep in mind for the future: the advantage of attaching a data object as we are doing is that it saves on syntax. for example, i can write diabetes instead of nsqip.data$diabetes . the problem is that sometimes the attachment will have masked objects (think about the object recode from car confused with the object recode from HMisc). the same thing can happen with variables. so, if in the future you have any problems recoding variables, just detach the data and do your recoding using the data$variable syntax

last: thanks for grouping all the data management in a single session. what i do now is that i come in, run up to that section and have everything i need to fix the code. made my life and hopefully yours far easier

On Tue, Jun 26, 2012 at 5:32 PM, mworni < reply@reply.github.com

wrote:

I would like to have none as the reference category, then oral meds, then insulin.


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6588475


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6599789


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6599931

mworni commented 12 years ago

Awesome - happy to do so - whenever it will get necessary, you can go back to gdrive and look at my "master" script - right?

However, if it doesn't interfere, I'm also happy just to click no if we open at the same time.

On Wed, Jun 27, 2012 at 12:44 PM, Ricardo Pietrobon < reply@reply.github.com

wrote:

relevel only works to set the referent, to reorder everything:

levels(diabetes) diabetes <- factor(diabetes, levels = c("none", "oral meds", "insulin")) levels(diabetes)

btw, this time i took your script out of gdrive and ran it from there. also, from now on i won't insert code anymore, will just throw it in github and then you can insert it into your file. of course i still have access to your latest scripts

On Wed, Jun 27, 2012 at 6:32 AM, mworni < reply@reply.github.com

wrote:

cool - works perfectly.

One more question - the order is now "none" "insulin" "oral meds" To even improve this, it would be great to have it "none" "oral meds" "insulin" - I tried diabetes <-(relevel(diabetes, ref="none", "oral meds", "insulin")) but this didn't work...

Any idea?

On Wed, Jun 27, 2012 at 12:23 PM, Ricardo Pietrobon < reply@reply.github.com

wrote:

you forgot to throw the content into the original object:

levels(diabetes) # the original one diabetes <- relevel(diabetes, ref="none") #sending the relevel to the original diabetes object levels(diabetes) #releveled (if that is a word) object

another thing to keep in mind for the future: the advantage of attaching a data object as we are doing is that it saves on syntax. for example, i can write diabetes instead of nsqip.data$diabetes . the problem is that sometimes the attachment will have masked objects (think about the object recode from car confused with the object recode from HMisc). the same thing can happen with variables. so, if in the future you have any problems recoding variables, just detach the data and do your recoding using the data$variable syntax

last: thanks for grouping all the data management in a single session. what i do now is that i come in, run up to that section and have everything i need to fix the code. made my life and hopefully yours far easier

On Tue, Jun 26, 2012 at 5:32 PM, mworni < reply@reply.github.com

wrote:

I would like to have none as the reference category, then oral meds, then insulin.


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6588475


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6599789


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6599931


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6600128

rpietro commented 12 years ago

yes, I can see what you are doing 24/7 (call me big brother), but probably best for me to only insert code in github to avoid conflicts from happening. one day you will be using github and this won't be necessary, but now is not the right time

On Wed, Jun 27, 2012 at 6:51 AM, mworni < reply@reply.github.com

wrote:

Awesome - happy to do so - whenever it will get necessary, you can go back to gdrive and look at my "master" script - right?

However, if it doesn't interfere, I'm also happy just to click no if we open at the same time.

On Wed, Jun 27, 2012 at 12:44 PM, Ricardo Pietrobon < reply@reply.github.com

wrote:

relevel only works to set the referent, to reorder everything:

levels(diabetes) diabetes <- factor(diabetes, levels = c("none", "oral meds", "insulin")) levels(diabetes)

btw, this time i took your script out of gdrive and ran it from there. also, from now on i won't insert code anymore, will just throw it in github and then you can insert it into your file. of course i still have access to your latest scripts

On Wed, Jun 27, 2012 at 6:32 AM, mworni < reply@reply.github.com

wrote:

cool - works perfectly.

One more question - the order is now "none" "insulin" "oral meds" To even improve this, it would be great to have it "none" "oral meds" "insulin" - I tried diabetes <-(relevel(diabetes, ref="none", "oral meds", "insulin")) but this didn't work...

Any idea?

On Wed, Jun 27, 2012 at 12:23 PM, Ricardo Pietrobon < reply@reply.github.com

wrote:

you forgot to throw the content into the original object:

levels(diabetes) # the original one diabetes <- relevel(diabetes, ref="none") #sending the relevel to the original diabetes object levels(diabetes) #releveled (if that is a word) object

another thing to keep in mind for the future: the advantage of attaching a data object as we are doing is that it saves on syntax. for example, i can write diabetes instead of nsqip.data$diabetes . the problem is that sometimes the attachment will have masked objects (think about the object recode from car confused with the object recode from HMisc). the same thing can happen with variables. so, if in the future you have any problems recoding variables, just detach the data and do your recoding using the data$variable syntax

last: thanks for grouping all the data management in a single session. what i do now is that i come in, run up to that section and have everything i need to fix the code. made my life and hopefully yours far easier

On Tue, Jun 26, 2012 at 5:32 PM, mworni < reply@reply.github.com

wrote:

I would like to have none as the reference category, then oral meds, then insulin.


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6588475


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6599789


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6599931


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6600128


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/13#issuecomment-6600245