lag

R - How can I check if a value in a row is different from the value in the previous row?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 15:48:28
I would like to add a column to my table that compares a value with a previous value in an existing column 'farm' (to check if it is the same); and also controls if the value in the current row is "NULL". The objective is to get back in the new column 'switch' the value "new" when the value in the column 'farm' for that row is different from the value in the previous row for the column 'farm'. (exept when the value in farm is "NULL", then I would like to get back "") See here below the desired output: farm switch A A NULL B new B B A new A A B new B B NULL A new A I tried to solve this using

Lags in R within specific subsets?

六眼飞鱼酱① 提交于 2019-12-07 12:59:30
Suppose I have the following dataframe: df <- data.frame("yearmonth"=c("2005-01","2005-02","2005-03","2005-01","2005-02","2005-03"),"state"=c(1,1,1,2,2,2),"county"=c(3,3,3,3,3,3),"unemp"=c(4.0,3.6,1.4,3.7,6.5,5.4)) I'm trying to create a lag for unemployment within each unique state-county combination. I want to end up with this: df2 <- data.frame("yearmonth"=c("2005-01","2005-02","2005-03","2005-01","2005-02","2005-03"),"state"=c(1,1,1,2,2,2),"county"=c(3,3,3,3,3,3),"unemp"=c(4.0,3.6,1.4,3.7,6.5,5.4),"unemp_lag"=c(NA,4.0,3.6,NA,3.7,6.5)) Now, imagine this situation except with thousands of

Cache whats being draw on MapView in Android

て烟熏妆下的殇ゞ 提交于 2019-12-07 09:41:22
问题 I am developing an app for my Universities campus that displays the campus in a MapView; then using geopoints draws the outlines of the buildings on campus on the mapView using the draw method a class that extents Overlay. There are about 50-60 buildings being drawn, resulting in a very laggy map as the draw method constantly gets drawn over and over. I have looked into my problem and I have found some people mentioning drawing the buildings on a canvas, but I have found no good examples or

Eclipse - Android GUI designer incredibly laggy and memory intensive

隐身守侯 提交于 2019-12-07 08:51:14
问题 I am having serious issues with the Android GUI designer. I used to be able to edit views just fine, but I was very far behind on updates. Once updated, the GUI editor started to lag. The Image-Buttons in this picture continuously flash as soon as I edit a property on a view. And memory usage skyrockets. Task Manager showed my RAM being completely maxed out at 8 gigs. (javaw.exe ~6.5 gigs of memory usage) As soon as I switch away from the GUI editor (over to the code editor) it stops lagging,

android EditText lagging when typing text

[亡魂溺海] 提交于 2019-12-07 04:42:34
问题 Im developing some sort of chat application, all goes wellm but im stuck with one problem. EditText lags, my android keyboard gets freezed on second or some whenever I type some letter in edittext. O din't really know what code to provide, because it's just a simple EditText box. Here's how i make it: linforbutton.add(new LinearLayout(this)); //linear layout on the bottom os creen for edittext and button RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL

decreasing sifr render time

柔情痞子 提交于 2019-12-06 16:14:56
问题 I'm using sifr for a few items on this page: http://blueprint.staging.dante-studios.com/public/templates/home.php unfortunately it seems that the rendering is very slow, does anyone have any idea of how to: a) speed up the rendering process b) hide all "to be sifr'd" items until all of them are ready? 回答1: Here are a few suggestions: The Flash movie has the bold and italic and bold + italic glyphs embedded. If you don't need those, they're adding needless weight to the movie. Same goes for

Android - GC lags listview scrolling with “bigger” images

旧时模样 提交于 2019-12-06 09:32:12
问题 In a listview I want to draw one image on a list entry. These 20 images have to scale to fill the width in vertical mode. The phone resolution is 480 x 800 pixels (SGS2). The images resolution is 400x400 and are about 100KB in size. I've placed the images in the drawable folder. When I scroll through the list it's not going smooth. I understand a few things: - application Heap size = limited, Allocated when first run = 13MB, got 1 MB left. - I have GC_FOR_ALLOC Log messages, which halts the

Get previous row updated value using LAG Without using Recursive CTE

∥☆過路亽.° 提交于 2019-12-06 03:22:10
How to use LAG function to get the updated previous row value (without using Recursive CTE ). Please check the screenshot for sample output Query Tried Declare @Tbl as Table(SNO Int,Credit Money,Debit Money,PaidDate Date) Insert into @Tbl SELECT * FROM (VALUES (1,0,12,'7Jan16'), (2,10,0,'6Jan16'), (3,15,0,'5Jan16'), (4,0,5,'4Jan16'), (5,0,3,'3Jan16'), (6,0,2,'2Jan16'), (7,20,0,'1Jan16')) AS X(SNO,Credit,Debit,PaidDate) Select T.SNO, T.Credit, T.Debit, TotalDebit = Case When Credit < LAG(T.Debit, 1, 0) OVER (ORDER BY SNO) Then Debit + (LAG(T.Debit, 1, 0) OVER (ORDER BY SNO)-Credit) Else Debit

UITableView Lagging due to Shadows and Borders

我是研究僧i 提交于 2019-12-06 02:40:48
问题 I have the following code to add a border colour and drop shadow to the background of my UITableViewCell. My problem is that this code causes a huge lag on the tableView itself. Please can you tell me how I can optimise my code, preventing the lag of the UITableView? if ([cell viewWithTag:012] == nil && comment.isReply == NO) { UIImageView *iv = [[[UIImageView alloc] initWithFrame:frame] autorelease]; [iv setImage:[UIImage imageNamed:@"paper"]]; [iv setTag:012]; [cell insertSubview:iv atIndex

ListView with getView() Over-Ridden Slow Due To Constant GC?

雨燕双飞 提交于 2019-12-05 18:46:10
I have a ListView in my app, and I've over-ridden the getView() method so I can change the row's ImageView src depending on the row's text. The problem is, I've noticed the ListView scrolling is lagging, and when I check DDMS, it seems the Garbage Collector is being called everytime the ListView is being scrolled, thus slowing the scrolling. I've also noticed the Garbage Collector being called in a different part of my app, when reading lines from a BufferedReader, which makes opening a 2,000 line file take ~47 seconds, where as a file exporer I have installed on my phone opens that same file