Re: [R] Amelia error
Easily fixed, Peter - str(ad04) 'data.frame': 1195 obs. of 15 variables: $ V040001 : num 1 2 3 4 5 6 7 8 9 10 ... $ insurance: num 7 2 4 1 5 2 7 1 5 5 ... $ jobs : num 7 3 4 1 6 5 7 5 4 7 ... $ services : num 5 2 5 1 5 2 7 1 4 7 ... $ ss : num 2 2 2 1 2 1 2 1 1 3 ... $ women: num 1 2 4 1 4 4 1 1 1 1 ... $ abortion : num 3 3 3 NA 3 3 1 1 NA 1 ... $ gayrights: num 1 1 2 NA 4 4 1 1 NA 4 ... $ demrep : num 4 3 7 4 7 4 7 2 3 7 ... $ libcon : num 4 4 6 4 6 6 6 4 3 6 ... $ educ : num 8 5 7 3 4 8 7 5 8 8 ... $ south: num 0 0 1 1 1 0 0 0 0 1 ... $ gender : Factor w/ 2 levels "1. Male","2. Female": 1 1 2 1 2 1 2 2 1 2 ... $ demrep.1 : num 4 3 7 4 7 4 7 2 3 7 ... $ race : chr "White" "Other" "White" "Other" ... On Wed, Apr 18, 2012 at 2:44 PM, Peter Ehlers wrote: > On 2012-04-18 11:18, Gaurav Sood wrote: >> >> Using: Amelia::amelia >> >> R version: 2.15 >> OS: Windows 7 Enterprise >> >> data = National Election Studies (cross-sectional); mostly ordinal >> variables, some nominal >> >> summary(ad04) >> >> insurance jobs services ss women >> Min. :1.000 Min. :1.000 Min. :1.000 Min. :1.000 Min. >> :1.00 >> 1st Qu.:2.000 1st Qu.:3.000 1st Qu.:2.000 1st Qu.:1.000 1st >> Qu.:1.00 >> Median :4.000 Median :4.000 Median :3.000 Median :1.000 Median >> :1.00 >> Mean :3.656 Mean :4.207 Mean :3.478 Mean :1.408 Mean >> :1.92 >> 3rd Qu.:5.000 3rd Qu.:6.000 3rd Qu.:4.000 3rd Qu.:2.000 3rd >> Qu.:2.00 >> Max. :7.000 Max. :7.000 Max. :7.000 Max. :3.000 Max. >> :7.00 >> NA's :97 NA's :105 NA's :146 NA's :21 NA's >> :52 > > > It would be far more useful to provide the result of str(ad04) than > the above useless summary. > > Peter Ehlers > >> >> aout04<- amelia(ad04,noms=c("race","south","gender","demrep"), m=5) >> Error in if (sum(non.vary == 0)) { : >> argument is not interpretable as logical >> In addition: Warning message: >> In FUN(X[[34L]], ...) : NAs introduced by coercion >> >> >> On Wed, Apr 18, 2012 at 1:39 PM, Sarah Goslee >> wrote: >>> >>> Do you mean the Amelia package? Or a function named Amelia()? >>> >>> What is your OS and version of R and package? >>> >>> What are the commands you are using? >>> >>> What do your data look like? >>> >>> Can you provide a reproducible example? >>> >>> Did you read the posting guide? >>> >>> Your problem doesn't "seem like a bug" rather than user error unless >>> we know a whole lot more about it. >>> >>> Sarah >>> >>> On Wed, Apr 18, 2012 at 1:33 PM, Gaurav Sood wrote: >>>> >>>> Hi, >>>> >>>> Encountering the following error using Amelia - >>>> >>>> Error in if (sum(non.vary == 0)) { : >>>> argument is not interpretable as logical >>>> In addition: Warning message: >>>> In FUN(X[[34L]], ...) : NAs introduced by coercion >>>> >>>> Seems like a bug. >>>> >>> >>> -- >>> Sarah Goslee >>> http://www.functionaldiversity.org >> >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Amelia error
Sarah - I have all the vars.. they all look sensible. I have been able to trace the problem to NAs in the nominal variable, which is a bit strange. The error that the program spits out is a class logical equating error in presence of NAs etc. and hence was my hunch that it was a bug. On Wed, Apr 18, 2012 at 2:32 PM, Sarah Goslee wrote: > Hi, > > On Wed, Apr 18, 2012 at 2:18 PM, Gaurav Sood wrote: >> Using: Amelia::amelia >> >> R version: 2.15 >> OS: Windows 7 Enterprise >> >> data = National Election Studies (cross-sectional); mostly ordinal >> variables, some nominal >> >> summary(ad04) >> >> insurance jobs services ss women >> Min. :1.000 Min. :1.000 Min. :1.000 Min. :1.000 Min. :1.00 >> 1st Qu.:2.000 1st Qu.:3.000 1st Qu.:2.000 1st Qu.:1.000 1st Qu.:1.00 >> Median :4.000 Median :4.000 Median :3.000 Median :1.000 Median :1.00 >> Mean :3.656 Mean :4.207 Mean :3.478 Mean :1.408 Mean :1.92 >> 3rd Qu.:5.000 3rd Qu.:6.000 3rd Qu.:4.000 3rd Qu.:2.000 3rd Qu.:2.00 >> Max. :7.000 Max. :7.000 Max. :7.000 Max. :3.000 Max. :7.00 >> NA's :97 NA's :105 NA's :146 NA's :21 NA's :52 >> >> aout04 <- amelia(ad04,noms=c("race","south","gender","demrep"), m=5) > > According to the summary you posted above, the columns of ad04 are > insurance, jobs, services, ss, women. > > But you tell amelia() that the nominal variables in your data frame > are race, south, gender, demrem - none of which appear in ad04. > > You might want to take a look at the example given in ?amelia and then > if you're still having trouble give us the rest of the information > that I requested, particularly the versions and the reproducible > example, or at the very least the output of str(ad04). > > Sarah > > >> Error in if (sum(non.vary == 0)) { : >> argument is not interpretable as logical >> In addition: Warning message: >> In FUN(X[[34L]], ...) : NAs introduced by coercion >> >> >> On Wed, Apr 18, 2012 at 1:39 PM, Sarah Goslee wrote: >>> Do you mean the Amelia package? Or a function named Amelia()? >>> >>> What is your OS and version of R and package? >>> >>> What are the commands you are using? >>> >>> What do your data look like? >>> >>> Can you provide a reproducible example? >>> >>> Did you read the posting guide? >>> >>> Your problem doesn't "seem like a bug" rather than user error unless >>> we know a whole lot more about it. >>> >>> Sarah >>> >>> On Wed, Apr 18, 2012 at 1:33 PM, Gaurav Sood wrote: >>>> Hi, >>>> >>>> Encountering the following error using Amelia - >>>> >>>> Error in if (sum(non.vary == 0)) { : >>>> argument is not interpretable as logical >>>> In addition: Warning message: >>>> In FUN(X[[34L]], ...) : NAs introduced by coercion >>>> >>>> Seems like a bug. >>>> >> > > > -- > Sarah Goslee > http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Amelia error
Using: Amelia::amelia R version: 2.15 OS: Windows 7 Enterprise data = National Election Studies (cross-sectional); mostly ordinal variables, some nominal summary(ad04) insurance jobs services sswomen Min. :1.000 Min. :1.000 Min. :1.000 Min. :1.000 Min. :1.00 1st Qu.:2.000 1st Qu.:3.000 1st Qu.:2.000 1st Qu.:1.000 1st Qu.:1.00 Median :4.000 Median :4.000 Median :3.000 Median :1.000 Median :1.00 Mean :3.656 Mean :4.207 Mean :3.478 Mean :1.408 Mean :1.92 3rd Qu.:5.000 3rd Qu.:6.000 3rd Qu.:4.000 3rd Qu.:2.000 3rd Qu.:2.00 Max. :7.000 Max. :7.000 Max. :7.000 Max. :3.000 Max. :7.00 NA's :97 NA's :105 NA's :146 NA's :21 NA's :52 aout04 <- amelia(ad04,noms=c("race","south","gender","demrep"), m=5) Error in if (sum(non.vary == 0)) { : argument is not interpretable as logical In addition: Warning message: In FUN(X[[34L]], ...) : NAs introduced by coercion On Wed, Apr 18, 2012 at 1:39 PM, Sarah Goslee wrote: > Do you mean the Amelia package? Or a function named Amelia()? > > What is your OS and version of R and package? > > What are the commands you are using? > > What do your data look like? > > Can you provide a reproducible example? > > Did you read the posting guide? > > Your problem doesn't "seem like a bug" rather than user error unless > we know a whole lot more about it. > > Sarah > > On Wed, Apr 18, 2012 at 1:33 PM, Gaurav Sood wrote: >> Hi, >> >> Encountering the following error using Amelia - >> >> Error in if (sum(non.vary == 0)) { : >> argument is not interpretable as logical >> In addition: Warning message: >> In FUN(X[[34L]], ...) : NAs introduced by coercion >> >> Seems like a bug. >> > > -- > Sarah Goslee > http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Amelia error
Hi, Encountering the following error using Amelia - Error in if (sum(non.vary == 0)) { : argument is not interpretable as logical In addition: Warning message: In FUN(X[[34L]], ...) : NAs introduced by coercion Seems like a bug. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing data to file
look up dump On Thu, Mar 22, 2012 at 11:35 AM, mail me wrote: > Hi: > > I created a data frame > > df <- data.frame( person = c('John','Bob','Mary'), team = > c('a','b','c'), stringsAsFactors = F); > > and obtained the expected output > > df > person team > 1 John a > 2 Bob b > 3 Mary c > > now I want to save the whole content of df preserving its row and > column order to a file in disk with the following command: > > write(df, file = "testfile", append=FALSE, sep=" "); > > and I get the error message > > Error in cat(list(...), file, sep, fill, labels, append) : argument > 1 (type 'list') cannot be handled by 'cat' > > Can you help to solve the problem? Thanks in advance. > > deb > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] compare two data frames with same columns names but of different dimensions
m <- rbind(reported, exportfile) m1 <- m[duplicated(m),] m[is.na(match(m$key, m1$key)),] On Mon, Feb 27, 2012 at 9:46 AM, Arnaud Gaboury wrote: > Dear List, > > I want to compare and return the rows which are NOT in the two data frames. > Classic methods don't work as the df have NOT the same dimensions. > > > Here are one example of my df: > > reported <- > structure(list(Product = structure(c(1L, 1L, 1L, 1L, 2L, 2L, > 3L, 4L, 5L, 5L), .Label = c("Cocoa", "Coffee C", "GC", "Sugar No 11", > "ZS"), class = "factor"), Price = c(2331, 2356, 2440, 2450, 204.55, > 205.45, 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61L, -61L, > 5L, 1L, 40L, 40L, -1L, -1L, -1L, 1L)), .Names = c("Product", > "Price", "Nbr.Lots"), row.names = c(1L, 2L, 3L, 4L, 6L, 7L, 5L, > 10L, 8L, 9L), class = "data.frame") > > exportfile <- > structure(list(Product = c("Cocoa", "Cocoa", "Cocoa", "Coffee C", > "Coffee C", "GC", "Sugar No 11", "ZS", "ZS"), Price = c(2331, > 2356, 2440, 204.55, 205.45, 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61, > -61, 6, 40, 40, -1, -1, -1, 1)), .Names = c("Product", "Price", > "Nbr.Lots"), row.names = c(NA, 9L), class = "data.frame") > > As you can see, they have same column names. > My idea was to merge these two df when passing as argument "not to take into > account duplicate rows", so I will get one df with rows which are not in both > df. > Is it possible? How to do it? > > TY for any help. > > > Arnaud Gaboury > > A2CT2 Ltd. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.