My question is little tricky. I have a vector as below
vec <-c("Camera","Battery","Protection")
And I have data frames as below Camera_pos # a Data Frame that has some columns (we may ignore the details here). Like wise we have other data frames such as Camera_neg, Battery_pos, Battery_neg, Protection_pos, Protection_neg
So I have 6 Data frame that holds some observations and those details are not of interest to the question.
Im trying to build a new Dataframe that pulls data/values from the vector and Data frames.
df <- data.frame(Features = character(),Positive = numeric(), Negative = numeric()) # empty data frame
for(i in 1:length(vec)){
df$Features[i] = vec[i] # Camera in case of vec[1]
df$Positive[i] = nrow() # not sure what code to write here, but this code should call the nrow() of Camera_pos ( i =1 is considered here)
df$Negative[i] = nrow() # not sure what code to write here, but this code should call the nrow() of Camera_neg
}
The code should be somewhat like this nrow(vec[i]_pos)
i.e nrow(Camera_pos)
in case of i =1. Request you to kindly help on this
P.S : Similarly the function should be able to call the elements in other vector too so the df has 3 rows and 3 columns filled
The output should be like below
Features Positive Negative
Camera 3 3
Battery 3 3
Protection 3 3