[R] error in unique() command

Amir Kasaeian amir_kasaeian at yahoo.com
Fri Feb 15 13:05:03 CET 2013

Dear all,
Good day!

I have a question in my codes, would you please help me how to rectify it?
these are my coded but at the last line I received the error!

mac_30 = read.dta("MAC results4.dta")
map_30 = read.dta("MAP results4.dta")
mac_30$weight = 1/nrow(mac_30)
map_30$weight = 1/nrow(map_30)
input.data = merge(mac_30, map_30, all = TRUE)
input.data.no15to19 = subset(input.data, agegroup != "15-19" | is.na(agegroup))
fit = loess(v5q0 ~ year, input.data.no15to19, weights = weight, span = 0.5)

years.predict = seq(min(input.data.no15to19$year), max(input.data.no15to19$year))

combined.method = data.frame(iso3 = unique(input.data$iso3), svdate = unique(input.data$svdate), method = "Combined method", year = years.predict)
the error is:

Error in data.frame(iso3 = unique(input.data3$iso3), svdate =unique(input.data3$svdate),  :
  arguments imply differing number of rows: 1, 4, 45

I know there is only one iso3 and 4 years but what I need is forty five 1 and forty five rows of different 4 svdate exactly equivalent to forty five rows of different years.
 Now, how can I have the same number of rows for the different variable to continue my code for rest of analysis?

Thank you so much.

Kind regards,

More information about the R-help mailing list