Search Results

Search found 5122 results on 205 pages for 'max'.

Page 69/205 | < Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >

  • Using reshape + cast to aggregate over multiple columns

    - by DamonJW
    In R, I have a data frame with columns for Seat (factor), Party (factor) and Votes (numeric). I want to create a summary data frame with columns for Seat, Winning party, and Vote share. For example, from the data frame df <- data.frame(party=rep(c('Lab','C','LD'),times=4), votes=c(1,12,2,11,3,10,4,9,5,8,6,15), seat=rep(c('A','B','C','D'),each=3)) I want to get the output seat winner voteshare 1 A C 0.8000000 2 B Lab 0.4583333 3 C C 0.5000000 4 D LD 0.5172414 I can figure out how to achieve this. But I'm sure there must be a better way, probably a cunning one-liner using Hadley Wickham's reshape package. Any suggestions? For what it's worth, my solution uses a function from my package djwutils_2.10.zip and is invoked as follows. But there are all sorts of special cases it doesn't deal with, so I'd rather rely on someone else's code. aggregateList(df, by=list(seat=seat), FUN=list(winner=function(x) x$party[which.max(x$votes)], voteshare=function(x) max(x$votes)/sum(x$votes)))

    Read the article

  • i need to use string virble in the Proc in sql server database 2005

    - by bassam
    i have this Proc CREATE Proc [dbo].Salse_Ditail -- Add the parameters for the stored procedure here @Report_Form varchar(1) , @DateFrom datetime , @DateTo datetime , @COMPANYID varchar(3), @All varchar(1) , @All1 varchar(1) , @All2 varchar(1) , @All3 varchar(1) , @All4 varchar(1) , @All5 varchar(1) , @Sector varchar(10), @Report_Parameter nvarchar(max) as BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. DECLARE @STRWhere nvarchar(max) IF @All5=0 AND @All4=0 AND @All3=0 AND @All2=0 AND @All1=0 and @All=1 set @STRWhere= N'and Sector_id = @Sector' if @Report_Form =1 or @Report_Form =3 or @Report_Form =4 SELECT RETURNREASONCODEID, SITE,SITE_NAME,Factory_id,Factory_Name,Sector_id,sector_name,Customer_name, Customer_id,ITEMID,ITEMNAME,SALESMANID,SALESMAN_NAME,Net_Qty,Net_Salse,Gross_Sales,Gross_Qty, NETWEIGHT_Gross,NETWEIGHT_salse_Gross,NETWEIGHT_NET,NETWEIGHT_salse_NET,Return_Sales,Free_Good, CollectionAmount FROM hal_bas_new_rep WHERE DATAAREAID =@COMPANYID AND INVOICEDATE >= @DateFrom AND INVOICEDATE <= @DateTo and Report_Activti = @Report_Form if @Report_Form =2 SELECT RETURNREASONCODEID , RETURNREASONDESC, SITE , SITE_NAME , Factory_id , Factory_Name , Sector_id , sector_name , Customer_name , Customer_id , ITEMID , ITEMNAME , SALESMANID , SALESMAN_NAME , Return_Sales FROM dbo.hal_bas_new_rep WHERE DATAAREAID =@COMPANYID AND INVOICEDATE >= @DateFrom AND INVOICEDATE <= @DateTo and Report_Activti = @Report_Form and RETURNREASONCODEID in ( SELECT Val FROM dbo.fn_String_To_Table(@Report_Parameter,',',1) ) /* @STRWhere question how i can but the virble here */ end GO i want to but virble put a variable under where Expression and from this function buc I have many function i want to add if any one have answer pls send me

    Read the article

  • technique for how to debug macros in C

    - by Dervin Thunk
    Hi. So I have the (mostly vilified) #define MAX( a, b ) ( ((a) > (b)) ? (a) : (b) ) somewhere in a program (yes, yes, I know). At some point in the code there is a comparison X>-1?, where X is (as far as I can tell) a (signed) integer. The line is j += MAX(bmGs[i], bmBc[(int)y[i + j]] - m + 1 + i);, where y here is a char*. Not necessarily surprisingly, I find that the macro is returning -1 as the larger number (I'm guessing too long a number for int or an unsigned issue, but I can't find it). I would like to know techniques you guys may have for finding these kinds of errors. Notice that I'm not asking for programming advice about whether or not to use that macro, I'm sure folks are dying to tell me I should refrain from things like that, but the question is going somewhere else. Thanks.

    Read the article

  • Reporting Services Linear Gauge Scale

    - by lnediger
    I have set up a linear gauge in Reporting Services 2008. What I would like to do is specify my scale interval. The only problem with this is the scale intervals I would like to use are not at constant intervals. For example, say the scale min is $0 and the scale max is $10 000. Depending on the chart I may want an interval marker labelled at $2000, $5000, then $7945. These numbers would be calculated based on percentages of scale max specified in the dataset. I have not been able to figure out how I would go about doing this.

    Read the article

  • How can i rewrite this query for faster execution

    - by sam
    SELECT s1.ID FROM binventory_ostemp s1 JOIN ( SELECT Cust_FkId, ProcessID, MAX(Service_Duration) AS duration FROM binventory_ostemp WHERE ProcessID='4d2d6068678bc' AND Overall_Rank IN ( SELECT MIN(Overall_Rank) FROM binventory_ostemp WHERE ProcessID='4d2d6068678bc' GROUP BY Cust_FkId ) GROUP BY Cust_FkId ) AS s2 ON s1.Cust_FkId = s2.Cust_FkId AND s1.ProcessID=s2.ProcessID AND s1.Service_Duration=s2.duration AND s1.ProcessID='4d2d6068678bc' GROUP BY s1.Cust_FkId It just goes away if there are more than 10K rows in that table. What it does is find rows for each customer who has min. of overall rank and in those max. of service duration for a given processid Table Data ID Cust_FkId Overall_Rank Service_Duration ProcessID 1 23 2 30 4d2d6068678bc 2 23 1 45 4d2d6068678bc 3 23 1 60 4d2d6068678bc 4 56 3 90 4d2d6068678bc 5 56 2 50 4d2d6068678bc 6 56 2 85 4d2d6068678bc

    Read the article

  • C#+Mysql Runs out of Connections. I am using 'using' and closing all connections immediately.

    - by Cyril Gupta
    In the application that I am making right now, I am getting this error: error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Evidently I am touching max-count in the connection pool. I am dutifully using 'using' with all connection objects and freeing them up immediately when the function is done with them. This is on C#, and I am using the MySql Data Dll. Is there something wrong with the dotnet connector for MySql? Is there a workaround?

    Read the article

  • `.' cannot appear in a constant-expression

    - by Amir Rachum
    Hi all, I'm getting the following error: `.' cannot appear in a constant-expression for this function (line 4): bool Covers(const Region<C,V,D>& other) const { const Region& me = *this; for (unsigned d = 0; d < D; d++) { if (me[d].min > other[d].min || me[d].max < other[d].max) { return false; } } can anyone explain the problem please?

    Read the article

  • SSRS - Checking whether the data is null

    - by NLV
    Hello I've the following expression in my report. =FormatNumber(MAX(Fields!Reading.Value, "CellReading_Reading"),3) Now when the dataset is empty 'Fields!Reading.Value' becomes empty and finding their maximum is invalid. How can i check if the entire column is empty? I tried the following with no luck. =iif(IsNothing(Fields!.Reading.Value),"",FormatNumber(MAX(Fields!Reading.Value, "CellReading_Reading"),3)) But still i'm getting #Error in the report. I also checked out link and was not able to get a clue from it. I want to handle it in the report level. Thank you. NLV

    Read the article

  • Nested WHILE loops not acting as expected - Javascript / Google Apps Script

    - by dthor
    I've got a function that isn't acting as intended. Before I continue, I'd like preface this with the fact that I normally program in Mathematica and have been tasked with porting over a Mathematica function (that I wrote) to JavaScript so that it can be used in a Google Docs spreadsheet. I have about 3 hours of JavaScript experience... The entire (small) project is calculating the Gross Die per Wafer, given a wafer and die size (among other inputs). The part that isn't working is where I check to see if any corner of the die is outside of the effective radius, Reff. The function takes a list of X and Y coordinates which, when combined, create the individual XY coord of the center of the die. That is then put into a separate function "maxDistance" that calculates the distance of each of the 4 corners and returns the max. This max value is checked against Reff. If the max is inside the radius, 1 is added to the die count. // Take a list of X and Y values and calculate the Gross Die per Wafer function CoordsToGDW(Reff,xSize,ySize,xCoords,yCoords) { // Initialize Variables var count = 0; // Nested loops create all the x,y coords of the die centers for (var i = 0; i < xCoords.length; i++) { for (var j = 0; j < yCoords.length, j++) { // Add 1 to the die count if the distance is within the effective radius if (maxDistance(xCoords[i],yCoords[j],xSize,ySize) <= Reff) {count = count + 1} } } return count; } Here are some examples of what I'm getting: xArray={-52.25, -42.75, -33.25, -23.75, -14.25, -4.75, 4.75, 14.25, 23.75, 33.25, 42.75, 52.25, 61.75} yArray={-52.5, -45.5, -38.5, -31.5, -24.5, -17.5, -10.5, -3.5, 3.5, 10.5, 17.5, 24.5, 31.5, 38.5, 45.5, 52.5, 59.5} CoordsToGDW(45,9.5,7.0,xArray,yArray) returns: 49 (should be 72) xArray={-36, -28, -20, -12, -4, 4, 12, 20, 28, 36, 44} yArray={-39, -33, -27, -21, -15, -9, -3, 3, 9, 15, 21, 27, 33, 39, 45} CoordsToGDW(32.5,8,6,xArray,yArray) returns: 39 (should be 48) I know that maxDistance() is returning the correct values. So, where's my simple mistake? Also, please forgive me writing some things in Mathematica notation... Edit #1: A little bit of formatting. Edit #2: Per showi, I've changed WHILE loops to FOR loops and replaced <= with <. Still not the right answer. It did clean things up a bit though... Edit #3: What I'm essentially trying to do is take [a,b] and [a,b,c] and return [[a,a],[a,b],[a,c],[b,a],[b,b],[b,c]]

    Read the article

  • How do I add values from two separate queries in SQL

    - by fishhead
    Below is my attempt at adding two values from separate select statements...it's not working, and I can't see why. I'm looking for some direction. select (v1.Value + v2.Value) as total from ( (Select Max(Value) as [Value] from History WHERE Datetime>='Apr 11 2010 6:05AM' and Datetime<='Apr 11 2010 6:05PM' and Tagname ='RWQ272017DTD' ) as v1 (Select Max(Value) as [Value] from History WHERE Datetime>='Apr 11 2010 6:05AM' and Datetime<='Apr 11 2010 6:05PM' and Tagname ='RU282001DTD' ) as v2 ) EDIT: Boy do I feel foolish...I asked the same question a few days ago...now I can't delete this.

    Read the article

  • [Flash 3d engine] Away3d and events (Basic questions)

    - by Simon
    I'd like to play around 3d in Flash and I'm wondering how sophisticated objects can i load from 3D Max... cos as i read it's possible to load something from 3d Max I've read that popular 3d engine is Away3d (many tutorials), so if there is nothing better... i'd like to focus on it. I've forgot to mention that i'm not familar with Flash, but the best way to learn something is to do something interesting with it... :) Main question: Can I load object from 3ds and link parts of this object to some actions in Flash. Better example: I'd like to load a Car and when user click on car's door i'd like to show some informations, about those door, or pass this event outside for example to any other application in PHP, Java etc... and when he click on car mask i'd like to raise other event... Is it possible to create such interaction?? Thx in advance :)

    Read the article

  • Library for Dataflow in C

    - by msutherl
    How can I do dataflow (pipes and filters, stream processing, flow based) in C? And not with UNIX pipes. I recently came across stream.py. Streams are iterables with a pipelining mechanism to enable data-flow programming and easy parallelization. The idea is to take the output of a function that turns an iterable into another iterable and plug that as the input of another such function. While you can already do this using function composition, this package provides an elegant notation for it by overloading the operator. I would like to duplicate a simple version of this kind of functionality in C. I particularly like the overloading of the operator to avoid function composition mess. Wikipedia points to this hint from a Usenet post in 1990. Why C? Because I would like to be able to do this on microcontrollers and in C extensions for other high level languages (Max, Pd*, Python). * (ironic given that Max and Pd were written, in C, specifically for this purpose – I'm looking for something barebones)

    Read the article

  • Linq TakeWhile depending on sum (or aggregate) of elements

    - by martinweser
    I have a list of elements and want to takeWhile the sum (or any aggregation of the elements) satisfy a certain condition. The following code does the job, but i am pretty sure this is not an unusual problem for which a proper pattern should exist. var list = new List<int> { 1, 2, 3, 4, 5, 6, 7 }; int tmp = 0; var listWithSum = from x in list let sum = tmp+=x select new {x, sum}; int MAX = 10; var result = from x in listWithSum where x.sum < MAX select x.x; Does somebody know how to solve the task in nicer way, probably combining TakeWhile and Aggregate into one query? Thx

    Read the article

  • Should I Use GUID or IDENTITY as Thread Number?

    - by user311509
    offerID is the thread # which represents the thread posted. I see in forums posts are represented by random numbers. Is this achieved by IDENTITY? If not, please advice. nvarchar(max) will carry all kind of texts along with HTML tags. CREATE TABLE Offer ( offerID int IDENTITY (4382,15) PRIMARY KEY, memberID int NOT NULL REFERENCES Member(memberID), title nvarchar(200) NOT NULL, thread nvarchar(max) NOT NULL, . . . );

    Read the article

  • question in sql server 2005 Proc

    - by bassam
    i have this Proc CREATE Proc [dbo].Salse_Ditail -- Add the parameters for the stored procedure here @Report_Form varchar(1) , @DateFrom datetime , @DateTo datetime , @COMPANYID varchar(3), @All varchar(1) , @All1 varchar(1) , @All2 varchar(1) , @All3 varchar(1) , @All4 varchar(1) , @All5 varchar(1) , @Sector varchar(10), @Report_Parameter nvarchar(max) as BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. DECLARE @STRWhere nvarchar(max) IF @All5=0 AND @All4=0 AND @All3=0 AND @All2=0 AND @All1=0 and @All=1 set @STRWhere= N'and Sector_id = @Sector' if @Report_Form =1 or @Report_Form =3 or @Report_Form =4 SELECT RETURNREASONCODEID, SITE,SITE_NAME,Factory_id,Factory_Name,Sector_id,sector_name,Customer_name, Customer_id,ITEMID,ITEMNAME,SALESMANID,SALESMAN_NAME,Net_Qty,Net_Salse,Gross_Sales,Gross_Qty, NETWEIGHT_Gross,NETWEIGHT_salse_Gross,NETWEIGHT_NET,NETWEIGHT_salse_NET,Return_Sales,Free_Good, CollectionAmount FROM hal_bas_new_rep WHERE DATAAREAID =@COMPANYID AND INVOICEDATE >= @DateFrom AND INVOICEDATE <= @DateTo and Report_Activti = @Report_Form if @Report_Form =2 SELECT RETURNREASONCODEID , RETURNREASONDESC, SITE , SITE_NAME , Factory_id , Factory_Name , Sector_id , sector_name , Customer_name , Customer_id , ITEMID , ITEMNAME , SALESMANID , SALESMAN_NAME , Return_Sales FROM dbo.hal_bas_new_rep WHERE DATAAREAID =@COMPANYID AND INVOICEDATE >= @DateFrom AND INVOICEDATE <= @DateTo and Report_Activti = @Report_Form and RETURNREASONCODEID in ( SELECT Val FROM dbo.fn_String_To_Table(@Report_Parameter,',',1) ) /* @STRWhere question how i can but the virble here */ end GO i want to but virble put a variable under where Expression and from this function buc I have many function i want to add if any one have answer pls send me

    Read the article

  • How do you write a recursive stored procedure

    - by Grayson Mitchell
    I simply want a stored procedure that calculates a unique id and inserts it. If it fails it just calls itself to regenerate said id. I have been looking for an example, but cant find one, and am not sure how I should get the sp to call itself, and set the appropriate output parameter. I would also appreciate someone pointing out how to test this sp also. ALTER PROCEDURE [dbo].[DataContainer_Insert] @SomeData varchar(max), @DataContainerId int out AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; BEGIN TRY SELECT @UserId = MAX(UserId) From DataContainer INSERT INTO DataContainer (UserId, SomeData) VALUES (@UserId, SomeData) SELECT @DataContainerId = scope_identity() END TRY BEGIN CATCH --try again exec DataContainer_Insert @DataContainerId, @SomeData END CATCH END

    Read the article

  • Problem with validating ModelForm

    - by user561640
    I use ModelForm to create my form. All works fine except 1 thing - validating the unique field. Code: class Article(models.Model): ... title = models.CharField(max_length=255, unique=True, error_messages={'max_length' : 'max translation', 'unique' : 'unique translation', 'required' : 'req translation',}) ... class ArticleForm(ModelForm): ... title = forms.CharField(max_length=255, min_length=3, error_messages={'required' : 'req translation', 'min_length' : 'min translation', 'max_length' : 'max translation', 'unique' : 'unique translation',}) But when I save my form with non-unique title I don't get my custom translated error but I get default error. How to fix it, that my unique field error is displayed?

    Read the article

  • Writing an AI for a turn-based board game

    - by Cyril
    Hi, i'm currently programming a board game (8x8) in which I need to develop an AI. I have read a lot of articles about AI in board games, minmax with or without alphabeta pruning, but I don't really know how to implements this, I don't know where to start... About my game, this is a turn-based game, each player has pieces on the board, they have to pick one and choose in moving this piece (1 or 2 cells max) or clone the piece (1 cell max). At the moment, I have a really stupid AI which choose a random piece then choose a random move to play... Could you please give me some clues, on how to implement this functionality ? Best regards

    Read the article

  • declare and assign value my sql stored procedure(5.0.45)

    - by naveen84n
    Hi everybody , DELIMITER $$ DROP PROCEDURE IF EXISTS quotations.sp_addservices $$ CREATE PROCEDURE quotations.sp_addservices (In categoryname varchar(25),in servicename varchar(250),in hours float,in cost float,in basis nvarchar (100)) BEGIN insert into categorydetails (Category_Name) values (categoryname); if(categoryname!=null) then DECLARE category_id int; set category_id= select max(Category_Id) from categorydetails ; insert into servicesdetails (Service_Name,Category_Id,Hours,Cost,Basis) values(servicename,category_id,hours,cost,basis); end if; END $$ DELIMITER ; This is my stored procedure .I have to retrive the value of categoryid that is posted into the database which is auto increased.Here i cant declare the variable and assign value to variable.Am getting error like Script line: 4 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE category_id int; set category_id= select max(Category_Id) from categor' at line 9 Can any one help me Thanks in advance.

    Read the article

  • How big can a SQL Server row be before it's a problem?

    - by John Leidegren
    Occasionally I run into this limitation using SQL Server 2000 that a row size can not exceed 8K bytes. SQL Server 2000 isn't really state of the art, but it's still in production code and because some tables are denormalized that's a problem. However, this seems to be a non issue with SQL Server 2005. At least, it won't complain that row sizes are bigger than 8K, but what happens instead and why was this a problem in SQL Server 2000? Do I need to care about my rows growing? Should I try and avoid large rows? Are varchar(max) and varbinary(max) a solution or expensive, in terms of size in database and/or CPU time? Why do I care at all about specifying the length of a particular column, when it seems like it's just a matter of time before someones going to hit that upper limit?

    Read the article

  • Hibernate Criteria API: get n random rows

    - by hadrien
    I can't figure out how to fetch n random rows from a criteria instance: Criteria criteria = session.createCriteria(Table.class); criteria.add(Restrictions.eq('fieldVariable', anyValue)); ... Then what? I can't find any doc with Criteria API Does it mean I should use HQL instead? Thanx! EDIT: I get the number of rows by: int max = criteria.setProjecxtion(Projections.rowCount()).uniqueResult(); How do I fetch n random rows with indexes between 0 and max? Thx again!

    Read the article

  • MYSQL - SQL query Getting single record for the similar records and populating other columns with which has more length

    - by Bujji
    Here is my case , I have a database table with below fields name place_code email phone address details estd others and example data if you look at the above example table First three records are talking about XYZ and place code 1020 . I want create a single record for these three records based on substring(name,1,4) place_code ( I am lucky here for all the similar records satisfies this condition and unique in the table .) For the other columns which record column length has max . For example again for the above 3 records email should be [email protected] , phone should be 657890 and details should be "testdetails" This should be done for all the table . (Some has single records and some has max 10 records ) Any help on query that helps me to get the desired result ? Thank You Regards Kiran

    Read the article

< Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >