Transpose / reshape dataframe without “timevar” from long to wide format

Transpose / reshape dataframe without “timevar” from long to wide format

I have a data frame that follows the below long Pattern: Name MedName Name1 atenolol 25mg Name1 aspirin 81mg Name1 sildenafil 100mg Name2 atenolol 50mg Name2 enalapril 20mgAnd would like to get below (I do not ca

Replace preg_replace() e modifier with preg_replace_callback

Replace preg_replace() e modifier with preg_replace_callback

I'm terrible with regular expressions. I'm trying to replace this:public static function camelize($word) { return preg_replace('/(^|_)([a-z])/e', 'strtoupper("\\2")', $word);}with preg_replace_callback with an anonymous function. I don't

Converting ISO 8601-compliant String to java.util.Date

Converting ISO 8601-compliant String to java.util.Date

I am trying to convert an ISO 8601 formatted String to a java.util.Date. I found the pattern "yyyy-MM-dd'T'HH:mm:ssZ" to be ISO8601-compliant if used with a Locale (compare sample).However, using the java.text.SimpleDateFormat, I cannot con

Dynamically select data frame columns using $ and a vector of column names

Dynamically select data frame columns using $ and a vector of column names

I wish to order a data frame based on different columns, one at a turn. I have a character vector with the relevant column names on which the order should be based:parameter <- c("market_value_LOCAL", "ep", "book_price", "sales_price", "div

Is it possible to write a template to check for a function's existence?

Is it possible to write a template to check for a function's existence?

Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class?Here's a simple example of what I would want to write:templatestd::string optionalToString(T* obj){ if (FUN

Is an array name a pointer?

Is an array name a pointer?

Is an array's name a pointer in C?If not, what is the difference between an array's name and a pointer variable? 1:An array is an array and a pointer is a pointer, but in most cases array names are converted to pointers. A term often use

sed: -i may not be used with stdin on Mac OS X

sed: -i may not be used with stdin on Mac OS X

I am using a bison parser in my project. When I run the following command:sed -i y.tab.c -e "s/ __attribute__ ((__unused__))$/# ifndef __cplusplus\n __attribute__ ((__unused__));\n# endif/"I get this errorsed: -i may not be used with stdi

return new RedirectResult() vs return Redirect()

return new RedirectResult() vs return Redirect()

What is the difference between the following two controller ActionResult return statements:return new RedirectResult("http://www.google.com", false);andreturn Redirect("http://www.google.com"); 1:straight from the source// Copyright (c)

What is a LEFT JOIN in PostgreSQL

What is a LEFT JOIN in PostgreSQL

I've seen a query using a LEFT JOIN as opposed to an INNER or LEFT OUTER.What is a LEFT JOIN exactly? 1:Where an inner join returns only entries that match in both tables, a left join takes all the entries from first table and any that m

How to emulate a BEFORE INSERT trigger in T-SQL / SQL Server for super/subtype (Inheritance) entitie

How to emulate a BEFORE INSERT trigger in T-SQL / SQL Server for super/subtype (Inheritance) entitie

This is on Azure.I have a supertype entity and several subtype entities, the latter of which needs to obtain their foreign keys from the primary key of the super type entity on each insert. In Oracle, I use a BEFORE INSERT trigger to accomp

Setting the POST-body to a JSON object with jQuery

Setting the POST-body to a JSON object with jQuery

I'm trying to write a JSON-based web API in a Sinatra app. I want to POST a JSON object as the post body (with the proper content-type set) but I'm struggling.In Cocoa, I'd do something like[mutableHTTPRequest setHTTPBody:dataRepresentation

Programmatically swap last two commits

Programmatically swap last two commits

I know how to swap the last two commits using git rebase interactively (git rebase -i HEAD~2, ddjp:x in Vim), but I'd like to do it programmatically with a wrapper script since it's something I end up doing relatively often.To be more concr

Why are generic and non-generic structs treated differently when building expression that lifts oper

Why are generic and non-generic structs treated differently when building expression that lifts oper

This looks like a bug in lifting to null of operands on generic structs.Consider the following dummy struct, that overrides operator==:struct MyStruct{ private readonly int _value; public MyStruct(int val) { this._value = val; } pu

iOS, How to find selected row Of UITableView?

iOS, How to find selected row Of UITableView?

I'm trying to find selected UITableViewCell as following: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tabl

Sum function prob TypeError: unsupported operand type(s) for +: 'int' and 'str'

Sum function prob TypeError: unsupported operand type(s) for +: 'int' and 'str'

I'm new to python (PYTHON 3.4.2) and I'm trying to make a program that adds and divides to find the average or the mean of a user's input, but I can't figure out how to add the numbers I receive. When I open the program at the command promp

Synchronize video and audio (preferably without JavaScript)

Synchronize video and audio (preferably without JavaScript)

If I have HTML5 video and audio elements, is there a clean way to keep them in sync? They should act like a video file that contains an audio track, so advancing one track manually should bring the other one along with it. Let's say the two

Keep checked items at top of list

Keep checked items at top of list

I'm trying to create a checklist that will sort checked items to the top of the list, and when an item is unchecked, it will move below the checked items. Beyond the checked/unchecked sort, items should stay in their original order, regardl

iOS 6: how to force change orientation when pushing view controller into the navigation controller s

iOS 6: how to force change orientation when pushing view controller into the navigation controller s

This question already has an answer here: In iOS6, trouble forcing ViewController to certain interfaceOrientation when pushed on stack 3 answers I thin

Passing parameters to Azure Active Directory authentication

Passing parameters to Azure Active Directory authentication

I have an ASP.Net MVC Application, Owin, and I'm using Azure Active Directory authentication as well.I want to pass a parameter when the user is redirected to the Azure AD authentication page. So when the user signs in or signs up I want to

Finding all subsets of a multiset

Finding all subsets of a multiset

Suppose I have a bag which contains 6 balls (3 white and 3 black). I want to find all possible subsets of a given length, disregarding the order. In the case above, there are only 4 combinations of 3 balls I can draw from the bag:2 white an

Passing list elements as parameters to curried function

Passing list elements as parameters to curried function

Still a Haskell newbie here. I know just enough to get myself into trouble with wrong assumptions. If I have the following function...quadsum w x y z = w+x+y+zI want a function that can take a list, use each element as a parameter in a sp

Python - seek in http response stream

Python - seek in http response stream

Using urllibs (or urllibs2) and wanting what I want is hopeless.Any solution? 1:I'm not sure how the C# implementation works, but, as internet streams are generally not seekable, my guess would be it downloads all the data to a local fil

Process a list with a loop, taking 100 elements each time and automatically less than 100 at the end

Process a list with a loop, taking 100 elements each time and automatically less than 100 at the end

Is there a way to use a loop that takes the first 100 items in a big list, does something with them, then the next 100 etc but when it is nearing the end it automatically shortens the "100" step to the items remaining.Currently I have to us

Accept Cookies in Python

Accept Cookies in Python

How can I accept cookies in a python script? 1:Try this:import urllib2 import cookielibjar = cookielib.FileCookieJar("cookies")opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))print "Currently have %d cookies" % len(jar)pri

C++/OpenSSL: Use root CA from buffer rather than file (SSL_CTX_load_verify_locations)

C++/OpenSSL: Use root CA from buffer rather than file (SSL_CTX_load_verify_locations)

I am using OpenSSL to verify a server's certificate. Since OpenSSL is shipped without any built-in root CAs, we must distribute the root CA certificate ourselves with our software (we statically-link OpenSSL). Ordinarily, the way to do th