Hello colleague, is there a way to allow the operation of data which differ in row length without removing them manually ??
You can pad the shorter vectors with some value, perhaps NA, to match the length of the longest vector.
X <- 1:4 Y <- 1:6 data.frame(X,Y) Error in data.frame(X, Y) : arguments imply differing number of rows: 4, 6 Xnew <- c(X, rep(NA,2)) data.frame(Xnew,Y) Xnew Y 1 1 1 2 2 2 3 3 3 4 4 4 5 NA 5 6 NA 6
However, this seems like a bad idea. The purpose of a data frame row is to hold values that are associated in some way. Why do you need to force the data together?
Thank you for the reply, I want to perform Chi square test, but there are different number of participants in each of the selected areas
I suspect that a chi squared test is not appropriate but I am not sure of that. Please explain what your data are. A typical chi squared with two vectors of results would look at individual samples with two sets of categories. For example, you might have people from four nations (Mexico, Germany, India, Egypt) and each individual selects a meal (fish, chicken, vegetables). The test checks whether nationality correlates with meals for an individual. When you say you have different numbers of participants in the different areas, it seems you are not checking correlations within individuals.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.