Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upmissing column names after crosstab? #77
Comments
|
by looking at the documentation, it seems this is the expected behavior of In my opinion, there is room for improvement here. In essence, by not showing the What do you think? Example output in
|
|
I agree that the ideal result would contain information about both variables used in the crosstab and have actually put considerable thought into this. I'm open to other ideas, but I haven't found a good way to do that without compromising the For interactive use, something like that Stata result is nice, to have the full info. But then the result can't be written to .csv, passed to
But I don't like that
and I don't see where the var2 name could go in a data.frame. I tried printing it for interactive use like this:
But in interactive use, you already have your command right above it the console output, so it's not as much of an issue - and then if the printed statement doesn't stay with the resulting data.frame, it doesn't solve the underlying problem. Here's an Excel screenshot from trying to conceptualize this: I don't think the var2 name can be included without creating a blank column. |
|
thanks for your detailed and nice answers.
|
|
I see the upside of this, but am stuck on two problems:
My solutions are (a) for interactive use, you have the syntax immediately before the result so can look there; (b) for scripted use you can add a title in Markdown or tweak the first column name with |
|
@sfirke !!! I wrote this in October!!!!! :D |
|
I'm hoping to get faster at responding :) Cleaning up some issues now before a minor CRAN submission. That approach sounds like a good compromise. I'm going to redo the whole crosstab() function later this year, and I'll look at that as a possible option for crosstab() to take. |
|
A year later and I'm struck by an idea. To recap, this looks pretty nice with "cyl" on top:
But it's not a data.frame. This is a data.frame:
It's no longer any good for manipulating, since the column names are put in the 1st row of the data.frame - feels so wrong. BUT, it looks good for printing in a report. I think I could implement this as an I think it's at least worth a shot. Anyone want to implement this? The attribute stuff is not hard if you look at I wonder if it would throw off any bolding of column names that might occur in RMarkdown or another output format like a .docx template; would it bold only that single name in the row by itself? |
|
Note to self: allow it to take optional text argument to put on top. Default is to get it from the |
|
Hi @sfirke sorry for my late andwer. Yes, I think this is a very good idea, and actually the only possible one when you think about it
at the end of the day? for printing, nobody cares whether this is a dataframe or a duck |
|
I agree that
I'm tinkering with this and it should be doable. |
|
Might consider |
|
This feature is now live on the master branch! Try out |
|
thanks that is great! sorry for getting back to you so late |
|
Hi, Thanks for adding this feature, I am using version 0.3.1 of janitor package and don't see adorn_title() in it. Thanks |
|
@vishalugle I plan to submit version 1.0 to CRAN tomorrow at which point this will be a moot question
See if that gives you that function? |
|
Thanks for your quick response , I got the latest version using devtools.
…On Thu, Mar 8, 2018 at 12:19 PM, Sam Firke ***@***.***> wrote:
@vishalugle <https://github.com/vishalugle> I plan to submit version 1.0
to CRAN tomorrow at which point this will be a moot question
|

Hello there,
First of all, congrats for this package. Coming from
stataandpandas, this is EXACLY whatdplyrneeded. A robust, easy to use package that excels at computing tabulations and cross-tabulations!I have a quick question. Consider this simple example
Now I compute a simple cross-tabulation
I dont get why I only see the variable name
var1above and notvar1andvar3. Given the table above, how could you possibly know that this is a cross-tabulation betweenvar1andvar3?Am I missing something?
Thanks!