I am trying to use flextable to make a nice table that knits into word, with descriptive banners/headers through out
Example data:
trialdata<-structure(list(` ` = c("Number per team", "Average height", "vegetarian",
"meat", "carrot", "cucumber", "orange",
"banana", "pepper", "tangerine", "Average Score",
"Range Score", "Number of children", "Number of parents",
"Number of grandparents"), `year 1` = c("20", "2",
"25", "12", "4", "7",
"7", "37", "21", "3",
"-0.3", "78 : 1", "61", "19",
"39"), `Year 2` = c("98", "28.2", "23",
"1", "8", "6", "1",
"36", "2", "29", "-0.2", "3 : 2",
"6", "18", "9"), `Year 3` = c("88",
"28.2", "24", "1", "1", "4",
"91", "3", "24 ", "2",
"-0.2", "7 : 2", "58", "1",
"8")), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-15L))
Make a table:
install.packages("flextable")
library(flextable)
table1<-flextable(trialdata)
That makes a table which looks like the below picture, with a single header
However I would like to add some kind of descriptive header, e.g.'favorite food'. This is not a 'grouping' already in the data, but an added text I would like to make the table clearer, for example to look like this:
Flex table has ways to add headers and footers, but I can't see a way to add a header-type object in the table.
Related
I would like to create an array of dates (or of tuples including an index and a data) from the following JSON.
My code is creating an array but instead of creating an array of dates, it breaks up the dates into characters. What do I need to do to create an array just of dates.
JSON looks like:
let json = """
[{"date":"2017-01-05",
"price":119.34},{"date":"2017-01-06",
"price":118.93}];
Code is:
let myprices = try JSONDecoder().decode([Prices].self, from: Data(json.utf8))
let dates = myprices.sorted{$0.date < $1.date}.enumerated().map {Array($0.element.date)}
Code prints to console as:
dates [["2", "0", "1", "7", "-", "0", "1", "-", "0", "5"], ["2", "0", "1", "7", "-", "0", "1", "-", "0", "6"], ["2", "0", "1", "7", "-", "0", "1", "-", "0"]]
Thanks in advance for any suggestions.
Replace
let dates = myprices.sorted{$0.date < $1.date}.enumerated().map {Array($0.element.date)}
with
let dates = myprices.sorted{$0.date < $1.date}.map { $0.date }
Currently you may be making let data:String change it to let date:Date and supply a formatter to the decoder check This
i am using webmethods platform 10.1 and i developed a service that is supposed to receive data as Post request.
when i try to run it on IDE it works fine, but when i publish it and try to access it through API Portal, it does not work.
i am not sure how to map my JSON to my Document. Can anyone please guide me in this regard?
I have attached my Document screen shot as well as the json i am trying to Post.
Can anyone explain how both are not related, because when i post the below JSON to my service, i do not get the values.
{
"EventCompanyId": "443",
"PositionTitleEn": "New post",
"PositionTitleAr": "New post",
"ReportsTo": "Manager",
"KnowledgeRequiredEn": "Basic knowlege",
"KnowledgeRequiredAr": "Basic knowledge",
"ExperienceRequired": "7 years",
"Gender": "1",
"EducationLevel": "4",
"CreatedBy": "1",
"UpdatedBy": "1",
"StartSalary": "35000",
"EndSalary": "35000",
"Status": "0",
"Certificate": "BS",
"YearsOfExperience": "7",
"Major": "5",
"Age": "30",
"JobType": "1",
"TrainingCourse": "",
"Weekdays": "",
"WorkingHours": "",
"Language": "1",
"Shift": "",
"JobLocations": [
{
"EmiratesId": 3,
"NumberOfVacancies": 3,
"EmiratesArea": "United Arab Emirates",
"Latitude": ,
"Longitude": ,
"EmirateEn": null,
"EmirateAr": null,
"EmirateName": null
},
{
"EmiratesId": 6,
"NumberOfVacancies": 23,
"EmiratesArea": " Dubai - United Arab Emirates",
"Latitude": 25.20447520001559,
"Longitude": 55.28122901916504,
"EmirateEn": null,
"EmirateAr": null,
"EmirateName": null
},
{
"EmiratesId": 1,
"NumberOfVacancies": 5,
"EmiratesArea": "Dubai - United Arab Emirates",
"Latitude": ,
"Longitude": ,
"EmirateEn": null,
"EmirateAr": null,
"EmirateName": null
},
{
"EmiratesId": 2,
"NumberOfVacancies": 3,
"EmiratesArea": "D72 - Dubai - United Arab Emirates",
"Latitude": ,
"Longitude": ,
"EmirateEn": null,
"EmirateAr": null,
"EmirateName": null
}
]
}
i have found a solution for it, the problem was i needed to remove Job Properties from under Job Document, they should not be inside any other property.
Someone managed to copy and paste a huge amount of data into the wrong place in smartsheet. Of course it wasn't reversed at the time, and now I have the lovely task of reversing out all of the entries. Manually. One cell at a time.
There has to be a better way.
Take a look at the Get Cell History endpoint on the Smartsheet API. When you call that you'll get a response back that looks like this:
{
"pageNumber": 1,
"pageSize": 100,
"totalPages": 1,
"totalCount": 3,
"data": [
{
"columnId":4567890123456789,
"displayValue": "Revision 3",
"columnType": "TEXT_NUMBER",
"value": "Revision 3",
"modifiedAt": "2013-06-24T00:10:18Z",
"modifiedBy" : {
"name" : "Jane Smart",
"email" : "jane.smart#smartsheet.com"
}
},
{
"columnId":4567890123456789,
"displayValue": "Revision 2",
"columnType": "TEXT_NUMBER",
"value": "Revision 2",
"modifiedAt": "2013-06-23T00:10:18Z",
"modifiedBy" : {
"name" : "Joe Smart",
"email" : "joe.smart#smartsheet.com"
}
}
]
}
You should be able to write a script that analyzes the revisions and lets you revert the value in a more automated fashion.
My Data
link https://api.myjson.com/bins/rwqy
Model
var oModel = new sap.ui.model.json.JSONModel("https://api.myjson.com/bins/rwqy");
sap.ui.getCore().setModel(oModel,'data');
I want to create a SplitApp(Master-Details page). I have created the Master page as a List of User Name from the User dataset. The list should contain the firstname.
var oList = new sap.m.List({
id:"listId",
mode: sap.m.ListMode.SingleSelect,
select: function(){
oController.itemSelected();
}
});
var oItemTemplate = new sap.m.StandardListItem({
id: "sList",title:"{data>firstname}"});
oList.bindAggregation("items","data>/user",oItemTemplate );
return new sap.m.Page({
id:"master",
title: "Claims",
content: [oList]
});
Now in details page I want to show the expenses made by that user(when i select a specific user from master view) in a table.
Now my question is how to filter data and use it for the Details view. Example:
If I select User "X" from Master view list, I should get id 1 from the "user" and Expenseno 1,4 and 7 (as they are associated with uid 1) from "expense", finally i will show the expenses of uid 1 in the details view.
Code I am trying
itemSelected: function(){
var app = sap.ui.getCore().byId("appid");//when a item will b selected first we will get instance of our app
var list = sap.ui.getCore().byId("listId");//then will get instance of the list
var sitem = list.getSelectedItem();
var spath = sitem.oBindingContexts.data.sPath;
var oitem = sap.ui.getCore().getModel('data').getProperty(spath);
console.log(oitem); //oitem has Object { id="", firstname="", lastname=""} values of the selected user.
//***how to get only the id from "oitem" and filter with expense table***//
//var Model = new sap.ui.model.json.JSONModel(oitem); // will use it for details
//sap.ui.getCore().setModel(Model,'item');// view(oitem should contain the filtered data)
app.toDetail("detailsid","show");
},
Please Help, Thank you.
I would suppose you reorganize your data source to something like.
[
{
"id": "1",
"firstname": "x",
"lastname": "k",
"expense": [
{
"expenseno": "1",
"uid": "1",
"item": "c",
"amount": "1500"
},
{
"expenseno": "4",
"uid": "1",
"item": "y",
"amount": "1000"
},
{
"expenseno": "7",
"uid": "1",
"item": "q",
"amount": "900"
}
]
},
{
"id": "2",
"firstname": "y",
"lastname": "kalita",
"expense": [
{
"expenseno": "2",
"uid": "2",
"item": "t",
"amount": "1150"
},
{
"expenseno": "5",
"uid": "2",
"item": "t",
"amount": "3500"
}
]
},
{
"id": "3",
"firstname": "z",
"lastname": "kalita",
"expense": [
{
"expenseno": "6",
"uid": "3",
"item": "s",
"amount": "3500"
},
{
"expenseno": "3",
"uid": "3",
"item": "p",
"amount": "500"
}
]
}
]
You can do this from your initial Data set by something like this
myData.user.forEach(function(d,i){
var exp = myData.expense.filter(function(d1){
if(d1.uid === d.id)return true;
});
console.log(exp);
});
After this it is just relative binding from parent. /Expense will give all the expenses of parent.
Hope this helps.
How to enable stemming when searching using lucene.net?
To do this you need to write your own analyzer class. This is relatively straightforward. Here is the one that I am using. It combines stop word filtering. Porter stemming and (this may be too much for your needs) stripping of accents from characters.
/// <summary>
/// An analyzer that implements a number of filters. Including porter stemming,
/// Diacritic stripping, and stop word filtering.
/// </summary>
public class CustomAnalyzer : Analyzer
{
/// <summary>
/// A rather short list of stop words that is fine for basic search use.
/// </summary>
private static readonly string[] stopWords = new[]
{
"0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "000", "$", "£",
"about", "after", "all", "also", "an", "and",
"another", "any", "are", "as", "at", "be",
"because", "been", "before", "being", "between",
"both", "but", "by", "came", "can", "come",
"could", "did", "do", "does", "each", "else",
"for", "from", "get", "got", "has", "had",
"he", "have", "her", "here", "him", "himself",
"his", "how","if", "in", "into", "is", "it",
"its", "just", "like", "make", "many", "me",
"might", "more", "most", "much", "must", "my",
"never", "now", "of", "on", "only", "or",
"other", "our", "out", "over", "re", "said",
"same", "see", "should", "since", "so", "some",
"still", "such", "take", "than", "that", "the",
"their", "them", "then", "there", "these",
"they", "this", "those", "through", "to", "too",
"under", "up", "use", "very", "want", "was",
"way", "we", "well", "were", "what", "when",
"where", "which", "while", "who", "will",
"with", "would", "you", "your",
"a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r",
"s", "t", "u", "v", "w", "x", "y", "z"
};
private Hashtable stopTable;
/// <summary>
/// Creates an analyzer with the default stop word list.
/// </summary>
public CustomAnalyzer() : this(stopWords) {}
/// <summary>
/// Creates an analyzer with the passed in stop words list.
/// </summary>
public CustomAnalyzer(string[] stopWords)
{
stopTable = StopFilter.MakeStopSet(stopWords);
}
public override TokenStream TokenStream(string fieldName, System.IO.TextReader reader)
{
return new PorterStemFilter(new ISOLatin1AccentFilter(new StopFilter(new LowerCaseTokenizer(reader), stopWords)));
}
}
You can use Snowball or PorterStemFilter.
See the Java Analyzer documentation as a guide to combining different Filters/Tokenizers/Analyzers. Note you have to use the same analyzer for indexing and retrieval, so that handling stemming should start at indexing time.