New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add 'rdf' (#804) #1010
add 'rdf' (#804) #1010
Conversation
Maybe the first row should always be column names? I definitely don't like Another approach that would be a bit easier to parse would be: rdf(
hdr(a, b, c)
row(a, b, 1, 2)
row(c, d, 3, 4)
) Another approach would require a sentinel value at the end of each row: rdf(
a, b, c, d, END
a, b, 1, e, END,
c, d, 3, 4
) (But I don't think you could make that as elegant as the other two approaches) |
I definitely prefer not having to add 'extra' syntax to make the table; we should keep it as 'markdown-like' as possible. Perhaps a dummy 'delimiter', or 'delimiter-like' symbol, could be used, e.g. a series of dots: rdf(
these | are | names,
...................,
these | are | cells,
)
) I would much prefer making the 'parser' more complicated if it meant keeping the user experience good + language simple. |
I like the series of dots idea. |
Just added some code to support the dots delimiter, and also we drop missing arguments. So we can now write e.g. df <- rdf(
, these | are | names
, ...................
, these | are | cells
) (note that symbols are implicitly converted to character) Still need a nice name -- any thoughts? Maybe something like |
|
another idea for specifying column headers: data <- doodle(
ha : ho : hi,
1 | x | NA,
3 | NA | NA,
) |
@jennybc I know this is something that you're interested in. Any thoughts on name, syntax, etc? |
Here's a mash-up of the above ideas
Who doesn't like I am much faster at typing commas than You could use the markdown-inspired "3 dashes" to signal the presence of variable names. A series of dots might lead to confusion with Maybe instead of a sentinel value to signal the end of one observation, just require variable names and get length there? That might be less of a drag than repeatedly typing the sentinel. |
I like your tibble(
these, are, names,
------------------,
these, are, values,
these, are, values
) |
I love the name tibble, but I don't think I like the idea of forcing a header row so that we can automatically determine how many columns there are, so can use the implicit newline as a row separator. |
ah yes... and with the dots there's another issue, the function won't work with only three dots. the following is maybe a bit annoying to type tibble(
these, are, names,
`----------------`,
these, are, values,
these, are, values
) This would work but looks like a hack: tibble(
these, are, names,
-----------------.,
these, are, values,
these, are, values
) |
I definitely don't understand exactly what will work as the thing that separates variable names from the data, but I get the general drift. That said, can the twiddle be pressed into service? It's easy to make a valid expression with it. |
maybe the simplest thing: tibble(
'these', 'are', 'names',
these, are, values,
these, are, values
) possibly with an optional ruler: tibble(
'these', 'are', 'names',
'---------------------',
these, are, values,
these, are, values
) |
The problem with using an infix function (like tibble(
"col1", "col2",
HEADER,
1, 3
2, 6
) I also don't think we want to drop the quotes for strings altogether because that will confuse people who want to put spaces in their values. So maybe we could flip @llionel-'s idea around and do: tibble(
col1, col2,
1, 2,
3, 4
) But then the header doesn't stand out much. Another idea would be to eliminate the NSE altogether and require formula quoting for column headers: tibble(
~col1, ~col2,
1, "a",
3, "b"
) I quite like that. (I also just thought of a another name: |
@hadley's last proposal looks really good to me:
|
and once again |
@jennybc how do you feel about @kevinushey do you want to take a shot at implementing this? Or should I? I think it should be fairly simple now. |
I like |
@hadley I'll give it a shot and update this PR. |
New PR at #1358. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Adds
rdf
as a little function helper for creatingtbl_df
s inline, e.g.Comments appreciated (probably most pertinent one -- what about column names?)
Other things to think about:
rdf
the best name?rdf
but transposes the created frame)? Such a function could accept named arguments (for named columns)