My question is how to reference tables in markdown format like the following because the answer here doesn't work
Referencing a 'hand-made' table using bookdown package
I tried
---
output: html_document
---
you may refer to this table using \#ref(tab:foo)
Table: (\#tab:foo) Your table caption.
+-----------------------+-----------------------+-----------------------+
| Auteur | Protocole | Résultats |
+=======================+=======================+=======================+
| (Jiayi 2011) | Analyse formantique | Diphtongaison de [e |
+-----------------------+-----------------------+-----------------------+
and it didn't work.
it gives "Table : (#tab:foo) Your table caption." as the caption and "you may refer to this table using #ref(tab:foo)" If I cross reference using #ref(tab:foo).
Is it possible also to have automatic numbering ?
Looks like you just need to use bookdown's output formats.
---
output:
bookdown::html_document2:
df_print: paged
---
you may refer to this table using \#ref(tab:foo)
Table: (\#tab:foo) Your table caption.
+-----------------------+-----------------------+-----------------------+
| Auteur | Protocole | Résultats |
+=======================+=======================+=======================+
| (Jiayi 2011) | Analyse formantique | Diphtongaison de [e |
+-----------------------+-----------------------+-----------------------+
The answer here works for me:
I am joining the discussion a bit late, but I just wanted to share a working MWE (based on the earlier answers):
```{r , echo=FALSE, results='asis'}
cat(' Table: (\\#tab:mwe) Example
| Sepal.Length| Sepal.Width| Petal.Length|
|------------:|-----------:|------------:|
| 5.1| 3.5| 1.4|
| 4.9| 3.0| 1.4|
| 4.7| 3.2| 1.3|
| 4.6| 3.1| 1.5|')```
The table can now be reference via \#ref(tab:mwe) in bookdown. This is working for me in pdf and html exports.
Note that if you would like to add greek letters or more complicated sub-or superscripts, you will need to include the following text reference outside of the code chunk
(ref:flower) Flower~dimensions\ example~
```{r , echo=FALSE, results='asis'}
cat(' Table: (\\#tab:mwe) Example with (ref:flower)
| Sepal.Length| Sepal.Width| Petal.Length|
|------------:|-----------:|------------:|
| 5.1| 3.5| 1.4|
| 4.9| 3.0| 1.4|
| 4.7| 3.2| 1.3|
| 4.6| 3.1| 1.5|')```
Related
I need to write a regexg_replace query in spark.sql() and I'm not sure how to handle it. For readability purposes, I have to utilize SQL for it. I am trying to pull out the hashtags from the table. I know how to do this using the python method but most of my team are SQL users.
My dataframe example looks like so:
Insta_post
Today, Senate Dems vote to #SaveTheInternet. Proud to support similar #NetNeutrality legislation here in the House…
RT #NALCABPolicy: Meeting with #RepDarrenSoto . Thanks for taking the time to meet with #LatinoLeader ED Marucci Guzman. #NALCABPolicy2018.…
RT #Tharryry: I am delighted that #RepDarrenSoto will be voting for the CRA to overrule the FCC and save our #NetNeutrality rules. Find out…
My code:
I create a tempview:
post_df.createOrReplaceTempView("post_tempview")
post_df = spark.sql("""
select
regexp_replace(Insta_post, '.*?(.|'')(#)(\w+)', '$1') as a
from post_tempview
where Insta_post like '%#%'
""")
My end result:
+--------------------------------------------------------------------------------------------------------------------------------------------+
|a |
+--------------------------------------------------------------------------------------------------------------------------------------------+
|Today, Senate Dems vote to #SaveTheInternet. Proud to support similar #NetNeutrality legislation here in the House… |
|RT #NALCABPolicy: Meeting with #RepDarrenSoto . Thanks for taking the time to meet with #LatinoLeader ED Marucci Guzman. #NALCABPolicy2018.…|
|RT #Tharryry: I am delighted that #RepDarrenSoto will be voting for the CRA to overrule the FCC and save our #NetNeutrality rules. Find out…|
+--------------------------------------------------------------------------------------------------------------------------------------------+
desired result:
+---------------------------------+
|a |
+---------------------------------+
| #SaveTheInternet, #NetNeutrality|
| #NALCABPolicy2018 |
| #NetNeutrality |
+---------------------------------+
I haven't really used regexp_replace too much so this is new to me. Any help would be appreciated as well as an explanation of how to structure the subsets!
For Spark 3.1+, you can use regexp_extract_all function to extract multiple matches:
post_df = spark.sql("""
select regexp_extract_all(Insta_post, '(#\\\\w+)', 1) as a
from post_tempview
where Insta_post like '%#%'
""")
post_df.show(truncate=False)
#+----------------------------------+
#|a |
#+----------------------------------+
#|[#SaveTheInternet, #NetNeutrality]|
#|[#NALCABPolicy2018] |
#|[#NetNeutrality] |
#+----------------------------------+
For Spark <3.1, you can use regexp_replace to remove all that doesn't match the hashtag pattern :
post_df = spark.sql("""
select trim(trailing ',' from regexp_replace(Insta_post, '.*?(#\\\\w+)|.*', '$1,')) as a
from post_tempview
where Insta_post like '%#%'
""")
post_df.show(truncate=False)
#+-------------------------------+
#|a |
#+-------------------------------+
#|#SaveTheInternet,#NetNeutrality|
#|#NALCABPolicy2018 |
#|#NetNeutrality |
#+-------------------------------+
Note the use trim to remove the unnecessary trailing commas created by the first replace $,.
Do you really need a view? Because the following code might do it:
df = df.filter(F.col('Insta_post').like('%#%'))
col_trimmed = F.trim((F.regexp_replace('Insta_post', '.*?(#\w+)|.+', '$1 ')))
df = df.select(F.regexp_replace(col_trimmed,'\s',', ').alias('a'))
df.show(truncate=False)
# +--------------------------------+
# |a |
# +--------------------------------+
# |#SaveTheInternet, #NetNeutrality|
# |#NALCABPolicy2018 |
# |#NetNeutrality |
# +--------------------------------+
I ended up using two of regexp_replace, so potentially there could be a better alternative, just couldn't think of one.
I have a group of people who started receiving a specific type of social benefit called benefitA, I am interested in knowing what(if any) social benefits the people in the group might have received immediately before they started receiving BenefitA.
My optimal result would be a table with the number people who was receiving respectively BenefitB, BenefitC and not receiving any benefit “BenefitNon” immediately before they started receiving BenefitA.
My data is organized as a relation database with a Facttabel containing an ID for each person in my data and several dimension tables connected to the facttabel. The important ones here at DimDreamYdelse(showing type of benefit received), DimDreamTid(showing week and year). Here is an example of the raw data.
Data Example
I'm not sure how to approach this in PowerBi as I am fairly new to this program. Any advice is most welcome.
I have tried to solve the problem in SQL but as I need this as part of a running report i need to do it in PowerBi. This bit of code might however give some context to what I want to do.
USE FLISDATA_Beskaeftigelse;
SELECT dbo.FactDream.DimDreamTid , dbo.FactDream.DimDreamBenefit , dbo.DimDreamTid.Aar, dbo.DimDreamTid.UgeIAar, dbo.DimDreamBenefit.Benefit,
FROM dbo.FactDream INNER JOIN
dbo.DimDreamTid ON dbo.FactDream.DimDreamTid = dbo.DimDreamTid.DimDreamTidID INNER JOIN
dbo.DimDreamYdelse ON dbo.FactDream.DimDreamBenefit = dbo.DimDreamYdelse.DimDreamBenefitID
WHERE (dbo.DimDreamYdelse.Ydelse LIKE 'Benefit%') AND (dbo.DimDreamTid.Aar = '2019')
ORDER BY dbo.DimDreamTid.Aar, dbo.DimDreamTid.UgeIAar
I suggest to use PowerQuery to transform your table into more suitable form for your analysis. Things would be much easier if each row of the table represents the "change" of benefit plan like this.
| Person ID | Benefit From | Benefit To | Date |
|-----------|--------------|------------|------------|
| 15 | BenefitNon | BenefitA | 2019-07-01 |
| 15 | BenefitA | BenefitNon | 2019-12-01 |
| 17 | BenefitC | BenefitA | 2019-06-01 |
| 17 | BenefitA | BenefitB | 2019-08-01 |
| 17 | BenefitB | BenefitA | 2019-09-01 |
| ...
Then you can simply count the numbers by COUNTROWS(BenefitChanges) filtering/slicing with both Benefit From and Benefit To.
I'm not sure how to do this in a dataframe context
I have the table below here with text information
TEXT |
-------------------------------------------|
"Get some new #turbo #stacks today!" |
"Is it one or three? #phone" |
"Mayhaps it be three afterall..." |
"So many new issues with phone... #iphone" |
And I want to edit it down to where only the words with a '#' symbol are kept, like in the result below.
TEXT |
-----------------|
"#turbo #stacks" |
"#phone" |
"" |
"#iphone" |
In some cases, I'd also like to know if it's possible to eliminate the rows that are empty by checking for NaN as true or if you run a different kind of condition to get this result:
TEXT |
-----------------|
"#turbo #stacks" |
"#phone" |
"#iphone" |
Python 2.7 and pandas for this.
You could try using regex and extractall:
df.TEXT.str.extractall('(#\w+)').groupby(level=0)[0].apply(' '.join)
Output:
0 #turbo #stacks
1 #phone
3 #iphone
Name: 0, dtype: object
I am working on a project that processes data and displays information using Boxplot Chart in Visual Studio 2010 using C/C++ language.
I found some examples on MSDN Microsoft documentation but it only includes sample codes in C# and Visual Basic, but I couldn't find examples in C/C++ language.
I tried to create a boxplot using this code
this->chart1->Series["dat"]->Points->AddY(10);
this->chart1->Series["dat"]->Points->AddY(5);
this->chart1->Series["dat"]->Points->AddY(7);
this->chart1->Series["dat"]->Points->AddY(4);
this->chart1->Series["dat"]->Points->AddY(8);
this->chart1->Series["dat"]->Points->AddY(6);
But instead of showing a single boxplot (as below)
---------
|
|
-----
| |
-----
| |
-----
|
|
---------
it displays 6 different whiskers
--- ---
| --- --- | ---
| | | --- | |
| | | | | |
--- --- --- --- --- ---
I tried to manipulate C++ instructions in order to create a code similar to the sample code within the MSDN documentation and insert data into the chart, so I tried this:
this->chart1->Series["dat"]->Points->AddY(10);
this->chart1->Series["dat"]->Points->AddY(5);
this->chart1->Series["dat"]->Points->AddY(7);
this->chart1->Series["dat"]->Points->AddY(4);
this->chart1->Series["dat"]->Points->AddY(8);
this->chart1->Series["dat"]->Points->AddY(6);
this->chart1->Series["BoxPlotSeries"]["BoxPlotSeries"]="dat";
But it didn't work.
It is kind of difficult for me to explore the Chart methods and properties as VS2010 does not provide Intellisense for C++/CLI.
Could you provide me any sample code to create Boxplot Charts for Visual C++ 2010??? Any ideas???
Thanks in advance.
System::Windows::Forms::DataVisualization::Charting::Series^ bpSeries =
gcnew System::Windows::Forms::DataVisualization::Charting::Series();
bpSeries->Name = "bpSeries";
std::vector<int> yValues { 10,5,7,4,8,6 };
for(int i = 0; i < yValues.size(); i++)
bpSeries->Points->AddY(yValues[i]);
this->chart1->Series["dat"]["BoxPlotSeries"] = "bpSeries";
I publish an OG action/object but the attachment layout of the action (which has been set to "Item") is simply ignored. On my timeline, I click on the date/time link to see the action in full details (along with the attachment)... but all I see is a box with object image in the center and the object title at the bottom:
------------------
| |
| |
| Image |
| |
| |
------------------
| Object Title |
------------------
Instead I expect to see a smaller image at the left side along with the title and other captions on the right side (like what "Item" layout preview is showing):
-----------------------------------------
| | Object Title |
| | Caption 1 |
| Image | Caption 2 |
| | Caption 3 |
| | Caption 4 |
-----------------------------------------
And the OG tags of my object page, hosted on my website, are correct (at least the Facebook OG Debugger says so!).
Does anyone know what I'm missing here?
Thank you,