I have a list of variables(a,b,c)
from df1 which i want to pass into a API call. When we pass each variable it gives out data which may have any number of rows depending on data.
Below is the code I am using:
df$list ### has variables (a,b,c)
output_df<- data.frame()
for(k in 1:length(df$list)) {
res1z = GET(paste0("url1",df$list[[k]],"&StartDate=02-01-2023&EndDate=02-28-2023"))
dataz = fromJSON(rawToChar(res1z$content))
dataz <- as.data.frame(fromJSON(rawToChar(res1z$content)))
# dataz$emp_code<- df$list[[k]]
output_df <- rbind(output_dfz1,dataz)
The expected output i am trying to get is adding that variable column to the api output.When I try to insert it just inserts the variable a or b for just the first record.
SNo OP2 OP3 OP4 OP5 Variable
1 5.1 3.5 1.4 0.2 a
2 4.9 3.0 1.4 0.2 a
3 4.7 3.2 1.3 0.2 a
4 4.6 3.1 1.5 0.2 a
5 5.0 3.6 1.4 0.2 a
1 5.1 3.5 1.4 0.2 b
2 4.9 3.0 1.4 0.2 b
3 4.7 3.2 1.3 0.2 b
4 4.6 3.1 1.5 0.2 b
5 5.0 3.6 1.4 0.2 b