I am attempting to normalize the feedback from an API in R. But in some cases, the API returns a strange format. This does not allow me to normalize and automate. I have thought of a resolution which is as follows:
- If the dataframe has more than 1 variable, then I have to keep the dataframe as it is.
- If the dataframe has 1 variable, then I have to do the transpose
This is what I tried until now:
col <- ncol(df)
df <- ifelse( col > 1, as.data.frame(df), as.data.frame(t(df))col <- ncol(df)
df <- ifelse( col > 1, as.data.frame(df), as.data.frame(t(df))
This however returns a list and does not allow the process further.