i have the following dataframe stored inside a variable:
project_name task_name
6 TPV
This dataframe is stored in variable called isPNfound
.
If the task name is queried in the dataframe, i'm supposed to get back the project name. But when the project name is empty, the following code is suppose to catch that and alert:
if(isPNfound$project_name == "") {
dataStatus <- paste("Task [", projectTaskName, "] has no Project assigned to it!!!")
print(dataStatus)
chkstatus <- 0
}
The above code works if there is only one taskname in the dataframe matching "TPV". But suppose there are multiple lines in the data frame, I need to run a loop on it. But im clueless on how to do that.
Sample content of dataframe:
project_name task_name
6 Rice TPV
7 Beans TPV
8 TPV
I need to somehow run my code in a loop against this dataframe. Here's my attempt:
isPNfound <- dataframeContent
if (length(isPNfound) > 1) {
for (eachtask in isPNfound){
dataStatus <- paste("Task [", projectTaskName, "] has no Project assigned to it!!!")
print(dataStatus)
chkstatus <- 0
}
}