I am plotting a table using following code but I found there is unnecessary column names V1 and V2 appear as column name.
statdat<-read.table("stat.txt",sep="\t",header=FALSE)
kable(statdat)
How can I avoid printing the column name?
You can set col.names to NULL to remove the column names:
kable(statdat, col.names = NULL)
An alternative solution is to use format="pandoc" and cat() to select the relevant rows after the table has been created. This solution is given here: R- knitr:kable - How to display table without column names?
Related
Suppose we have the following table in BigQuery:
CREATE TABLE sample_dataset.sample_table (
id INT
,struct_geo STRUCT
<
country STRING
,state STRING
,city STRING
>
,array_info ARRAY
<
STRUCT<
key STRING
,value STRING
>
>
);
I want to rename the columns inside the STRUCT and the ARRAY using an ALTER TABLE command. It's possible to follow the Google documentation available here for normal columns ("non-nested" columns) i:
ALTER TABLE sample_dataset.sample_table
RENAME COLUMN id TO str_id
But when I try to run the same command for nested columns I got errors from BigQuery.
Running the command for a column inside a STRUCT gives me the following message:
ALTER TABLE sample_dataset.sample_table
RENAME COLUMN `struct_geo.country` TO `struct_geo.str_country`
Error: ALTER TABLE RENAME COLUMN not found: struct_geo.country.
The exact same message appears when I run the same statement, but targeting a column inside an ARRAY:
ALTER TABLE sample_dataset.sample_table
RENAME COLUMN `array_info.str_key` TO `array_info.str_key`
Error: ALTER TABLE RENAME COLUMN not found: array_info.str_key
I got stuck since the BigQuery documentation about nested columns (available here) lacks examples of ALTER TABLE statements and refers directly to the default documentation for non-nested columns.
I understand that I can rename the columns by simply creating a new table using a CREATE TABLE new_table AS SELECT ... and then passing the new column names as aliases, but this would run a query over the whole table, which I'd rather avoid since my original table weighs way over 10TB...
Thanks in advance for any tips or solutions!
I have a simple problem. Let's assume I have the following
Now I want to add a specific vector or list for example (1,2,2,1) as an additional column and it should look like
When I add "Custom Column", how do I have to enter this list that it creates exactly this column?
It should not be a index column or a calculated column because I want to specify the values depending on another column manually. It seems like it is a very simple task, but I couldn't find any solutions yet! (I feel very stupid xD)
pls help
Thank you!
let Source = #table({"Column1"},{{"A"},{"B"},{"C"},{"D"}}),
Add = {{1,2,2,1}},
part1=Table.ToColumns(Source) & Add,
part2= Table.FromColumns(part1,Table.ColumnNames(Source)&{"Column2"})
in part2
or perhaps, if grabbing column from another table
let Source = #table({"Column1"},{{"A"},{"B"},{"C"},{"D"}}),
part1=Table.ToColumns(Source) & Table.ToColumns(Table.SelectColumns(SomeOtherTable,"Column9")),
part2 = Table.FromColumns(part1,Table.ColumnNames(Source)&{"Column2"})
in part2
Copy your Column1
Open the Enter Data / Create Table UI and paste Column1
Add your specific vector as Column2 and save the new table
Merge the new table into your original table using both Column1
Note that Column1 has to be a key column (unique values). If it's not, create a temporary index column and use that for merging.
I have a source table with a variable number of columns. The first column is a name, and the remaining columns are type with values of true or false based on my data.
I also have an input lookup column that will have the names of the types.
Based on the types selected in the lookup column, I want to return the names from the source column that has true for any of the selected types.
It is hard to explain so I made a sample sheet with expected output and explanation at https://docs.google.com/spreadsheets/d/1U7-Vz8tq-4E1Z6jkVFzsoIvW8VHRJNGw0oqDE1LUKOI/edit?usp=sharing has sample input and my expected output.
New rows could be added to the source table, and new columns (types) could be added too. One thought I was to have a formula for each row in the source table checking the column based on what is in the lookup table but I want to avoid that because new rows/columns could be added to the source table.
I'm hoping for a single arrayformula or something efficient. I have been looking at this for hours with no luck. I don't even know where to start...
for H9:
=ARRAYFORMULA(UNIQUE(TRIM(QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(B3:F=TRUE, "♠"&B2:F2&"♦"&A3:A, )),,999^99)),,999^99), "♠")), "♦"),
"select Col2 where Col1 matches '"&TEXTJOIN("|", 1, G9:G)&"'"))))
for H3:
=ARRAYFORMULA(UNIQUE(TRIM(QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(B3:F=TRUE, "♠"&B2:F2&"♦"&A3:A, )),,999^99)),,999^99), "♠")), "♦"),
"select Col2 where Col1 matches '"&TEXTJOIN("|", 1, G3:G6)&"'"))))
I have the following query in M:
= Table.Combine({
Table.Distinct(Table.SelectColumns(Tab1,{"item"})),
Table.Distinct(Table.SelectColumns(Tab2,{"Column1"}))
})
Is it possible to get it working without prior changing column names?
I want to get something similar to SQL syntax:
select item from Tab1 union all
select Column1 from Tab2
If you need just one column from each table then you may use this code:
= Table.FromList(List.Distinct(Tab1[item])
& List.Distinct(Tab2[Column1]))
If you use M (like in your example or the append query option) the columns names must be the same otherwise it wont work.
But it works in DAX with the command
=UNION(Table1; Table2)
https://learn.microsoft.com/en-us/dax/union-function-dax
It's not possible in Power Query M. Table.Combine make an union with columns that match. If you want to keep all in the same step you can add the change names step instead of tap2 like you did with Table.SelectColumns.
This comparison of matching names is to union in a correct way.
Hope you can manage in the same step if that's what you want.
According to this picture there is Table1 in "Sheet1" containing initial data.
I need use List Data validation for 3 end columns of Table2 in the Sheet2
i.e. Columns B, C, D in Sheet2 should have data validation lists that are comprised of the unique sorted values of Sheet1 columns A,B,C respectively. They should dynamically update as new items are added to Sheet1.
Note: I want prepare dependent data validation list, without using helper sheet or helper column.
In related same issues (questions & answers & articles e.g. get-digital-help and microsoft and extendoffice), this below objects are not covered all together.
dependent drop down lists with several (more than 2) columns.
unique distinct alphabetically sorted text values
ignore Blanks
without using helper sheet or helper column
With formulas:
1) I tried for ignoring blanks:
{=IFERROR(INDEX(Table1[order '# id], SMALL(IF(ISBLANK(Table1[order '# id]),"", ROW(Table1[order '# id])-MIN(ROW(Table1[order '# id]))+1), ROW(A2))),"")}
2) With helper columns i tried:
{=INDEX(order,MATCH(0,COUNTIF($A$1:A1,Table1[order '# id]),0))} for unique value and {=INDEX(continent,MATCH(0,COUNTIF($C$1:C1,Table1[Continent])+(order<>Sheet1!$E$2)+(product<>Sheet1!$E$5),0))}
But I need to combine the 2 steps of remove blanks and unique values in one step and write in a Name if possible.