[R] stacked and dodged bar graph ggplot

2016-12-30 Thread Robert Lynch
I have some census data with race and ethnicity for various towns. I am trying to make a stacked bar graph where all the race data is in one stacked bar, and all the ethnicity data is in another. Below is a minimal reproducible sample. library("ggplot2") Demog <- data.frame(source=c(rep("Davis"

[R] anova.lme

2014-07-21 Thread Robert Lynch
I would like to know the sum of squares for each term in my model. I used the following call to fit the model fit.courseCross <- lme(fixed= zGrade ~ Rep + ISE +P7APrior+Female+White+HSGPA+MATH+Years+Course+Course*P7APrior , random= ~1|SID, data = Master.complet

[R] CI for nlme predictions

2014-07-11 Thread Robert Lynch
I am running a mixed effects model with random intercepts fit.courseCross <- lme(fixed= zGrade ~ Rep + ISE +P7APrior+Female+White+HSGPA+MATH+Years+Course+Course*P7APrior , random= ~1|SID, data = Master.complete[Master.complete$Course != "P7A",]) where all varia

[R] help with the nested anova formulas

2013-12-05 Thread Robert Lynch
I am modeling grade as a function of membership in various cohorts. There are four "cohorts". (NONE, ISE07,ISE08,ISE09) and two times of cohorts coded as ISE = TRUE (ISE0#) or FALSE (NONE). There is clear co-linearity but that is to be expected. running the following code CutOff <-0 fit.base <

Re: [R] help with the nested anova formulas

2013-12-05 Thread Robert Lynch
I am modeling grade as a function of membership in various cohorts. There are four "cohorts". (NONE, ISE07,ISE08,ISE09) and two times of cohorts coded as ISE = TRUE (ISE0#) or FALSE (NONE). There is clear co-linearity but that is to be expected. running the following code CutOff <-0 fit.

[R] getting p-value for comparing to gam's from gmcv

2013-10-30 Thread Robert Lynch
I am trying to compare two different GAM fits. I have something like Course.bam20 <-bam(zGrade ~ Rep + ISE + White + Female + Years + AP_TOTAL + MATH + HSGPA+ EOP + factor(P7APrior, ordered = FALSE)+s(Yfrm7A,k=20), data= Course, na.action = na.exclude,samfrac =0.1) Course.bam4 <-bam(zGrade ~ Rep

[R] Centering multi-level unordered factors

2013-10-07 Thread Robert Lynch
I have a question I am not even sure quite how to ask. When r fits models with un-ordered categorical variables as predictors (RHS of model) it automatically converts them into 1 less dichotomous variables than there are levels. For example if I had levels(trait) = ("A","B","C") it would automa

[R] trouble with nlme: Error in MEEM() : Singularity in backsolve at level 0, block 1

2013-10-05 Thread Robert Lynch
I am trying to fit my data, attached, with the following model CutOff <- 0 fit.full <- lme(fixed= zGrade ~ Rep + ISE +Yfrm7A +Ufrm7A +Female +White +HSGPA +MATH +AP_TOTAL +Years +Course + Course*Rep + Course*ISE +Course*Yfrm7A+Course*Ufrm7A +Course*Female +Course*White +Course*H

[R] re-coding variables

2013-10-01 Thread Robert Lynch
I am running a large mixed model, 65k entries on 11 fixed effects and one random. One of the fixed effects is "Course" a factor that takes on 14 different values >levels(Master.complete$Course) [1] "B101" "B2A" "B2B" "B2C" "C118A" "C118B" "C118C" "C2A" "C2B" [10] "C2C" "N101" "P7A" "

[R] ggplot legend formatting

2013-09-19 Thread Robert Lynch
I am having trouble getting my legend to format correctly in ggplot2. A full description and pictures are in the ggplot google group. but the short description is that in guides(fill = guide_legend(nrow = 3),bycol = TRUE) changing t

Re: [R] ggplot interactions

2013-09-11 Thread Robert Lynch
> I am sorry to ask what I am sure is a simple question but I am stuck > trying to figure out how different parts of ggplot2 calls interact > > I am plotting using the following code > > ggplot(Chem.comp, aes(Course, GRADE)) + geom_boxplot(notch = TRUE,aes(fill > = COHORT))+ > labs(y ="Grade Poin

Re: [R] ggplot interactions

2013-09-11 Thread Robert Lynch
On Tue, Sep 10, 2013 at 11:33 PM, Robert Lynch wrote: > I am sorry to ask what I am sure is a simple question but I am stuck > trying to figure out how different parts of ggplot2 calls interact > > I am plotting using the following code > > ggplot(Chem.comp, aes(Course, GRAD

[R] finding both rows that are duplicated in a data frame

2013-09-07 Thread Robert Lynch
I have a data frame that looks like id1<-c(1,1,2,2,3,3,4,5,5,6,6,7,8,9,9,10) id2<-c(22,22,34,34,15,15,76,45,45,84,84,37,52,66,66,91) GENDER<-sample(c("G-UNK","G-M","G-F"),16, replace = TRUE) ETH <-sample(c("E-AF","E-UNK","E-VT"),16, replace = TRUE) example<-cbind(id1,id2,GENDER,ETH) where there a

[R] string processing(regular expressions)

2013-09-01 Thread Robert Lynch
I have a variable that is course # nCourse <- as.factor(c("002A","002B","002C","007A","007B","007C","101","118A","118B","118C")) And I would like to get rid of the leading zeros, and have the following set ("2A","2B","2C","7A","7B","7C","101","118A","118B","118C") to paste() together with the depa

Re: [R] Legend formatting (ggplot2)

2013-08-28 Thread Robert Lynch
I am having trouble getting my legend to format the way I want it to. I suspect it is something simple. > > the code I have is > library(ggplot2) > ggplot(Chem.comp, aes(Course, GRADE.)) + geom_boxplot(notch = > TRUE,aes(fill = COHORT))+ > labs(title = "Comparison between ISE cohorts and Peers

[R] the inverse of assign()

2013-08-27 Thread Robert Lynch
I am looking for a way to extract the name of a variable that has been passed into a function for example foo <-function(x){ write.csv(x, file = paste(NAME(x), "csv", sep =".")) } is there a function "NAME" that would let the calls foo(bar) write the file bar.csv and foo(stuff) write the fi

Re: [R] ave function

2013-08-20 Thread Robert Lynch
lean$TERM,Clean$INST_NUM)),function(x) > shapiro.test(x$GRADE)) > A.K. > > > > > - Original Message - > From: Robert Lynch > To: r-help@r-project.org > Cc: > Sent: Tuesday, August 13, 2013 1:46 PM > Subject: [R] ave function > > I've written the

[R] ave function

2013-08-13 Thread Robert Lynch
I've written the following function CoursePrep <- function (Source, SaveName) { Clean$TERM <- as.factor(Clean$TERM) Clean$INST_NUM <- as.factor(Clean$INST_NUM) Clean$zGrade <- with(Clean, ave(GRADE., list(TERM, INST_NUM), FUN = scale)) write.csv(Clean,paste(SaveName, "csv", sep ="."), ro

[R] help with apply (lapply or sapply not sure)

2013-07-25 Thread Robert Lynch
I am reading in a bunch of files and then processing them all in the same way. I am sure there as a better way then to copy and past the code for each file. Here is what I've done so far InputFiles<- as.character(list.files("~/ISLE/RWork/DataWarehouseMining/byCourse/")) #Path to the Course data f

[R] weighted average

2013-07-22 Thread Robert Lynch
I am trying to compute GPA from class grades(which have been normallized) I have for example the following matrix Master = SIDB2AB2BB2C C2A C2BC2CC118AC118B C118C 0010.010.5 -0.41.2 -1.8 0.3 -0.3 0.4 0.5 0020.01

[R] interpreting GLM results and plotting fits

2013-06-29 Thread Robert Lynch
I am trying to interpret the output of GLM and I am not sure how it is treating the factor GENDER with levels G-M and G-F. Below is the output of summary(GPA.lm) Call: glm(formula = zGPA ~ Units.Bfr.7A * GENDER, data = Master1) Deviance Residuals: Min 1Q Median 3Q Max -1.

[R] data selection

2013-06-18 Thread Robert Lynch
I have two different data frames ( actually a set of data frames for each class and one master one into which i want pull some data from each of the frame in the set) one is all students that have taken a course so the set of data frames is B101 B2A B2B B2C etc. . . and each one has lots of da

[R] Multiple selection and normalization

2013-06-03 Thread Robert Lynch
Hi-- I am trying to normalize course grades for each instance of a course, e.g. Stats 1 Fall2009 J. Smith. I have a frame for all instances of a course, e.g. stats 1 in the last 5 years, that looks like SIDN TERM GRADE INST where SIDN is a Student ID Number, TERM is a factor that gives the q