Question: I want to set the cursor position to last character in textbox.

I'm using this code.

```
$("#txt_search").focus();

```

In **chrome** it is set cursor to last but in **mozilla** it is in first.

Answer: 
Based on agstudy's answer, the correct code is:

```
ldtSUM<-lapply(ldt,function(x)x[, sum(V4), by = "V1,V3"]

```
You had two parts to your problem:
The first part you have already solved by:

```
ldtSUM<-lapply(ldt,function(x)x[, sum(V4), by = "V1,V3"]

```

The second part is on initialization, and that can be solved by following:

```
ldtSUM <- list()

```

After this initialization if you run your original code:

```
for (i in length(ldt)) {ldtSUM[[i]]<-ldt[[i]][, sum(V4), by="V1,V3"]}

```

should also work.

Note: For your problem, the solution suggested by agstudy is best. But the initialization is a general trick that is useful in variety of situations.