how to calculate the number of events N(t) (counting process) at a certain time point I have a simulated survival data of failure time, censoring time, observed time and delta like the following pic (a part of the data. There are 1000 rows in total. The first column is just index numbers of the data.).
I want to calculate the $N(t)=\sum_{i=1}^{1000}N_i(t)$ when $t=2,4,6,8$, where $N_i(t)=I(T_i \le t)$(it takes 0 until $t=T_i$ and then jumps to 1. It can only take values 1 or 0.)
I'm quite confused with the concept here. Is $N(t)$ the sum of failure indicators? I think it's something about counting process.
And I know $i$ represents the subject and $t$ represents the time? Then is $N(2)=0+1=1$? Is it the right way to do the calculation?


The statistical content here is the counting-process representation of survival data, a flexible approach that allows for things like multiple events per subject and covariate values that change over time for individuals.
The $N(t)$ asked about here is one part of that representation. Yes, it represents the cumulative number of events ("sum of failure indicators") that have been observed up through time $t$.
Subscripting in the form $N_i(t)$ can, in general, represent multiple events of the same type happening to the same individual $i$. In your case if the values of $N_i(t)$ are either 0 or 1, then there is at most one event per individual. The sum that you are asked for among your 1000 cases, $N(t) = \sum_{i=1}^{1000} N_i(t)$, is over all events for all 1000 individuals up through time $t$.
So for your example of $N(2)$, even among these 17 rows I see two row/individuals with an observed event at $t=2$ or sooner: rows 10 and 15. On that basis I can certainly say that your value of $N(2)=1$ is incorrect. With each individual labeled by its row number one could say that $N_{10}(2)=1$ and that $N_{15}(2)=1$ as they both had events up through $t=2$, but the full value of $N(2)$ is the sum of those values over all 1000 individuals: clearly, at least 2.
One way to proceed that can help avoid errors is to put your cases in ascending order of observed times (event time $T$ or censoring time $C$, whichever comes first). Then as the $\delta$ values represent events, just do a cumulative sum on the $\delta$ values as time increases. That's pretty easy even with a spreadsheet.
$N(t)$ doesn't provide information about censoring. For the full counting-process analysis you also need to know the number still at risk at time $t$, often represented by $Y_i(t)$ for an individual and $Y(t)$ overall. For data like these with at most one event per individual and put into observation-time order as I recommend, that's just how many rows haven't yet been gone past when you go down the spreadsheet to a specific observation time $t$--that's how many individuals are still at risk at time $t$ regardless of whether they end up having observed or censored event times.
For both $N(t)$ and $Y(t)$ you can only use the information available to you (in principle) at time $t$. Although your data set shows values out to your maximum value of $t$, it's best to think about your analysis as starting out from time 0 and moving out progressively to larger times. At any time $t$ what you know is how many events have occurred up to and including time $t$ (that's $N(t)$) and how many individuals were still in your data set at time $t$ (that's $Y(t)$), putting aside all those that already had the event or had already been lost to follow up.
