[R] Barplots inside loop - several data errors, workaround needed
I have a series of data which is managed through a loop. The loop creates "pivot tables" of my data using the *cast* function in the *reshape*library. For the most part, the data is all plotted correctly. Unfortunately, there are a couple of data sets which create errors and halt the loop. One of the tables looks like the following: dbh Black Walnut 1 8 38.19722 2 10 48.89244 3 12 38.19722 When the loop attempts the barplot() function, the following error is returned: Error in seq_len(p) : argument must be coercible to non-negative integer In other cases, there is simply no data in the specified set of data. Therefore, the table is full of NA's. Obviously, this does not need to be plotted, but I cannot simply remove it from the larger database. I need my loop to continue regardless of if it runs into these issues. *Question: What can I do to ensure the above single variable table will plot correctly? and what can I do to suppress errors on the datasets which do not have data so the loop continues?* full code: http://pastebin.com/LB88hpfM Thank you in advance. -- all the best, Lee Mueller ISA Certified Arborist MI-4148A Registered Forester #46043 [[alternative HTML version deleted]] __ 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] Barplots inside loop - several data errors, workaround needed
Looking at the documentation for try() I am not sure how it would be best applied in this situation. My background is not extensively programming. Would writing a function first be appropriate? Also, I'm not sure just a simple error catch would solve my first problem. I do, in fact, need it to plot the barplot based on the table which is created above. However, R doesn't like the lack of several columns. Further guidance would be appreciated. -- all the best, Lee Mueller ISA Certified Arborist MI-4148A Registered Forester #46043 On Wed, May 9, 2012 at 4:30 AM, Jim Holtman wrote: > ?try > > Sent from my iPad > > On May 8, 2012, at 22:03, Lee wrote: > > > I have a series of data which is managed through a loop. The loop creates > > "pivot tables" of my data using the *cast* function in the > > *reshape*library. For the most part, the data is all plotted > > correctly. > > Unfortunately, there are a couple of data sets which create errors and > halt > > the loop. > > > > One of the tables looks like the following: > > > > dbh Black Walnut > > 1 8 38.19722 > > 2 10 48.89244 > > 3 12 38.19722 > > > > When the loop attempts the barplot() function, the following error is > > returned: > > Error in seq_len(p) : argument must be coercible to non-negative integer > > > > In other cases, there is simply no data in the specified set of data. > > Therefore, the table is full of NA's. Obviously, this does not need to be > > plotted, but I cannot simply remove it from the larger database. I need > my > > loop to continue regardless of if it runs into these issues. > > > > *Question: What can I do to ensure the above single variable table will > > plot correctly? and what can I do to suppress errors on the datasets > which > > do not have data so the loop continues?* > > > > full code: http://pastebin.com/LB88hpfM > > > > Thank you in advance. > > > > -- > > all the best, > > Lee Mueller > > ISA Certified Arborist MI-4148A > > Registered Forester #46043 > > > >[[alternative HTML version deleted]] > > > > __ > > 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. > [[alternative HTML version deleted]] __ 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] A question on modeling brain growth using GAM
Hi, Simon Thank you for your explanation! I followed the instructions and successfully get the predicted values with both fixed and random effects incorporated: pred.new=predict.gam(gamm1$gam,newdata,type="response"). Also, what I meant to say was "plot(gamm1$gam, pages=1)" for left and right figures. I didn't attach any figures. Thank you very much for the help! L On Thu, Apr 6, 2017 at 10:44 AM, Simon Wood wrote: > > gamObj=gam(brainVolume~ s(correctedAge) + s(subjIndexF, bs="re") + > s(subjIndexF, correctedAge, bs="re"), method="REML", data=mydata), where > subjIndexF is a factor for each subject. I was thrown an error saying "more > coefficients than data". > > --- I'm not sure exactly how many scans and subjects you have. The above > model will have 10 + 2*(number of subjects ) coeffs. If that is more than > the number of scans then gam will not handle it. Depending on the numbers > involved you could reduce the k parameter to s(correctedAge), to fix the > problem. (e.g. with 31 subjects and 70 scans s(correctedAge=8) should work > ). > > However, when I tried to model similar (please correct me if they are not > similar) things using GAMM based on description in > ?factor.smooth.interaction: > gamm1=gamm(BrainVolume~ s(correctedAge) + s(correctedAge, subjIndexF, > bs="fs", k=5), data=mydata) > > --- It's not the same model. You now have a random smooth curve per > subject. You can add random effects in gamm using the list form of the > syntax for specifying random effects in lme. see ?gamm. Random intercepts > and slopes can be added that way. > > The model ran. When I plotted the data using plot(gamm1), I got two > figures: the left one is the group mean and 95%CI, which I assume is the > results by gamm1$gam model. The right one shows 30 lines (the number of > subjects in my data) fluctuating around 0, which I assume is the random > effects (gamm1$lme) modeled within each subject that can be added onto the > group mean for individual curves. Is my understanding correct? If so, how > can I extract these curves from gamm1$lme? > > --- I would extract the fitted curves using predict(gamm1$gam,..., > type="terms") supplying the factor levels and correctedAges at which you > want to evaluate the curves. > > Many thanks! > L > > > > On Thu, Apr 6, 2017 at 8:22 AM, Simon Wood wrote: > >> If 'subjIndexF' is a factor for subject, then s(subjIndexF, bs="re") will >> produce a random effect for subject. i.e. each subject will be given its >> own random intercept term, which is a way that repeated measures data like >> this are often handled. >> >> The reason for the s(subjIndexF, bs="re") syntax is that smooths can be >> viewed as Gaussian random effects, so simple Gaussian random effects can >> also be viewed as (0-dimensional) smooths. In general s(x,z,w,bs="re") just >> appends the columns of model.matrix(~x:z:w-1) to the gam model matrix, and >> treats the associated coefficients as i.i.d. Gaussian random effects with a >> common variance (to be estimated). In principle this works with any number >> of arguments to s(...,bs="re"). >> >> See ?random.effects (and its linked help files) in mgcv for more. >> >> There are mechanisms for allowing random smooth curves for each subject, >> (e.g. ?factor.smooth.interaction), but I would only use these if simpler >> approaches really aren't adequate here. >> >> best, >> Simon >> >> >> >> >> On 30/03/17 17:06, David Winsemius wrote: >> >>> On Mar 30, 2017, at 6:56 AM, Leon Lee wrote: >>>> >>>> David >>>> >>>> Thank you for your reply. I apologize if I posted in the wrong forum, >>>> as I really couldn't decide which forum is the best place for my question >>>> and I saw similar questions asked before in this forum. >>>> >>>> I agree that a sample of ~30 subjects (70 scans in total), the model >>>> can be too complicated. Based on that, I did the following: >>>> (1) ignored the gender effect, as we have less females than males. >>>> (2) corrected chronological age based on their gestational age, that >>>> is, we subtracted an infant's chronological age by 2 weeks, if the infant's >>>> gestational age is 38 weeks instead of 40weeks. >>>> >>>> When I ran the model with corrected age, gestational age and their >>>> interactions modeled, I found the main effect of gestational age and th
Re: [R] A question on modeling brain growth using GAM
Simon I wonder whether I can take advantage of this thread and ask you another related question. Now, I want to get the 95%CI of the fit and their derivatives as well. For the original fitted curves, It is straightforward as the option "type=terms" can be used to get the CI for the fixed effect. Now, I want to get the CI for the fixed effect in the first derivative as well. I tried to follow your example in the predict.gam() and got stuck here: %- predict.gam example- dat <- gamSim(1,n=300,scale=sig) b<-gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat) plot(b,pages=1) ## now evaluate derivatives of smooths with associated standard ## errors, by finite differencing... x.mesh <- seq(0,1,length=200) ## where to evaluate derivatives newd <- data.frame(x0 = x.mesh,x1 = x.mesh, x2=x.mesh,x3=x.mesh) X0 <- predict(b,newd,type="lpmatrix") eps <- 1e-7 ## finite difference interval x.mesh <- x.mesh + eps ## shift the evaluation mesh newd <- data.frame(x0 = x.mesh,x1 = x.mesh, x2=x.mesh,x3=x.mesh) X1 <- predict(b,newd,type="lpmatrix") Xp <- (X1-X0)/eps ## maps coefficients to (fd approx.) derivatives colnames(Xp) ## can check which cols relate to which smooth par(mfrow=c(2,2)) Xi <- Xp*0 Xi[,1:9+1] <- Xp[,1:9+1] ## Xi%*%coef(b) = smooth deriv i df <- Xi%*%coef(b) ## ith smooth derivative df.sd <- rowSums(Xi%*%b$Vp*Xi)^.5 ## cheap diag(Xi%*%b$Vp%*%t(Xi))^.5 %-predict.gam example--- Am I right that df.sd is the standard error for the derivatives and I can get the 95% CI by 1.96*df.sd? If so, is this the CI for the fixed effect or fixed + random effects for the predictions that have random effects modeled? as I mentioned earlier, my model includes both fixed and random effects: gamm1=gamm(BrainVolume~ s(correctedAge) + s(correctedAge, subjIndexF, bs="fs", k=5), data=mydata) For the newd in the predict(), I constructed a data frame with all the time points for all subjects and fed it into the predict.gam() function. If I only want to get the CI for the fixed effect only for the derivatives, what should I change here? Many thanks in advance! L On Thu, Apr 6, 2017 at 2:16 PM, Leon Lee wrote: > Hi, Simon > > Thank you for your explanation! I followed the instructions and > successfully get the predicted values with both fixed and random effects > incorporated: pred.new=predict.gam(gamm1$gam,newdata,type="response"). > > Also, what I meant to say was "plot(gamm1$gam, pages=1)" for left and > right figures. I didn't attach any figures. > > Thank you very much for the help! > L > > On Thu, Apr 6, 2017 at 10:44 AM, Simon Wood wrote: > >> >> gamObj=gam(brainVolume~ s(correctedAge) + s(subjIndexF, bs="re") + >> s(subjIndexF, correctedAge, bs="re"), method="REML", data=mydata), where >> subjIndexF is a factor for each subject. I was thrown an error saying "more >> coefficients than data". >> >> --- I'm not sure exactly how many scans and subjects you have. The above >> model will have 10 + 2*(number of subjects ) coeffs. If that is more than >> the number of scans then gam will not handle it. Depending on the numbers >> involved you could reduce the k parameter to s(correctedAge), to fix the >> problem. (e.g. with 31 subjects and 70 scans s(correctedAge=8) should >> work). >> >> However, when I tried to model similar (please correct me if they are not >> similar) things using GAMM based on description in >> ?factor.smooth.interaction: >> gamm1=gamm(BrainVolume~ s(correctedAge) + s(correctedAge, subjIndexF, >> bs="fs", k=5), data=mydata) >> >> --- It's not the same model. You now have a random smooth curve per >> subject. You can add random effects in gamm using the list form of the >> syntax for specifying random effects in lme. see ?gamm. Random intercepts >> and slopes can be added that way. >> >> The model ran. When I plotted the data using plot(gamm1), I got two >> figures: the left one is the group mean and 95%CI, which I assume is the >> results by gamm1$gam model. The right one shows 30 lines (the number of >> subjects in my data) fluctuating around 0, which I assume is the random >> effects (gamm1$lme) modeled within each subject that can be added onto the >> group mean for individual curves. Is my understanding correct? If so, how >> can I extract these curves from gamm1$lme? >> >> --- I would extract the fitted curves using predict(gamm1$gam,..., >> type="terms") supplying the factor levels and correctedAges at
[R] Question about change the length of a string.
Hello everyone, I have a question and I need your precious kind help. I am working on matching two string. However, the length of the two strings is different. For example, one is "example" (nchar=7), the other one is "example " (nchar=10). The R considers them as different strings but they will be the same if I could make the first string has 10 characters, "example" followed by 3 spaces. However, I could not find a way to do it. Is there anyone able to provide some suggestions? I appreciate your precious time Best, Yen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Question about change the length of a string.
Hi Jeff, Thank you a lot! Best, Yen -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Thursday, May 18, 2017 11:11 PM To: r-help@r-project.org; Yen Lee Subject: Re: [R] Question about change the length of a string. http://stackoverflow.com/questions/2261079/how-to-trim-leading-and-trailing-whitespace-in-r -- Sent from my phone. Please excuse my brevity. On May 18, 2017 8:57:51 PM PDT, Yen Lee wrote: >Hello everyone, > > > >I have a question and I need your precious kind help. > > > >I am working on matching two string. However, the length of the two >strings is different. For example, one is "example" (nchar=7), the >other one is >"example " (nchar=10). The R considers them as different strings but >they >will be the same if I could make the first string has 10 characters, >"example" followed by 3 spaces. However, I could not find a way to do >it. Is there anyone able to provide some suggestions? > > > >I appreciate your precious time > > > >Best, > >Yen > > > > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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 -- To UNSUBSCRIBE and more, see 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] Multinomial Regression for Complex Survey
Hi Dear Rusers, I am working on a survey data with the "survey" package. The logistic regression and multinomial regression would be the main statistic method I want to use. I found that the svyglm function could be used to conduct the logistic regression with the complex design but not the multinomial regression. I wonder if there is any package or function in the "survey" could be used to handle this problem. Please let me know if you have any clue. I appreciate your willingness to help! Thank you for your time! Best, Yen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Cluster analysis with Weighted attribute
Hi! All. I'm not much familiar with R. So I tried to find a R function or packages that could work with my problems. What I wonder is, Whether there is any R function or package that includes the cluster analysis considering with the weighted attribute. I saw several papers that dealt with the Attribute Value Weighting in K-Modes Clustering. but I could not find the R function or packages related with this. We got the weight of each attributes by interviewing the experts. What we want to do is do cluster analysis regarding with those weighted value on the attributes. Is there any suggestion for me?? It would be much appreciated ! Thanks for your interest on my question! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] (no subject)
Hello forum members, I am taking this R course which I have to admit that it is beyond my capability. I am asked to analyze the following data(file attached) according to the question provided below: 1. The file [data_13-9.txt] contains a data of length 225, which seems to have some cycle pattern. (1) Fit a suitable model for this data, then report the model equation. (2) Provide the forecast values for 3-steps ahead and 6-steps ahead. I am desperately seeking for your help, since I really don't know where to start.. I have done "plot.ts(data.13-6)", but not further. Above question is just part of the whole task, but I believe solving this would be very much helpful for me to jump in to the other questions. It would be easier for me to follow if your answer is in R script.. I appreciate your patience and help. Thank you so much in advance! Cheers, Lia fourth_a.ts 1 -0.0242227774450564 2 0.447778425867187 3 0.0679634009051251 4 0.390085614914361 5 0.249535226083153 6 0.518797872921499 7 -0.0969256279112136 8 0.123337983703432 9 -0.414941322119016 10 -0.27757276812968 11 0.0403939285820523 12 0.494211788018315 13 0.124244228153442 14 0.394493565117432 15 0.188705401390586 16 0.532762644104765 17 -0.10747895472636 18 0.144164346660537 19 -0.336048738751554 20 -0.268668787023198 21 0.0632175364558109 22 0.425890066866375 23 0.129576388534439 24 0.434428059119178 25 0.166373082777172 26 0.500324747168639 27 -0.181757008467706 28 0.111908426500126 29 -0.271053619415509 30 -0.167744715393572 31 -0.0338728333227656 32 0.333625139545928 33 0.0140758980245519 34 0.357007127635719 35 0.117528321727847 36 0.436606929603184 37 -0.281483140210634 38 0.0207127868483681 39 -0.347869271054934 40 -0.173998579595848 41 -0.0799206011874377 42 0.277044216890528 43 -0.114919716596858 44 0.284979270819777 45 -0.0204983858654412 46 0.404494915834395 47 -0.293744301550975 48 0.127254025577103 49 -0.260160101188769 50 -0.0875216627615043 51 -0.0462217977187355 52 0.397719199372734 53 -0.0591056840364732 54 0.367738474710558 55 -0.0152206137909984 56 0.353167727849039 57 -0.312136059481424 58 0.143633095475107 59 -0.171180250675521 60 -0.0465141674925802 61 0.0899046896169316 62 0.598910847300957 63 0.0475490561242251 64 0.358240966214597 65 -0.115970806757625 66 0.322290982770865 67 -0.286140052945316 68 0.0618578078197809 69 -0.212161273189703 70 -0.0454341579685268 71 0.0105666268253198 72 0.581041116690388 73 0.0693941384243427 74 0.261971378607031 75 -0.123479577576325 76 0.367590419177466 77 -0.141235430279281 78 0.116237028180501 79 -0.198695126295741 80 -0.0657961678537194 81 -0.0135147919675166 82 0.64984396453257 83 -0.0167548399541178 84 0.227526983440523 85 -0.299388449116629 86 0.416617177307962 87 -0.203407983560365 88 -0.0023010455436364 89 -0.282560660653303 90 -0.176413766464725 91 -0.0983101390414709 92 0.676705573655853 93 0.0203031107706873 94 0.312294913410111 95 -0.165489563226253 96 0.495102364234008 97 -0.305931623403696 98 0.0254406084608136 99 -0.225414817884392 100 -0.15036962703039 101 -0.112423279517229 102 0.745007684199088 103 0.0255308466866797 104 0.315917556432058 105 -0.303111962111323 106 0.4422161899518 107 -0.369563414156803 108 0.0535188548883159 109 -0.164608441001884 110 -0.156343742785993 111 -0.207438206198236 112 0.689341282064895 113 -0.00226758654004458 114 0.288620788540252 115 -0.400804924124587 116 0.359566102139385 117 -0.321517807983831 118 0.00695988179093469 119 -0.231063555270884 120 -0.0754597599841716 121 -0.217474888732617 122 0.683362779387654 123 -0.00314961139535584 124 0.30330965844177 125 -0.345238161601586 126 0.360311898301801 127 -0.301677126208083 128 0.0752078039771654 129 -0.155192129731062 130 -0.061593861998895 131 -0.219884190719033 132 0.628023504848516 133 -0.0382384606055213 134 0.297499086480709 135 -0.346531677222434 136 0.327798639134225 137 -0.391356801473802 138 0.0491703726922144 139 -0.249887313782597 140 -0.114655677012198 141 -0.220433378749168 142 0.560059582446338 143 -0.196920702930255 144 0.219878996139467 145 -0.373914844022043 146 0.292758745532306 147 -0.471257747874178 148 0.101291169049118 149 -0.177115964022913 150 -0.132451723823155 151 -0.21848909838528 152 0.514021082036989 153 -0.211628524400154 154 0.249156930945686 155 -0.277957223804047 156 0.292060580594635 157 -0.411605289128537 158 0.15610957238629 159 -0.167147715462073 160 -0.116581851584324 161 -0.234964260449157 162 0.526997072058525 163 -0.234040498456114 164 0.193292408158503 165 -0.286173628961541 166 0.329912374179291 167 -0.439242525292821 168 0.12873648130915 169 -0.211483057184516 170 -0.160118716712957 171 -0.168318618554501 172 0.553840105722893 173 -0.184533155434883 174 0.134661753730845 175 -0.264620194457709 176 0.378708889591781 177 -0.400340933892769 178 0.105012175958662 179 -0.28484391241728 180 -0.200352172901001 181 -0.217957678983035 182 0.524658753398018 183 -0.287612226565405 184 0.0883221554409499 185 -0.341060900924494 186 0.263243703023783 187 -0.43
[R] How to generate mtable output from lm with response matrix
lm can accept a multiple response variables, and produces a list containing one model per response variable. I would like to compare those models using the mtable function from the memisc package. I cannot figure out the indexing of the list produced by the lm call. How can I extract an lm from the list produced by a call of the form: data(mtcars) lmTest = lm(cbind(mpg, hp) ~ disp + wt + carb, data=mtcars) Best, --Lee -- Lee Hachadoorian Assistant Professor in Geography, Dartmouth College http://geospatial.commons.gc.cuny.edu http://freecity.commons.gc.cuny.edu __ 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] Draw a dendrogram with ROCK clustering (cba package)
Dear all. Hi, Currently, i do clustering analysis with several algorithms in R. one of them is ROCK clustering. Thanks to "cba" package in R, i could easily analyze with ROCK. (https://cran.r-project.org/web/packages/cba/cba.pdf) but what I want to see is a dendrogram which could be intuitive to define the number of clusters. I tried to find possible functions which could draw a dendrogram within cba packages. but i couldn't... Is there any way to draw a dendrogram with ROCK clustering outcome ? Any comments would be helpful for me to keep on this research. Thanks ! All the best, Ahreum Lee. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Matrix-free fused lasso
Hi, I am looking for an implementation of the fused lasso that allows the predictor matrix to be an "abstract" linear operator, namely the cumulative sum (that is, (X.b)_i = sum(b_k, k=1..i)) (due to the size of the problem, forming the entire matrix is unlikely to be a good approach). Any pointers would be welcome. Thanks! Antony [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] A question on modeling brain growth using GAM
Hi, R experts I am new to R & GAM toolbox and would like to get inputs from you all on my models. The question I have is as follows: I have 30 subjects with each subject being scanned from one to three times in the first year of life. The brain volume from each scan was measured. The scan time was randomly distributed from birth to 1 year. Each subject has different gestational age ranging from 38 to 41 weeks Each subject has chronological age from birth to 1 year old Each subject has gender category. Now, I want to look at how predictors, such as subject's chronological age, gestational age and gender will explain the changes in brain volume. I also want to include interactions between gender and age, gestational and chronological age. Random effects are also included in the model to account for subject variability. My model looks like the follows: gam=gam(brainVolume~ s(age) + ti(age, gestationalAge) + gestationalAge + sex + s(age, by=sex) + s(subjIndexF, bs="re"), method="REML", data=mydata) Are there any obvious mistakes in the model? Any suggestions will be greatly appreciated! L [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] A question on modeling brain growth using GAM
David Thank you for your reply. I apologize if I posted in the wrong forum, as I really couldn't decide which forum is the best place for my question and I saw similar questions asked before in this forum. I agree that a sample of ~30 subjects (70 scans in total), the model can be too complicated. Based on that, I did the following: (1) ignored the gender effect, as we have less females than males. (2) corrected chronological age based on their gestational age, that is, we subtracted an infant's chronological age by 2 weeks, if the infant's gestational age is 38 weeks instead of 40weeks. When I ran the model with corrected age, gestational age and their interactions modeled, I found the main effect of gestational age and the interaction between the two are gone. So, my final model will look something like this: gamObj=gam(brainVolume~ s(correctedAge) + s(subjIndexF, bs="re"), method="REML", data=mydata) Does this look more reasonable? Yes, I am relatively new to the mixed model. We originally applied functional data analysis (PACE) on the data, but want to see the results using a different approach. Also, I couldn't find the Mixed Models list, do you mind sending me a link? Thank you! Longchuan On Tue, Mar 28, 2017 at 4:28 PM, David Winsemius wrote: > > > On Mar 28, 2017, at 9:32 AM, Leon Lee wrote: > > > > Hi, R experts > > > > I am new to R & GAM toolbox and would like to get inputs from you all on > my > > models. The question I have is as follows: > > I have 30 subjects with each subject being scanned from one to three > times > > in the first year of life. The brain volume from each scan was measured. > > The scan time was randomly distributed from birth to 1 year. > > Each subject has different gestational age ranging from 38 to 41 weeks > > Each subject has chronological age from birth to 1 year old > > Each subject has gender category. > > Now, I want to look at how predictors, such as subject's chronological > age, > > gestational age and gender will explain the changes in brain volume. I > also > > want to include interactions between gender and age, gestational and > > chronological age. Random effects are also included in the model to > account > > for subject variability. My model looks like the follows: > > > > gam=gam(brainVolume~ s(age) + ti(age, gestationalAge) + gestationalAge + > > sex + s(age, by=sex) + s(subjIndexF, bs="re"), method="REML", > data=mydata) > > > > Are there any obvious mistakes in the model? Any suggestions will be > > greatly appreciated! > > I'm not seeing mistakes in the syntax but I would question whether 30 > subjects is sufficient to adequately support estimates in a a model of this > complexity. I would also think that the 's(age)' and 'sex' terms would get > aliased out in a model with "+ s(age, by=sex)". Most R regression functions > handle removal of over-parametrization automatically. > > You also have a variable number of measurements per subject. I am unable > to comment on the effort to account for the implicit and variably measured > correlation and auto-correlation of values within subjects using a "smooth" > on subjIndexF, since that is not an approach I was familiar with. But I am > getting concerned whether you are also new to statistical modeling in > addition to your use of R and GAM being "new to you"? > > (Perhaps Simon or one of the mixed-effects experts can correct the gaps in > my understanding of how to model repeated measures in the context of small > numbers of subjects and irregular emasurements.) > > Please read the Posting Guide and the pages of candidate mailing lists. > Rhelp is not really the place to go when you need statistical advice. I'm > not sure if this is really in the center of concerns that get discussed on > the Mixed Models list, but to my eyes it would be a better fit there. > > -- > David. > > > > L > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > David Winsemius > Alameda, CA, USA > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] How to extract component number of RMSEP in RMSEP plot
Hi R-listers, > > I would like to know how can i extract (ncomps) component no. when the > RMSEP is lowest for PLS package? > > Currently, I only plot it manually, validationplot(pls) and then only feed > the ncomp to the jack knife command. However, I would like to automate this > step. > > Please let me know. Many thanks. > > Rgrds, > [[alternative HTML version deleted]] __ 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] How to extract component number of RMSEP in RMSEP plot
Hi Bjorn, Greetings. I would like to know how can i extract component no. when the RMSEP is lowest? > > Currently, I only plot it manually and then only feed the ncomp to the jack > knife command. However, I would like to automate this step. > > Please let me know. Many thanks. > > Rgrds, > [[alternative HTML version deleted]] __ 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] How to convert/map jacktest results to dataframe or file
Hi, I have issue a jacktest command and it produces me a list of numbers. I would like to map them to a dataframe so I could save it to a file. I tried to convert the mvr.obj to vector but when I check the class, it is still jacktest. converted<-as.vector(mvr.obj) Or any otehr way to map this to a file eventually? Please advise. Appreciate your help. Thanks. [[alternative HTML version deleted]] __ 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] How to run a model 1000 times, while saving coefficients each time?
Hey Mark, I'm not sure if anyone gave this answer, but I have a similar setup in one of my codes, to get the coefficients and r^2 value, you can use the commands: model1$coefficients (or any part of the term since R can recognize the first couple of letters) summary(model1)$r.squared as for saving the values in your loop, you could try something like this: coef1 <- c() for(i in 1000){ # rest of the code... newcoef1 <- model1$coef coef1 <- rbind(coef1,newcoef1) } HTH. Cheers. - Derrick Greg Snow wrote: ?replicate -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Na Sent: Monday, August 25, 2008 2:45 PM To: [EMAIL PROTECTED] Subject: [R] How to run a model 1000 times, while saving coefficients each time? Hello, We have written a program (below) to model the effect of a covariate on observed values of a response variable (using only 80% of the rows in our dataframe) and then use that model to calculate predicted values for the remaining 20% of the rows. Then, we compare the observed vs. predicted values using a linear model and inspect that model's coefficients and its R2 value. We wish to run this program 1000 times, and to save the coefficients and R2 values into a separate dataframe called results. We have a looping structure (also below) but we do not know how to save the coefficients and R2 values. We are missing some code (indicated) Any assistance would be greatly appreciated. Thanks, library(sampling) mall<-read.csv("mall.csv") for (j in 1:1000) { s<-srswor(2840,3550) mall80<-mall[s==1,] mall20<-mall[s==0,] model1<-lm(count~habitat,data=mall80) summary(model1) mall20$predicted<-predict(model1,newdata=mall20) model2<-lm(count~predicted,data=mall20) MISSING CODE: SAVE MODEL COEFFICIENTS AND R2 VALUE TO A DATAFRAME CALLED RESULTS } __ 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. -- Sincerely - Derrick Derrick Lee, MSc Candidate Department of Statistics The University of British Columbia LSK-314A | 604 - 822 - 1299 x532 d.lee at stat dot ubc dot ca | dgylee at mun dot ca www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/ __ 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] releasing memory when using the ncdf package
Hello, I'm running R 2.7.2 in a windows XP environment and I run the following in an R console: library(ncdf) nc <-open.ncdf('c:/file.nc') aa <- get.var.ncdf(nc,'var1') This works fine, but 'aa' takes up about 100mb and I want to release the memory after using it. I try: rm(aa) close.ncdf(nc) and look at Windows Task Manager, but the memory hasn't been released. Do you know what I should do to release the memory? Thanks in advance. eric __ 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] somebody help me about this error message...
I created variables automatically like this way for(i in 1:5){ nam <- paste("a",i,sep="") assign(nam,1:i) } and then, i want to insert a new data into "a2" variable. so, i did next sentence paste("a",2,sep="") <- 4 so, i got this error message Error in get(paste("a", 2, sep = ""))[1] <- 4 : target of assignment expands to non-language object anyone knows abou this error message and tell me how to solve thie problem, please.. -- View this message in context: http://n4.nabble.com/somebody-help-me-about-this-error-message-tp1571700p1571700.html Sent from the R help mailing list archive at Nabble.com. __ 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] Calling SAS from R
I'm new to post in R-help and my native language is not English. I apologize if my sentence is not fluent to read. I am doing a simulation study and I need to execute SAS and read a SAS code in R. I try the following code but it doesn't work. system('"c:\\program files\\SAS\\SAS 9.1\\sas.exe" "c:\\syntax.sas"') can anyone give me some help with this? Thanks Yen [[alternative HTML version deleted]] __ 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] Calling SAS from R
Thank you for your reply. Because my R program is Chinese version, I would try my best to translate and specify my question more precisely. When I type system('"c:\\Program Files\\SAS\\SAS 9.1\\sas.exe","c:\\entropy\\output7\\scale\\syntax.sas"') The warning message is as follow, In system("\"c:\\Program Files\\SAS\\SAS 9.1\\sas.exe\",\"c:\\entropy\\output7\\scale\\syntax.sas\"") : "c:\Program Files\SAS\SAS 9.1\sas.exe","c:\entropy\output7\scale\syntax.sas" is not be found When I try system('"c:\\Program Files\\SAS\\SAS 9.1\\sas.exe"','"c:\\entropy\\output7\\scale\\syntax.sas"') The warring message is as follow, The mistake is if (intern) flag <- 3L else { : The argument can not be interpreted as the logical value. These commands also don't work outside R, but I also don't know how to modify. I guess it's because I lose a command to tell SAS to read the file, but I don't know how to do this. Hope it's clear enough. Can anyone give me some help with this? Thanks~ Yen -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker Sent: Monday, March 01, 2010 12:32 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Calling SAS from R Yen Lee ntu.edu.tw> writes: > I apologize if my sentence is not fluent to read. > > I am doing a simulation study and I need to execute SAS and > read a SAS code in R. > I try the following code but it doesn't work. > system('"c:\\program files\\SAS\\SAS 9.1\\sas.exe" "c:\\syntax.sas"') > can anyone give me some help with this? You need to tell us, as precisely as possible, what "doesn't work" means. Did R produce warnings or error messages? What were they? If you run the equivalent command (the same except for single vs double backslashes and surrounding quotation marks) "c:\program files\SAS\SAS 9.1\sas.exe" "c:\syntax.sas" outside of R (in a terminal window or from the "Run" box in Windows), does it work? __ 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. [[alternative HTML version deleted]] __ 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] Calling SAS from R
Thanks for all insightful replies. I've solved the problem by using the code as following, system('"C:\\Program Files\\SAS\\SAS 9.1\\sas.exe" C:/entropy/output7/scale/syntax.sas') Thanks for you all. Yen Lee -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Monday, March 01, 2010 8:32 PM To: Yen Lee Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Calling SAS from R On 01.03.2010 08:42, Yen Lee wrote: > Thank you for your reply. > > > > Because my R program is Chinese version, > > I would try my best to translate and specify my question more precisely. > > > > When I type > > system('"c:\\Program Files\\SAS\\SAS > 9.1\\sas.exe","c:\\entropy\\output7\\scale\\syntax.sas"') > > The warning message is as follow, > > In system("\"c:\\Program Files\\SAS\\SAS > 9.1\\sas.exe\",\"c:\\entropy\\output7\\scale\\syntax.sas\"") : > >"c:\Program Files\SAS\SAS > 9.1\sas.exe","c:\entropy\output7\scale\syntax.sas" is not be found > > > > When I try > > system('"c:\\Program Files\\SAS\\SAS > 9.1\\sas.exe"','"c:\\entropy\\output7\\scale\\syntax.sas"') > > The warring message is as follow, > > The mistake is if (intern) flag<- 3L else { : The argument can not be > interpreted as the logical value. See ?shell (and ?system) and find that you need one string such as: shell('"c:\\Program Files\\SAS\\SAS 9.1\\sas.exe" "c:\\entropy\\output7\\scale\\syntax.sas"') given the paths are correct. Uwe Ligges > > > These commands also don't work outside R, but I also don't know how to > modify. > > > > I guess it's because I lose a command to tell SAS to read the file, but I > don't know how to do this. > > > > Hope it's clear enough. > > Can anyone give me some help with this? > > > > Thanks~ > > > > Yen > > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Ben Bolker > Sent: Monday, March 01, 2010 12:32 AM > To: r-h...@stat.math.ethz.ch > Subject: Re: [R] Calling SAS from R > > > > Yen Lee ntu.edu.tw> writes: > > > >> I apologize if my sentence is not fluent to read. > >> > >> I am doing a simulation study and I need to execute SAS and > >> read a SAS code in R. > >> I try the following code but it doesn't work. > >> system('"c:\\program files\\SAS\\SAS 9.1\\sas.exe" "c:\\syntax.sas"') > >> can anyone give me some help with this? > > > >You need to tell us, as precisely as possible, > > what "doesn't work" means. > >Did R produce warnings or error messages? What were they? > >If you run the equivalent command (the same except for > > single vs double backslashes and surrounding quotation marks) > > > > "c:\program files\SAS\SAS 9.1\sas.exe" "c:\syntax.sas" > > > >outside of R (in a terminal window or from the "Run" box > > in Windows), does it work? > > > > __ > > 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. > > > [[alternative HTML version deleted]] > > __ > 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. [[alternative HTML version deleted]] __ 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] Making multiple columns to a single column
Hi guys, I have a very simple question. I'm trying to make multiple columns to a single column. For example, *ttx1* is a 46*72 matrix. so, I tried this. *d1=ttx1[,1] d2=ttx1[,2] ... d72=ttx1[,72]* now, d1, d2, ...,d72 become a 46*1 matrix. And then.. I tried.. *dd=rbind(d1, d2, ..., d72)* I thought *dd* should be 3312*1 matrix; but it becomes 72*46. I really wanted to make it a single column (3312*1). Do you know what is wrong in this code? Or, do you have a better idea in making multiple columns to a single column? Thank you so much. -Hyo [[alternative HTML version deleted]] __ 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] corspatial
Hi. I have a dataset of unique coordinates (no missing coordinates). When I did the following: lonlat<-mydata[, c("lon, "lat")] sp1<-corSpatial(1,form=~lon+lat,type="g") scor<-Initialize(sp1, lonlat , nugget=FALSE) I got a value for sp1 (2.67). But got an error message for scor--Error in getCovariate.corSpatial(object, data = data) : Cannot have zero distances in "corSpatial" I find that puzzling since I have unique coordinates and there should not be any zero distances. Any idea? Thanks! K. __ 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] subsetting a matrix with specified no of columns
Hello! All, I am working on 1x1000 matrix say 'mat' and i want to subset this matrix in a fashion that in new matrix i get columns 2,3,9,10,16,17,23,24...so on. That is pair of columns after every interval of 7. I tried following but i got an error which is obvious. >dim(mat) [1] 1 10 >a=mat[,c(seq(c(2,3),ncol(mat),7))] Warning messages: 1: In if (n < 0L) stop("wrong sign in 'by' argument") : the condition has length > 1 and only the first element will be used 2: In if (n > .Machine$integer.max) stop("'by' argument is much too small") : the condition has length > 1 and only the first element will be used 3: In if (dd < 100 * .Machine$double.eps) return(from) : the condition has length > 1 and only the first element will be used 4: In 0L:n : numerical expression has 2 elements: only the first used Is there any other way to do it?? Please, help! regards Lee [[alternative HTML version deleted]] __ 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] sum on column using apply
I have two data frames ( x and y -- sample values below). The rows have HH:MM:SS and columns have names of devices. I am trying to find a list of 5 least used devices during recorded time period. When apply function is used to sum on the column, I get the correct answer on data frame called x, but not for y. The data type of return answer is different and I cannot figure out why. Any insight into what is happening of possibly different simpler ways to do this would be appreciated. > colnames(t(sort(apply(x,2,sum))[1:5])) [1] "5x" "6x" "7x" "4x" "103x" # the above returns the answer I am trying to get > colnames(t(sort(apply(y,2,sum))[1:5])) NULL # the above does not below is sample data and output of the apply for each > x 0x 1x 2x 3x 4x 5x 6x 7x 32x 33x 34x 35x 36x 37x 38x 39x 64x 65x 66x 67x 68x 13:55:24 21 18 18 18 17 16 16 17 29 29 25 23 19 18 18 21 24 22 22 21 20 13:55:54 16 3 3 4 4 1 1 6 40 29 16 9 6 23 19 21 27 19 29 15 19 13:56:24 3 2 6 2 1 1 4 1 33 40 28 13 10 2 4 15 25 17 8 14 11 [ truncated ] > apply(x,2,sum) 0x1x2x3x4x5x6x7x 32x 33x 34x 35x 36x 37x 12042 11411 11343 11237 10937 10811 10909 10911 18341 16055 14406 13770 12252 12003 38x 39x 64x 65x 66x 67x 68x 69x 70x 71x 96x 97x 98x 99x 12266 13450 15426 14163 13913 13615 12972 12656 13089 13329 12671 12562 12336 12045 100x 101x 102x 103x 11476 11212 11066 10997 > y nfs6 sd0 sd1 sd30 sd31 sd36 sd6 ssd100 ssd101 ssd102 ssd103 ssd104 ssd105 13:55:540 2 0000 0 0 0 0 0 0 0 13:56:540 3 0000 0 0 0 0 0 0 0 13:57:540 1 0000 0 0 0 0 0 0 0 13:58:540 1 0000 0 0 0 0 0 0 0 [ truncated ] > apply(y,2,sum) [1]0 51500000 96000 9000 00 [17]01 13 960 3100000000 110 [33]00 120000000 16000 00 [49] 3100000000 100000 00 [65]00700 84 337 642 10050 605 51800 50 [81]0 86 335 646 10140 606 5130 737 418 306 277 607 301 410 [97] 1690 445 4320 738 424 315 283 608 302 411 1688 446 431 00 [113]000 93000001 1200 > __ 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] sum on column using apply
Wanted to thank David and Jim for the str. The x and y were created using the function below. In one case, reshape1 returned list and other data frame. I put the fix by putting the as.data.frame below myPivot <- function(y,x,z,m, ...){ m1 <- m[c(x,y,z)] # select the the columns wanted m2 <- melt(m1, id=c(y,x)) pivot <- as.data.frame(reshape1(m2,list(y,x))) # time , cpu, idl # hack below as pivot[y] does not work. need to research row.names(pivot) <- pivot$time # put the time as the row names pivot <- pivot[,2:dim(pivot)[2]] # remove time from column return(as.data.frame(pivot)) } On Apr 25, 2010, at 11:07 PM, David Winsemius wrote: > > On Apr 25, 2010, at 10:15 PM, robert lee wrote: > >> I have two data frames ( x and y -- sample values below). The rows have >> HH:MM:SS and columns have names of devices. >> >> I am trying to find a list of 5 least used devices during recorded time >> period. When apply function is used to sum on the column, I get the correct >> answer on data frame called x, but not for y. The data type of return >> answer is different and I cannot figure out why. Any insight into what is >> happening of possibly different simpler ways to do this would be appreciated. >> >>> colnames(t(sort(apply(x,2,sum))[1:5])) >> [1] "5x" "6x" "7x" "4x" "103x" > > Why are you getting colnames on the transpose of x? >> >> # the above returns the answer I am trying to get >> >>> colnames(t(sort(apply(y,2,sum))[1:5])) >> NULL > > Again. Why get colnames on transpose? > >> >> # the above does not >> >> below is sample data and output of the apply for each >> >>> x >>0x 1x 2x 3x 4x 5x 6x 7x 32x 33x 34x 35x 36x 37x 38x 39x 64x 65x 66x >> 67x 68x >> 13:55:24 21 18 18 18 17 16 16 17 29 29 25 23 19 18 18 21 24 22 22 >> 21 20 >> 13:55:54 16 3 3 4 4 1 1 6 40 29 16 9 6 23 19 21 27 19 29 >> 15 19 >> 13:56:24 3 2 6 2 1 1 4 1 33 40 28 13 10 2 4 15 25 17 8 >> 14 11 >> [ truncated ] > > You have not told us how you constructed "x" and it is undoubtedly important. > We probably need at the very least the results of str(x) and str(y). This > looks like a zoo object which is not a data.frame. > > >> >>> apply(x,2,sum) >> 0x1x2x3x4x5x6x7x 32x 33x 34x 35x 36x >> 37x >> 12042 11411 11343 11237 10937 10811 10909 10911 18341 16055 14406 13770 >> 12252 12003 >> 38x 39x 64x 65x 66x 67x 68x >> 12266 13450 15426 14163 13913 13615 12972 > > So where did these extra columns come from> > >> 69x 70x 71x 96x 97x 98x 99x >> 12656 13089 13329 12671 12562 12336 12045 >> 100x 101x 102x 103x >> 11476 11212 11066 10997 >> >>> y >>nfs6 sd0 sd1 sd30 sd31 sd36 sd6 ssd100 ssd101 ssd102 ssd103 ssd104 >> ssd105 >> 13:55:540 2 0000 0 0 0 0 0 0 >> 0 >> 13:56:540 3 0000 0 0 0 0 0 0 >> 0 >> 13:57:540 1 0000 0 0 0 0 0 0 >> 0 >> 13:58:540 1 0000 0 0 0 0 0 0 >> 0 >> [ truncated ] > > This might or might not be a data.frame. Doing a transpose on a data.frame > might have the side-effect of NULLing out the resulting colnames. >> >>> apply(y,2,sum) >> [1]0 51500000 96000 9000 >> 00 >> [17]01 13 960 3100000000 >> 110 >> [33]00 120000000 16000 >> 00 >> [49] 3100000000 100000 >> 00 >> [65]00700 84 337 642 10050 605 51800 >> 50 >> [81]0 86 335 646 10140 606 5130 737 418 306 277 607 >> 301 410 >> [97] 1690 445 4320 738 424 315 283 608 302 411 1688 446 431 >> 00 >> [113]000 93000001 1200 >>> >> __ >> 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. > > David Winsemius, MD > West Hartford, CT > [[alternative HTML version deleted]] __ 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] Teach me how to transpose in R
Hi guys, I need your help!! My goal is to make a csv file from ncdf file. This is the code i've used : > hyo=open.ncdf("C:/CRUTEM3.nc") > hyo [1] "file C:/CRUTEM3.nc has 4 dimensions:" [1] "longitude Size: 72" [1] "latitude Size: 36" [1] "unspecified Size: 1" [1] "t Size: 1916" [1] "" [1] "file C:/CRUTEM3.nc has 1 variables:" [1] "float temp[longitude,latitude,unspecified,t] Longname:Temperature T Missval:2.0004008175e+20" > data2=get.var.ncdf(hyo) > write.csv(data2,file="C:/ple.csv") But the problem is, I expected this data would be 17000 * 72 (row* col) ; but, it is the other way around. 72*17000 Because the maximum col number in excel is 16383, this cvs file doesn't show all data. Obviously, I need to transpose the matrix.. I tried to use transpose function but failed. > bbb=t(data2) Error in t.default(data2) : argument is not a matrix > ccc=t(hyo) > ccc [1] "file has dimensions:" Error in if (nc$ndims > 0) for (i in 1:nc$ndims) { : argument is of length zero Teach me how to deal with this problem. Thank you very much. -Hyo [[alternative HTML version deleted]] __ 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] How to select a subset
Hi guys, I need your help. I would like to select a subset from a dataset. This is the dimension of the dataset. > dim(data1) [1] 72 36 1916 so, it's like.. there are 1916 of 72 * 36 matrix. ==> looks like 72 * ( 36*1916 ) ** *1)* And I would like to select the first 72*36 matrix. This is how I did: > two=data1[,1:36] Error in data1[, 1:36] : incorrect number of dimensions Do you have any idea how I should fix this? *2) *I thought about another way to deal with this problem. Firstly, I name the each column variable: >colnames(data1)=paste('lati',1:36) and then select: >one=subset(data1,subset=TRUE, select = lati1:lati36) but the problem is that, although I tried to select only 36 columns, above command selects the all columns. (36*1916 =68976) I think if I can name all the variables at one time, say , colnames(data1)=paste('lati',1:68976) ,then it wouldn't have been a problem. (but obviously, <---this command does not work) Do you have any idea how to deal with this?? *3)* After all, what I would really like to do is to transpose the data: The dataset I have above is 72*68976. (hard to export to csv; since max column# is 18000 something.) I have to transpose the data.. obviously. But, the problem is, after I transpose the data and export it to csv, I can't really see the data. Besides, I think tranpose thing does not seem work as I want, >bbb=t(as.matrix(data1)) >write.csv(bbb,"c:/oo.csv") Please help me, Thanks. -Hyo [[alternative HTML version deleted]] __ 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] How to deal with this :" object ' obs' not found.
Hi guys, I need your help. I'm trying to sort the data by the variable "obs". This is how I tried to sort the data below. The problem is, I have a variable name "obs"; this is.. a counter variable. something like _n_ in SAS. I do not know why it is not working. I even tried a similar example in UCLA webpage: http://www.ats.ucla.edu/stat/R/faq/sort.htm :it also does not seem to work. "*sort1.hsb2 <- hsb2[order(read) , ]"* Do you have any idea how to deal with this problem?? Thank you so much. -Hyo > colnames(ttx1) [1] "longitude 1" "longitude 2" "longitude 3" "longitude 4" "longitude 5" [6] "longitude 6" "longitude 7" "longitude 8" "longitude 9" "longitude 10" [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14" "longitude 15" [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19" "longitude 20" [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24" "longitude 25" [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29" "longitude 30" [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34" "longitude 35" [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39" "longitude 40" [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44" "longitude 45" [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49" "longitude 50" [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54" "longitude 55" [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59" "longitude 60" [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64" "longitude 65" [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69" "longitude 70" [71] "longitude 71" "longitude 72" "obs" > > sortedx1=ttx1[order(-obs),] Error in order(-obs) : object 'obs' not found [[alternative HTML version deleted]] __ 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] How to deal with this :" object ' obs' not found.
Thanks.. but not working... > sortedx1=ttx1[order(-ttx1$obs),] Error in ttx1$obs : $ operator is invalid for atomic vectors On Fri, Oct 2, 2009 at 8:47 PM, P Ehlers wrote: > Try > > sortedx1=ttx1[order(-ttx1$obs),] > > (and ask yourself where obs lives) > > -Peter Ehlers > > Hyo Lee wrote: > >> Hi guys, >> I need your help. >> I'm trying to sort the data by the variable "obs". >> This is how I tried to sort the data below. >> >> The problem is, I have a variable name "obs"; this is.. a counter >> variable. >> something like _n_ in SAS. >> I do not know why it is not working. >> I even tried a similar example in UCLA webpage: >> http://www.ats.ucla.edu/stat/R/faq/sort.htm :it also does not seem to >> work. >> "*sort1.hsb2 <- hsb2[order(read) , ]"* >> Do you have any idea how to deal with this problem?? Thank you so much. >> -Hyo >> >> >> >>> colnames(ttx1) >>> >>> >> [1] "longitude 1" "longitude 2" "longitude 3" "longitude 4" >> "longitude >> 5" >> [6] "longitude 6" "longitude 7" "longitude 8" "longitude 9" >> "longitude >> 10" >> [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14" >> "longitude >> 15" >> [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19" >> "longitude >> 20" >> [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24" >> "longitude >> 25" >> [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29" >> "longitude >> 30" >> [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34" >> "longitude >> 35" >> [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39" >> "longitude >> 40" >> [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44" >> "longitude >> 45" >> [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49" >> "longitude >> 50" >> [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54" >> "longitude >> 55" >> [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59" >> "longitude >> 60" >> [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64" >> "longitude >> 65" >> [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69" >> "longitude >> 70" >> [71] "longitude 71" "longitude 72" "obs" >> >> >>> sortedx1=ttx1[order(-obs),] >>> >>> >> Error in order(-obs) : object 'obs' not found >> >>[[alternative HTML version deleted]] >> >> __ >> 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<http://www.r-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> >> >> >> > [[alternative HTML version deleted]] __ 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] How to deal with this :" object ' obs' not found.
Ok. I just figured out what the problem was. I had to attach() the data. ** x1=data1[,,2] tx1=t(x1) *ttx1 *= cbind(tx1 , obs=1:nrow(tx1)) --> this is how ttx1 was made; and of course, in ttx1, there is a variable called 'obs'. I had to attach(ttx1) first before I use this: *sortedx1=ttx1[order(-obs),]* But it seems that, I cannot attach ttx1. *> attach(ttx1) Error in attach(ttx1) : 'attach' only works for lists, data frames and environments* Of course, this is one of the ways I can do. But I just don't think I can do it for 1916 times. > write.csv(ttx1,"c:/i.csv") > m=read.table("c:/i.csv", header=T, sep=",") > attach(m) > sortedx1=m[order(-obs),] Do you know what I should do? Thanks. -Hyo On Fri, Oct 2, 2009 at 8:50 PM, jim holtman wrote: > It is clear that 'obs' does not exist. > > On Fri, Oct 2, 2009 at 8:48 PM, Hyo Lee wrote: > > It says... > > > >> str(obs) > > Error in str(obs) : object 'obs' not found > >> ls(obs) > > Error in try(name) : object 'obs' not found > > Error in as.environment(pos) : no item called "obs" on the search list > > > > On Fri, Oct 2, 2009 at 8:26 PM, jim holtman wrote: > >> > >> Are you really sure you have 'obs'? What does 'str(obs)' show? What > >> about 'ls()'? > >> > >> On Fri, Oct 2, 2009 at 8:19 PM, Hyo Lee wrote: > >> > Hi guys, > >> > I need your help. > >> > I'm trying to sort the data by the variable "obs". > >> > This is how I tried to sort the data below. > >> > > >> > The problem is, I have a variable name "obs"; this is.. a counter > >> > variable. > >> > something like _n_ in SAS. > >> > I do not know why it is not working. > >> > I even tried a similar example in UCLA webpage: > >> > http://www.ats.ucla.edu/stat/R/faq/sort.htm :it also does not seem > to > >> > work. > >> > "*sort1.hsb2 <- hsb2[order(read) , ]"* > >> > Do you have any idea how to deal with this problem?? Thank you so > much. > >> > -Hyo > >> > > >> >> colnames(ttx1) > >> > [1] "longitude 1" "longitude 2" "longitude 3" "longitude 4" > >> > "longitude > >> > 5" > >> > [6] "longitude 6" "longitude 7" "longitude 8" "longitude 9" > >> > "longitude > >> > 10" > >> > [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14" > >> > "longitude > >> > 15" > >> > [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19" > >> > "longitude > >> > 20" > >> > [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24" > >> > "longitude > >> > 25" > >> > [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29" > >> > "longitude > >> > 30" > >> > [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34" > >> > "longitude > >> > 35" > >> > [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39" > >> > "longitude > >> > 40" > >> > [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44" > >> > "longitude > >> > 45" > >> > [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49" > >> > "longitude > >> > 50" > >> > [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54" > >> > "longitude > >> > 55" > >> > [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59" > >> > "longitude > >> > 60" > >> > [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64" > >> > "longitude > >> > 65" > >> > [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69" > >> > "longitude > >> > 70" > >> > [71] "longitude 71" "longitude 72" "obs" > >> >> > >> >> sortedx1=ttx1[order(-obs),] > >> > Error in order(-obs) : object 'obs' not found > >> > > >> >[[alternative HTML version deleted]] > >> > > >> > __ > >> > 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<http://www.r-project.org/posting-guide.html> > >> > and provide commented, minimal, self-contained, reproducible code. > >> > > >> > >> > >> > >> -- > >> Jim Holtman > >> Cincinnati, OH > >> +1 513 646 9390 > >> > >> What is the problem that you are trying to solve? > > > > > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem that you are trying to solve? > [[alternative HTML version deleted]] __ 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] Using WCSLIB in R
Hello, I'm aware that not everyone who uses R is an astronomer, and so apologies in advance to those people for the nature of this email. I need to convert right-ascension and declination (RA & DEC) coordinates for an object on the sky into physical pixel positions in a FITS image in R. There is a C library that does this, WCSLIB by Mark Calabretta (http://www.atnf.csiro.au/people/mcalabre/WCS/), however I am unsure how to use it in R. I do not program in C, which adds to the problem. I have created the libwcs.so file and moved it to /usr/local/lib already, and am able to load the library in R using: > dyn.load("/usr/local/lib/libwcs.so") and then check that the function I need is available using: > is.loaded("wcss2p") [1] TRUE My problem now is how to actually use it, as the author of the library does not use R. I was wondering if anyone in the community has used this library before, and if so how? Thankyou in advance, Lee Kelvin -- School of Physics & Astronomy University of St Andrews North Haugh St Andrews KY16 9SS United Kingdom Phone (+44) [0]1334461668 Email l...@st-andrews.ac.uk __ 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] column names of a correlation matrix
Hi! All, I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish to obtain pairs with highest correlation values. So, I did this > b=matrix(data=NA,nrow=4217,ncol=1) > rownames(b)=rownames(cor_expN) > for(i in 1:4217){b[i,]=max(cor_expN[i,])} > head(b) [,1] aaeA_b3241_14 0.7181912 aaeB_b3240_15 0.7513084 aaeR_b3243_15 0.7681684 aaeX_b3242_12 0.5230587 aas_b2836_14 0.6615927 aat_b0885_140.6344144 Now I want the corresponding columns for the above values. For that I tried this > c=matrix(data=NA,nrow=4217,ncol=1) > for(i in 1:4217){b[i,]=colnames(max(cor_expN[i,]))} And got the following error: Error in b[i, ] = colnames(max(cor_expN[i, ])) : number of items to replace is not a multiple of replacement length Any thoughts? Lee [[alternative HTML version deleted]] __ 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] column names of a correlation matrix
Thanks! guys for the help. cheers! Lee On Wed, Oct 28, 2009 at 7:03 PM, Tony Plate wrote: > Here's a simple example that might help you get what you want: > > set.seed(1) >> x <- matrix(rnorm(30), ncol=3, dimnames=list(NULL, letters[1:3])) >> (xc <- cor(x)) >> > a b c > a 1.000 -0.3767034 -0.7158385 > b -0.3767034 1.000 0.6040273 > c -0.7158385 0.6040273 1.000 > >> (cd <- data.frame(elt=outer(colnames(xc), colnames(xc), paste, >> sep=":")[upper.tri(xc)], row=row(xc)[upper.tri(xc)], >> col=col(xc)[upper.tri(xc)], cor=xc[upper.tri(xc)])) >> > elt row colcor > 1 a:b 1 2 -0.3767034 > 2 a:c 1 3 -0.7158385 > 3 b:c 2 3 0.6040273 > >> cd[order(-cd$cor),] >> > elt row colcor > 3 b:c 2 3 0.6040273 > 1 a:b 1 2 -0.3767034 > 2 a:c 1 3 -0.7158385 > >> >> > If you need something more efficient, try using which(..., arr.ind) to pick > out matrix style indices, e.g.: > >> (ii <- which(xc > -0.4 & upper.tri(xc), arr.ind=T)) >> > row col > a 1 2 > b 2 3 > >> cbind(ii, cor=xc[ii]) >> > row colcor > a 1 2 -0.3767034 > b 2 3 0.6040273 > >> >> > -- Tony Plate > > Lee William wrote: > >> Hi! All, >> I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish >> to obtain pairs with highest correlation values. So, I did this >> >>> b=matrix(data=NA,nrow=4217,ncol=1) >>> rownames(b)=rownames(cor_expN) >>> for(i in 1:4217){b[i,]=max(cor_expN[i,])} >>> head(b) >>> >> [,1] >> aaeA_b3241_14 0.7181912 >> aaeB_b3240_15 0.7513084 >> aaeR_b3243_15 0.7681684 >> aaeX_b3242_12 0.5230587 >> aas_b2836_14 0.6615927 >> aat_b0885_140.6344144 >> >> Now I want the corresponding columns for the above values. For that I >> tried >> this >> >>> c=matrix(data=NA,nrow=4217,ncol=1) >>> for(i in 1:4217){b[i,]=colnames(max(cor_expN[i,]))} >>> >> >> And got the following error: >> Error in b[i, ] = colnames(max(cor_expN[i, ])) : number of items to >> replace >> is not a multiple of replacement length >> Any thoughts? >> >> Lee >> >>[[alternative HTML version deleted]] >> >> >> __ >> 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. >> >> > [[alternative HTML version deleted]] __ 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] extracting values from correlation matrix
Hi! All, I have 2 correlation matrices of 4000x4000 both with same row names and column names say cor1 and cor2. I have extracted some information from 1st matrix cor1 which is something like this: rowname colname cor1_value a b0.8 b a0.8 c f 0.62 d k0.59 - - -- - - -- Now I wish to extract values from matrix cor2 for the same rowname and colname as above so that it looks similar to something like this with values in cor2_value: rowname colname cor1_value cor2_value a b0.8 --- b a0.8 --- c f 0.62 --- d k0.59 --- - - -- --- - - -- --- I am running out of ideas. So I decided to post this on mailing list. Please Help! Best Lee [[alternative HTML version deleted]] __ 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] selective subsetting of a correlation matrix
Dear All, I have a correlation matrix say 'M' (4000x4000) for 4000 genes and I want to subset it to 'N' (190x190) for 190 genes. The list of those 190 genes are in variable 't'. So the idea is to read the names of genes from variable 't' and subset the matrix M accordingly. Any thoughts are welcome! Best Lee [[alternative HTML version deleted]] __ 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] Export R output to Word/RTF?
Hi R Experts, I'm aware of pdf(), jpeg(),... functions. But, 1. Is it also possible to export graphs directly to word or RTF? I use to copy and paste graphs but resolutions are not so great. 2. Also, is it possible to export your out to word file? I use sink() function to export it text files. Any suggestions, thanks, Wenjie Lee [[alternative HTML version deleted]] __ 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] Export R output to Word/RTF?
Please read this: On Fri, Dec 11, 2009 at 6:28 PM, Wenjie Lee wrote: > Hi R Experts, > > I'm aware of pdf(), jpeg(),... functions. But, > > 1. Is it also possible to export graphs directly to word or RTF? I use to > copy and paste graphs but resolutions are not so great. > > 2. Also, is it possible to export your statistical (regression, etc...) > output to word file? I use sink() function to export it text files. > > Any suggestions, thanks, > > Wenjie Lee > [[alternative HTML version deleted]] __ 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] Export R output to Word/RTF?
Thanks, can anyone explain a little more on what "beta" version means? Thanks! On Sat, Dec 12, 2009 at 10:59 AM, Frank Bloos wrote: > I am using SWord from statconn: http://rcom.univie.ac.at/download.html > It allows you to put r-commands into Word (similar to odfWeave). Output is > directed to Word including figures and tables. It is still a beta-version > but works fine. > > Frank Bloos > > >>> Wenjie Lee 12.12.2009 00:28 >>> > > Hi R Experts, > > I'm aware of pdf(), jpeg(),... functions. But, > > 1. Is it also possible to export graphs directly to word or RTF? I use to > copy and paste graphs but resolutions are not so great. > > 2. Also, is it possible to export your out to word file? I use sink() > function to export it text files. > > Any suggestions, thanks, > > Wenjie Lee > > [[alternative HTML version deleted]] > > > > > > Universitätsklinikum Jena > Körperschaft des öffentlichen Rechts und Teilkörperschaft der > Friedrich-Schiller-Universität Jena > Bachstraße 18, 07743 Jena > Verwaltungsratsvorsitzender: Prof. Dr. Walter Bauer-Wabnegg; Medizinischer > Vorstand: Prof. Dr. Klaus Höffken; > Wissenschaftlicher Vorstand: Prof. Dr. Klaus Benndorf; Kaufmännischer > Vorstand und Sprecher des Klinikumsvorstandes Rudolf Kruse > Bankverbindung: Sparkasse Jena; BLZ: 830 530 30; Kto.: 221; Gerichtsstand > Jena > Steuernummer: 161/144/02978; USt.-IdNr. : DE 150545777 > [[alternative HTML version deleted]] __ 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] Export R output to Word/RTF?
Oh okay :), thanks a lot! On Sun, Dec 13, 2009 at 5:53 PM, Remko Duursma wrote: > http://en.wikipedia.org/wiki/Software_release_life_cycle#Beta > > > > r > > > - > Remko Duursma > Post-Doctoral Fellow > > Centre for Plants and the Environment > University of Western Sydney > Hawkesbury Campus > Richmond NSW 2753 > > Dept of Biological Science > Macquarie University > North Ryde NSW 2109 > Australia > > Mobile: +61 (0)422 096908 > www.remkoduursma.com > > > > On Mon, Dec 14, 2009 at 9:50 AM, Wenjie Lee > wrote: > > Thanks, can anyone explain a little more on what "beta" version means? > > Thanks! > > > > > > On Sat, Dec 12, 2009 at 10:59 AM, Frank Bloos > > wrote: > > > >> I am using SWord from statconn: http://rcom.univie.ac.at/download.html > >> It allows you to put r-commands into Word (similar to odfWeave). Output > is > >> directed to Word including figures and tables. It is still a > beta-version > >> but works fine. > >> > >> Frank Bloos > >> > >> >>> Wenjie Lee 12.12.2009 00:28 >>> > >> > >> Hi R Experts, > >> > >> I'm aware of pdf(), jpeg(),... functions. But, > >> > >> 1. Is it also possible to export graphs directly to word or RTF? I use > to > >> copy and paste graphs but resolutions are not so great. > >> > >> 2. Also, is it possible to export your out to word file? I use sink() > >> function to export it text files. > >> > >> Any suggestions, thanks, > >> > >> Wenjie Lee > >> > >> [[alternative HTML version deleted]] > >> > >> > >> > >> > >> > >> Universitätsklinikum Jena > >> Körperschaft des öffentlichen Rechts und Teilkörperschaft der > >> Friedrich-Schiller-Universität Jena > >> Bachstraße 18, 07743 Jena > >> Verwaltungsratsvorsitzender: Prof. Dr. Walter Bauer-Wabnegg; > Medizinischer > >> Vorstand: Prof. Dr. Klaus Höffken; > >> Wissenschaftlicher Vorstand: Prof. Dr. Klaus Benndorf; Kaufmännischer > >> Vorstand und Sprecher des Klinikumsvorstandes Rudolf Kruse > >> Bankverbindung: Sparkasse Jena; BLZ: 830 530 30; Kto.: 221; > Gerichtsstand > >> Jena > >> Steuernummer: 161/144/02978; USt.-IdNr. : DE 150545777 > >> > > > >[[alternative HTML version deleted]] > > > > > > __ > > 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<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > > > [[alternative HTML version deleted]] __ 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] Inserting .png plots in MS Word.
Hi R Users, I'm using following sample code to save png plots. png(file="sample.png", width=8, height=6) Then I copy or use "insert pictures" function to get the image into MS Word. After copying, if I try to stretch or re-size the image it starts getting distorted. Is there a way to standardized graph pixels so that the sharpness of the graph is maintained (at least for minor stretching/re-sizing). Is it possible to achieve this? I know I can change width and height, but I have to submit this .doc file to my adviser and he may need to re-size it. Any suggestion would be highly appreciated, Thanks, Wenjie [[alternative HTML version deleted]] __ 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] Inserting .png plots in MS Word.
Thanks David and Duncan, pdf()/eps() are good options. Can you please tell which function produces .wmf images. I finally want to copy/insert these images into word file (.doc) and submit it to my adviser, and keep a possibility to re-size pictures. Is it possible to add these .pdf / .eps images into word (instead of latex). Thanks, Wenjie On Sat, Dec 19, 2009 at 1:49 PM, Duncan Murdoch wrote: > On 19/12/2009 1:28 PM, Wenjie Lee wrote: > >> Hi R Users, >> >> I'm using following sample code to save png plots. >> >> png(file="sample.png", width=8, height=6) >> >> Then I copy or use "insert pictures" function to get the image into MS >> Word. >> After copying, if I try to stretch or re-size the image it starts getting >> distorted. Is there a way to standardized graph pixels so that the >> sharpness of the graph is maintained (at least for minor >> stretching/re-sizing). Is it possible to achieve this? >> >> I know I can change width and height, but I have to submit this .doc file >> to >> my adviser and he may need to re-size it. >> >> Any suggestion would be highly appreciated, >> >> > If you want to resize the graphic, you shouldn't use a bitmap format. Use > .pdf, .eps, .wmf, etc. It's still best to generate the graph at the final > size (to get fonts and line widths right), but you'll get better results > than with resizing a bitmap. > > I don't know which vector formats your advisor's version of MS Word > supports, but presumably their docs will tell you. > > Duncan Murdoch > [[alternative HTML version deleted]] __ 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] Inserting .png plots in MS Word.
Thanks all for your reply, Wenjie On Sat, Dec 19, 2009 at 4:20 PM, Gabor Grothendieck wrote: > You can: > > 1. Right click the graphic and choose copy metafile or save metafile. > 2. Use savePlot after producing your plot. See ?savePlot > 3. Use win.metafile(...); plot(...); dev.off() > > > On Sat, Dec 19, 2009 at 1:28 PM, Wenjie Lee > wrote: > > Hi R Users, > > > > I'm using following sample code to save png plots. > > > > png(file="sample.png", width=8, height=6) > > > > Then I copy or use "insert pictures" function to get the image into MS > Word. > > After copying, if I try to stretch or re-size the image it starts getting > > distorted. Is there a way to standardized graph pixels so that the > > sharpness of the graph is maintained (at least for minor > > stretching/re-sizing). Is it possible to achieve this? > > > > I know I can change width and height, but I have to submit this .doc file > to > > my adviser and he may need to re-size it. > > > > Any suggestion would be highly appreciated, > > > > Thanks, > > Wenjie > > > >[[alternative HTML version deleted]] > > > > __ > > 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<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] __ 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] maximum over one dimension of a 3-dimensional array
Hi, I'm running R 2.7.2 on windows XP. I'd like to find the maximum of a 3-d array over it's third index to create a 2-d array. For example: > x <- array(c(1,2,3,10,11,12,3:8),c(2,3,2)) > x , , 1 [,1] [,2] [,3] [1,]13 11 [2,]2 10 12 , , 2 [,1] [,2] [,3] [1,]357 [2,]468 > x1 <- x[,,1] > x2 <- x[,,2] > pmax(x1,x2) [,1] [,2] [,3] [1,]35 11 [2,]4 10 12 Is there a pre-defined function that I can use to do this without using a for-loop? Also, the third index can be long and of variable length, so I don't want to explicitly write out x1, x2,... Thanks in advance for your help. eric __ 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] save history only option under Linux
Hi, I have a question regarding the R command options under Linux Is there any options that I can save history only? The only save option is --save, which saves both data and history. I don't want to save temporary data, because sometimes the it takes much time if the temp data is too big. However I want to restore the history for my next R session.. If there is no such option that meets my needs. Is there any other way to work out, such as configuration in the profile file, etc. ? Thanks a lot. alex -- View this message in context: http://www.nabble.com/save-history-only-option-under-Linux-tp23257673p23257673.html Sent from the R help mailing list archive at Nabble.com. __ 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] save history only option under Linux
I put savehistory() in my profile file, and it works nicely. Thank you very much, jdeisenberg. alex jdeisenberg wrote: > > > alex lee wrote: >> >> Is there any options that I can save history only? >> The only save option is --save, which saves both data and history. >> However I want to restore the history for my next R session.. >> >> If there is no such option that meets my needs. Is there any other way to >> work out, such as configuration in the profile file, etc. ? >> > > You could start R with the --no-save option, and then do a savehistory() > call as the last command before you quit. > -- View this message in context: http://www.nabble.com/save-history-only-option-under-Linux-tp23257673p23276960.html Sent from the R help mailing list archive at Nabble.com. __ 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] bootstrapping a matrix and calculating Pearson's correlation coefficient
Hi All, I have got matrix 'data' of dimension 22000x600. I want to make 50 independent samples of dimension 22000x300 from the original matrix 'data'. And then want to calculate pearsons CC for each of the obtained 50 matrices. It seems it is possible to do this using 'boot' function from library boot but I am not able to figure out how? I am really stuck. Please help! Best Lee [[alternative HTML version deleted]] __ 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] How to define degree=1 in mgcv
Hi, all I have a question on mgcv and ns. Now I want to compare the results from glm, gam and ns. Take a simple model y~x for example. glm1 = glm(y~x, data=data1) gam1 = gam(y~s(x), data=data1) ns1 = glm(y~ns(x),data=data1) In order to confirm the result from glm1 is consistent to those from gam1 and ns1, I want to define degree=1 in mgcv and ns. I am wondering if there is somebody can give me some suggestions? I appreciate. Hellen [[alternative HTML version deleted]] __ 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] How to define degree=1 in mgcv
Hi, all I have a question on mgcv and ns. Now I want to compare the results from glm, gam and ns. Take a simple model y~x for example. glm1 = glm(y~x, data=data1) gam1 = gam(y~s(x), data=data1) ns1 = glm(y~ns(x),data=data1) In order to confirm the result from glm1 is consistent to those from gam1 and ns1, I want to define degree=1 in mgcv and ns. I am wondering if there is somebody can give me some suggestions? I appreciate. Hellen [[alternative HTML version deleted]] __ 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] two sample chi-squared test
Hello, Can you tell me what R function to use to do a two-sample chi-squared test? I want to see if two distributions are significantly different from each other, and I don't specify the theoretical distribution of either. For example, I have the following fake count data: x <- sample(1:10,50,replace=TRUE) y <- sample(1:10,100,replace=TRUE) I saw chisq.test in the stats package, but that looks like a one-sample test. I'm running version 2.7.2 on windows xp. Thanks. eric __ 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 for Use of R software
Dear Sir/Madam, May I seek for your kind help for the use of R software for conducting two-proportional z-test which is test for non-inferiority? I have found one saying using function (TwoSampleProportion.NIS(alpha, beta, p1, p2, k, delta, margin) but the software said there is not such function. Thank you very much for your kind help. With kindest regards, Simon [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 for Use of R software
Dear Sir/Madam, May I seek for your kind help for the use of R software for conducting two-proportional z-test which is test for non-inferiority? What function will the R software provide for doing such test with 95%CI and P-value calculated. Thank you very much! With kindest regards, Simon [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] paran package - error message
I am trying to using the "paran" package in R for Horn's parallel analysis. According to the "paran" manual, the highlighted yellow ought to be a numerical matrix or data frame. It looks like this should be the file name. Is there something that I need to do install.packages("paran") library(paran) IS<- read.table ("C:/Users/Deborah Lee/Documents/R/IS.csv") paran(IS, cfa=TRUE, graph=TRUE, color=TRUE, col=c("black", "red", "blue")) When I run the code above, I get the error message below. in cor(x) : 'x' must be numeric How do I set up my data (csv) file itself to make this a numerical matrix? (FYI: row 1 for headers for variables names). Thank you for your help. Deborah D. Lee, PhD Associate Director of Student Affairs Research and Assessment The Pennsylvania State University 105 White Building University Park, PA 16802 (814) 863-9609 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] paran package - error message
Thank you very much. I appreciate your help! Deborah D. Lee, PhD Associate Director of Student Affairs Research and Assessment The Pennsylvania State University 105 White Building University Park, PA 16802 (814) 863-9609 -Original Message- From: PIKAL Petr Sent: Wednesday, August 26, 2020 4:01 AM To: Lee, Deborah ; r-help@r-project.org Subject: RE: paran package - error message Hi IS is data frame so it is not numeric. try str(IS) to see structure of your data. maybe just mat.IS <- as.matrix(IS) gives you desired result, but it depends on (undisclosed) IS structure BTW, do not use html formatting, it is useless in this list BTW2, you should spend at least few minutes to read basic docs, kindly offered by R-core in doc directory, especially R-intro which gives you quick info about objects and their properties. BTW3, your read.table is lacking header and sep and maybe dec specification so I doubt it reads your data properly. Cheers Petr > -Original Message- > From: R-help On Behalf Of Lee, Deborah > Sent: Monday, August 24, 2020 12:52 PM > To: r-help@r-project.org > Subject: [R] paran package - error message > > I am trying to using the "paran" package in R for Horn's parallel analysis. > According to the "paran" manual, the highlighted yellow ought to be a > numerical matrix or data frame. It looks like this should be the file name. Is > there something that I need to do > > install.packages("paran") > library(paran) > > IS<- read.table ("C:/Users/Deborah Lee/Documents/R/IS.csv") paran(IS, > cfa=TRUE, graph=TRUE, color=TRUE, col=c("black", "red", "blue")) > > When I run the code above, I get the error message below. > in cor(x) : 'x' must be numeric > > How do I set up my data (csv) file itself to make this a numerical matrix? (FYI: > row 1 for headers for variables names). > > Thank you for your help. > > > Deborah D. Lee, PhD > Associate Director of Student Affairs Research and Assessment The > Pennsylvania State University > > 105 White Building > University Park, PA 16802 > (814) 863-9609 > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] ERROR: missing value where TRUE/FALSE needed
Hello, I have a problem... I tried using a function and I get the error: "ERROR: missing value where TRUE/FALSE needed" Here is my code: a<-mctp(Ecoli~Fecha, data=Datos, type = "Tukey", alternative = "two.sided", asy.method = "mult.t", plot.simci = TRUE)summary(a) Ecoli, Fecha and Datos are well defined. I don't know what is the problem... THANKS [[alternative HTML version deleted]] __ 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] could I remove or move points in locator() based on plot()?
Hi, The function locator() allows me to add points by mouse on function plot() I have draft. But the points can not be edit once I have made the click. How can I remove or just move the points I made on the draft? I use the locator function like this: > plot(1,1) > locator(type="o") Thanks. [[alternative HTML version deleted]] __ 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] could I remove or move points in locator() based on plot()?
Maybe I have to white a function for the purpose base on loacator. Thanks for the reply. 2013/8/3 David Carlson > You cannot move or edit them interactively, but you can save > the locations of those points by using: > > > a <- locator(type="o") > > # e.g. click on three locations > > > a > $x > [1] 0.8559376 1.1778126 1.2340626 > > $y > [1] 1.2256976 1.2501162 0.8402324 > > You could now delete or modify the points and then use lines() > or points() to add them to a new graph. > > > plot(1, 1) > > lines(a, type="o") > > points(a, pch=16, col="red") > > - > David L Carlson > Associate Professor of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Daniel > Guetta > Sent: Friday, August 2, 2013 12:23 PM > To: David Winsemius > Cc: R-help@r-project.org > Subject: Re: [R] could I remove or move points in locator() > based on plot()? > > Depending on the complexity of your graphic, you could also > just re-draw > the entire thing every time you want to make a change. > > Daniel > > > On Fri, Aug 2, 2013 at 10:17 AM, David Winsemius > wrote: > > > > > On Aug 2, 2013, at 2:26 AM, Klot Lee wrote: > > > > > Hi, > > > The function locator() allows me to add points by mouse on > function > > plot() > > > I have draft. But the points can not be edit once I have > made the click. > > > How can I remove or just move the points I made on the > draft? > > > > You cannot. The plotting model for base graphics is > indelible ink. The > > best you could do would be to plot white on top of black. > > > > -- > > David. > > > > > > I use the locator function like this: > > > > > >> plot(1,1) > > >> locator(type="o") > > > > > > > > > Thanks. > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > 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. > > > > David Winsemius > > Alameda, CA, USA > > > > __ > > 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. > > > > [[alternative HTML version deleted]] > > __ > 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. > -- Stand Alone Complex [[alternative HTML version deleted]] __ 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] could I remove or move points in locator() based on plot()?
Thanks. I have tried put.points.demo, it helps, maybe some more modify then it would be suitable for me. Thank you again. 2013/8/3 Greg Snow <538...@gmail.com> > The function "put.points.demo" in the TeachingDemos package allows you to > add points, delete points, and move points on a scatterplot (and also > computes some summaries based on the points). > > It actually uses "locator" behind the scenes and redraws the plot each > time, but it gives the effect. If that does not do what you want, you may > be able to modify the function (pure R code) to do what you need. > > > On Fri, Aug 2, 2013 at 3:26 AM, Klot Lee wrote: > >> Hi, >> The function locator() allows me to add points by mouse on function plot() >> I have draft. But the points can not be edit once I have made the click. >> How can I remove or just move the points I made on the draft? >> >> I use the locator function like this: >> >> > plot(1,1) >> > locator(type="o") >> >> >> Thanks. >> >> [[alternative HTML version deleted]] >> >> __ >> 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. >> > > > > -- > Gregory (Greg) L. Snow Ph.D. > 538...@gmail.com > -- Stand Alone Complex [[alternative HTML version deleted]] __ 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] how to deal with continous and Non continuous mixed variables in factor analysis?
hi, when I am doing factor analysis, there is continous and Non continuous variables(classified variables). Does "psych" package handle this? Is there any difference between continous variables and non ones or mixed ones when doing factor analysis? If there is, which packages should I use then? My data look like this: a01 a02 a03 a04 a05 14.7 11.9 0.990 4 20.1 5.5 0.98 1 3 11.6 1.9 0.980 7 54.3 5.7 0.360 5 .. variable a01, a02, a03 is continuous and a04, a05 is Non continuous. when I do factor analysis by psych package, the results is not good enough, so is there some method handle data like this? Thanks. klot [[alternative HTML version deleted]] __ 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] weights error in svyglm
Hi! I am just learning the 'svyglm' package and have run into an error for which I have not found a solution. My data have been collected from a stratified random survey. Here is the code: NB3<-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data) dstrat <- svydesign(id=~1, strata=~STRATA, weights = ~weight, data=data) SNB3 <- svyglm(NB3, design=dstrat) The error that is returned is: Error in model.frame.glm(formula = list(coefficients = c(-6.96858807641624, : object '.survey.prob.weights' not found I would appreciate any assistance in solving this problem. Thanks, Laura [[alternative HTML version deleted]] __ 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] weights error in svyglm
Thanks! That worked. However, what error distribution is assumed? I was hoping to use a negative binomial. -Original Message- From: Milan Bouchet-Valat [mailto:nalimi...@club.fr] Sent: Friday, April 11, 2014 11:37 AM To: Lee, Laura Cc: r-help@r-project.org Subject: Re: [R] weights error in svyglm Le vendredi 11 avril 2014 à 13:38 +, Lee, Laura a écrit : > Hi! > > I am just learning the 'svyglm' package and have run into an error for > which I have not found a solution. My data have been collected from a > stratified random survey. Here is the code: > > NB3<-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data) > > dstrat <- svydesign(id=~1, strata=~STRATA, weights = ~weight, > data=data) > > SNB3 <- svyglm(NB3, design=dstrat) > > The error that is returned is: > > Error in model.frame.glm(formula = list(coefficients = > c(-6.96858807641624, : > object '.survey.prob.weights' not found > > I would appreciate any assistance in solving this problem. The error is somewhat strange, but you should not pass the result of glm.nb() to svyglm (where have you found this idea?). Just do SNB3 <- svyglm(COLNUM ~ Year + Depth + MESH + offset(LogEffort), design=dstrat) Regards __ 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] could I smooth the geom_line output on ggplot2?
hi, I have got some data and draw a line graph with ggplot2 geom_line. The output seems too sharp to me, is there any way to smooth it? I mean smooth the line, NOT ADDING a smooth line. Or there is other functions in ggplot2 can help me out with a smooth line? Thank you. -- Stand Alone Complex [[alternative HTML version deleted]] __ 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] How could I graph a special coordinate
hi, I'v got some data attached as apx.csv. It shows the relationship about a kind of enzyme and the temperature. "yhf" and "xbt" are 2 kind of cowpea. "apx" is the kind of enzyme and "low" means the lowest temperature intraday. "date" means 1 to 121 days. What I want to show with it is how is "apx" changes with "low" on 2 kind of cowpeas. And "date" is better not missing in graph. I have made one by ggplot2 using apx2.csv (reshaped by melt). apx<- read.csv("apx2.csv") p<- ggplot(apx, aes(x= dat, y=apx, colour= factor(var))) p + geom_line()+facet_wrap(~var,ncol=1, scales= "free_y") The graph is NOT good enough. It is not easy to find the relationship between "apx" and "low". How could I do better? Is it possible to show "low" data as graph background color changing with "date"? Thank you. -- Stand Alone Complex __ 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 Read File With Odd Characters
I have a large (105MB) data file, tab-delimited with a header. There are some odd characters at the beginning of the file that are preventing it from being read by R. > dfTemp = read.delim(filename) Error in make.names(col.names, unique = TRUE) : invalid multibyte string at 'm' When I view the file with head, I see: ��muni_code parcel_id… The file is too large to edit in a graphical text editor (gedit). I tried just dropping the header row with sed '1 d' new.txt" but then > dfTemp = read.delim(filename) Error in read.table(file = file, header = header, sep = sep, quote = quote, : empty beginning of file I tried some other shenanigans with sed (with which I am not really experienced) but did not get a usable file. Does anyone have any ideas for how to (a) directly read this into R, skipping the offending line or characters, or (b) preprocess it so that I can read it into R? Best, --Lee R version 2.14.1 (2011-12-22) Platform: x86_64-pc-linux-gnu (64-bit) Linux Mint 13 -- Lee Hachadoorian Assistant Professor in Geography, Dartmouth College http://freecity.commons.gc.cuny.edu __ 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] Help Read File With Odd Characters
On 11/08/2012 02:51 AM, Prof Brian Ripley wrote: On 08/11/2012 07:11, Lee Hachadoorian wrote: I have a large (105MB) data file, tab-delimited with a header. There are some odd characters at the beginning of the file that are preventing it from being read by R. That is a BOM make in UCS-2 encoding. Was this file created on Windows? It so try using iconv to convert it to UTF-8, or in R use read.delim(filename, fileEncoding = "UCS-2LE") Perfect. I tried it both ways, and both iconv and the fileEncoding parameter did the trick. As far as I know the file (which was provided by a public agency) was created in Windows. Thanks, --Lee -- Lee Hachadoorian Assistant Professor in Geography, Dartmouth College http://freecity.commons.gc.cuny.edu __ 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] Standard errors for predictions of zero-inflated models
Dear all, I am using the zeroinfl() function from the pscl package to develop a zero-inflated Poisson GLM. I would like to calculate the standard errors of predicted values. I've tried code posted in a previous discussion on this topic (https://stat.ethz.ch/pipermail/r-help/2008-December/182806.html), and I don't understand the results. Before I apply this code, I get the predicted value for the data 'newdat' using the following: -> predict(bestfit,type="response",newdata=newdat) 109 198.5146 The predicted value is approximately 199. When I apply the previously mentioned code (predict.zeroinfl), I can now calculate the standard error: -> predict(bestfit,type="response",se=TRUE,newdata=newdat) MC iterate 1 of 1000 MC iterate 2 of 1000 ... MC iterate 1000 of 1000 [[1]] 109 0.00016793 [[2]] [[2]]$lower [1] 9.151924e-05 [[2]]$upper [1] 0.0002945504 [[2]]$se [1] 5.296472e-05 However, the predicted value is now 1.7x10^-4. The standard error value makes sense for this predicted value, but I'm not sure why the predicted value has changed. I would appreciate any assistance. Cheers, Laura [[alternative HTML version deleted]] __ 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] CPOS from cwhmisc package not found
Hi: I wonder if anyone can help me about cpos function not found error: : path.package("cwhmisc", quiet = FALSE) [1] "C:/Users/slee/Documents/R/win-library/2.15/cwhmisc" So I have package cwhmisc where there is cpos function. But I got error: cpos("ab","b",1) Error: could not find function "cpos" Then I tried to install on R prompt but got this error message: install.packages("cwhmisc",lib="C:/Program Files/R/R-2.15.2/library/") Warning message: package 'cwhmisc' is not available (for R version 2.15.2) So I don't understand why the package is not available for the version of R I am running. Anyone has any idea? --- Shirley Lee [[alternative HTML version deleted]] __ 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] My problem with R
Hi, I am a student in trouble with R. please help me! I have a 16 huge data(.csv). data1<-read.csv(D://data1.csv, header=FALSE) . . . data16<-read.csv(D://data16.csv, header=FALSE) and then, I tried to seperated data w/ column. a1<-cbind(data1[1:36568,1]) b1<-cbind(data1[1:36568,2]) . . . ac16<-cbind(data16[1:85207,31]) a column is a Date(-mm-dd) b column is a Time(hh:mm:ss) c to ac is a numeric data. finished this work, use "rbind" function. date<-rbind(a1,a2,a3,a4,.,a16) time<-rbind(b1,b2,b3,..,b16) . . . . ac<-rbind(ac1,ac2,ac3,...,ac16) I want to see -mm-dd format, but It does not work. >b [,1] [1,] 17753 [2,] 17754 [3,] 17755 [4,] 17756 [5,] 17757 [6,] 17758 >a [,1] [1,]1 [2,]1 [3,]1 [4,]1 [5,]1 [6,]1 I don't know why... Question 1. I want to paste a and b >> -mm-dd hh:mm:ss Question 2. I want to averaging mean, median for every each minute groups. for example) Time c de f . . . 2014-01-20 00:00:00 3.1428 1.99 0.123455 7.5526 2014-01-20 00:00:01 3.1887 1.03 0.176545 7.5234 2014-01-20 00:00:02 2.1876 1.27 0.987455 7.5996 ... 2014-01-20 00:01:00 5.4428 1.96 0.164455 7.8666 2014-01-20 00:01:01 1.5658 1.39 0.176545 7.7786 2014-01-20 00:01:02 3.1776 1.67 0.254655 7.4567 then, Time average_C c de f . . . 2014-01-20 00:00:00 here 3.1428 1.99 0.123455 7.5526 2014-01-20 00:00:01 3.1887 1.03 0.176545 7.5234 2014-01-20 00:00:02 2.1876 1.27 0.987455 7.5996 ... 2014-01-20 00:01:00 here 5.4428 1.96 0.164455 7.8666 2014-01-20 00:01:01 1.5658 1.39 0.176545 7.7786 2014-01-20 00:01:02 3.1776 1.67 0.254655 7.4567 PLEASE HELP ME, R-help!!! [[alternative HTML version deleted]] __ 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] Using apply function
Hi all R-users, I'm trying to using apply function to input a range of values into a function I wrote. I wrote a function with 4 information needed. I would like to make 2 of them fixed and the other 2 random (but with specified values). I would like to replicate the function 1 times. I was thinking about using loop function but which is really slow, therefore I transfer to apply function. But I got stucked. Could anyone help me? The question could be illustrated as follows, Target function: fun(F1,F2,R1,R2) R1 has values 1, 2, 3, 4, 5 R2 has values -1, -2, -3, -4, -5 F1=10 F2=100 There would be 25 conditions. I would like to avoid using loop to get the result. Could anyone give me some precious suggestion? Thank you Best, Yen __ 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] Problem about zero
Hello, everyone, There's a problem about zero in R and I really need your help. I have a vector shown as x=c(0.1819711,0.4811463,0.1935151,0.1433675), The sum of this vector is shown as 1 in R, but when I type 1-sum(x), the value is not zero, but -2.220446e-16. I can accept that this value is quite small and could be seen as zero, but there would be a problem when it's not really zero but a negative value in my algorithm. Therefore I would like to know that how could it be avoid. One way I think is to define the value 1-sum(x) as zero when it is smaller than a particular value, but the particular value is not be set yet. I would like to know more about the definition of the shown zero in R. Thank you so much. Yen [[alternative HTML version deleted]] __ 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] Problem about zero
Hello, everyone, Thank you for all your kindness. I've solved the problem through your help with the function all.equal. Thank you very much! Yen -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Wednesday, June 16, 2010 6:40 AM To: Yen Lee Cc: r-help@r-project.org Subject: Re: [R] Problem about zero On Tue, Jun 15, 2010 at 6:00 PM, Yen Lee wrote: > Hello, everyone, > > There's a problem about zero in R and I really need your help. > > > > I have a vector shown as x=c(0.1819711,0.4811463,0.1935151,0.1433675), > > The sum of this vector is shown as 1 in R, but when I type 1-sum(x), the > value is not zero, but -2.220446e-16. > > I can accept that this value is quite small and could be seen as zero, but > there would be a problem when it's not really zero but a negative value in > my algorithm. > > > > Therefore I would like to know that how could it be avoid. > > One way I think is to define the value 1-sum(x) as zero when it is smaller > than a particular value, but the particular value is not be set yet. > > I would like to know more about the definition of the shown zero in R. > As others have pointed out please read the R FAQ. Actually on my machine: Windows Vista running C2D BLAS, "R version 2.11.1 Patched (2010-05-31 r52167)" I do get zero: > x <- c(0.1819711,0.4811463,0.1935151,0.1433675) > 1-sum(x) [1] 0 Also check out sum.exact in the caTools package. __ 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] calculation on series with different time-steps
Hello, I have two series, one with stream stage measurements every 5 minutes, and the other with barometric pressure measurements every hour. I want to subtract each barometric pressure measurement from the 12 stage measurements closest in time to it (6 stage measurements on either side of the hour). I want to do something like the following, but I don't know the syntax. "If the Julian day of the stage measurement is equal to the Julian day of the pressure measurement, AND the absolute value of the difference between the time of the stage measurement and the hour of the pressure measurement is less than or equal to 30 minutes, then subtract the pressure measurement from the stage measurement (and put it in a new column in the stage data frame)." if ( stage$julian_day = baro$julian_day & |stage$time - baro$hour| <= 30 ) then (stage$stage.cm - baro$pressure) Can you help me? Thanks, JL [[alternative HTML version deleted]] __ 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] command to start R and Rcmdr?
Liviu, Try sh -c 'R_DEFAULT_PACKAGES="$R_DEFAULT_PACKAGES Rcmdr" R "$@"' This is pulled directly from the launcher that Ubuntu creates when it installs Rcmdr from the repository. --Lee On 10/23/2010 11:37 AM, Liviu Andronic wrote: > On Sat, Oct 23, 2010 at 5:30 PM, Henrique Dallazuanna > wrote: >> In windows it work's fine >> > After further experimentation, it does work when I escape the > parentheses. However, both > l...@liv-laptop:~$ R --interactive -e require\(Rcmdr\) > > and > l...@liv-laptop:~$ R -e require\(Rcmdr\) --interactive > > fail to pop up Commander(), as described in the original post. The > same holds for the following > l...@liv-laptop:~$ R -e require\(Rcmdr\) > > Ideas? > Liviu > -- Lee Hachadoorian PhD Student, Geography Program in Earth & Environmental Sciences CUNY Graduate Center __ 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] Best IDE for R
On Wed, 27 Oct 2010 16:31:30 +0530, Santosh Srinivas wrote: > I am looking for suggestions for the "best" IDE for R. Best is obviously > subjective but I need just the basic features that should function well (and > I looked through the threads already). > - Proper integration with R 2.11.1 > - Good key shortcuts ... similar to the R Gui > - Manageability of Projects, etc. > - Neat formatting features > > I tried Revolution R but it seems huge in size for something my basic needs > and keep throwing up configuration problems. > I tried Komodo. It works fine but having problems with "proper" integration > into R and unable to do debugging. Hi Santosh, I guess the main choice would be do you want something to supercharge your text editor so that it works well with R, or do you want something "bigger". For an R-enabled text editor, I would suggest Tinn-R for Windows or RGedit (a gedit plugin) for Linux/Gnome-desktop. Since both are just text editors, they will work with whatever version R you have installed (criteria 1). RGedit is pretty spare: basically just console integration and keyboard shortcuts to send code (current line, selection, defined blocks) to the console. Criteria 1 Y 2 basic 3 N 4 N Tinn-R is much richer. It has function reference pane (double click to insert the function with argument placeholders. It also let's you define R hotkeys, so you can configure the keyboard shortcuts however you want. The main problem is that when hotkeys are enabled, Tinn-R intercepts key presses even when another application window is active. Another thing I didn't like about R is that the console is not integrated into the IDE. It also let's you define project files (criteria 3). Criteria 1 Y 2 Y (except for key intercept issue) 3 Y 4 Y For something with more features but still easier to approach than Revolution R, I like RKWard. It's KDE only, but I got so used to using it on Ubuntu that I now run it on a VM on my Windows machine. (An attempt to run it on KDE Windows was unsuccessful.) The workspace panel shows you all objects and loaded packages. It has an itegrated console and integrated R documentation. It will save a "workplace layout" with your R workspace so that when you load the workspace your script files, documentation windows, object views, will all be restored. Of course, if you're not on Linux, you might not want to go to the trouble of running a VM. Criteria 1 Y 2 Y 3 Y 4 Y Hope this helps, --Lee -- Lee Hachadoorian PhD Student, Geography Program in Earth & Environmental Sciences CUNY Graduate Center __ 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] Generate random percentages and placing vectors
Thanks for the help! However, for the code in #2, it seems to just randomly split up the vectors. I would still like to keep the integrity of each vector. For example: if v1 = (1,2,3) v2 = (4,5,6) output = (0,0,0,1,2,3,0,0,0,0,4,5,6,0,0,0,0,0,0,0,0,0,0,0,0) - which has a specified length of 25 With v1 and v2 inserted in at random locations. On Wed, Oct 27, 2010 at 10:25 AM, Jonathan P Daily wrote: > > 1) > rands <- runif(5) > rands <- rands/sum(rands)*100 > > 2) > # assume vectors are v1, v2, etc. > v_all <- c(v1, v2, ...) > v_len <- length(v_all) > > output <- rep(0,25) > output[sample(1:25, v_len)] <- v_all > > -- > Jonathan P. Daily > Technician - USGS Leetown Science Center > 11649 Leetown Road > Kearneysville WV, 25430 > (304) 724-4480 > "Is the room still a room when its empty? Does the room, > the thing itself have purpose? Or do we, what's the word... imbue it." > - Jubal Early, Firefly > > > From: Aaron Lee To: r-help@r-project.org Date: > 10/27/2010 > 11:06 AM Subject: [R] Generate random percentages and placing vectors Sent > by: r-help-boun...@r-project.org > -- > > > > Hello everyone, > > I have two questions: > > 1.) I would like to generate random percentages that add up to 100. For > example, if I need 5 percentages, I would obtain something like: 20, 30, > 40, > 5, 5. Is there some way to do this in R? > > 2.) I would like to insert vectors of specified length into a larger vector > of specified length randomly, and fill the gaps with zeroes. For example, > if > I have 3 vectors of length 3, 2, and 2 with values and I would like to > randomly place them into a vector of length 25 made of 0's. > > Thank you in advance! > > -Aaron > > [[alternative HTML version deleted]] > > __ > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] __ 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] 32-bit packages on 64-bit Windows
Are 32-bit precompiled packages supposed to work on 32-bit R installed on 64-bit Windows? I *think* the Windows R FAQ (2.28 Should I run 32-bit or 64-bit R?) implies that they will work, but I am having trouble getting certain packages to work. Before I spend more time on it or start asking questions about specific packages, I would like to know I'm not trying to do something impossible. Thanks, --Lee __ 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] 32-bit packages on 64-bit Windows
Thanks very much for the information. I also see that http://cran.r-project.org/bin/windows/contrib/2.12/ReadMe has information on some of the packages I'm interested in. Thanks for the help, --Lee On Mon, Nov 1, 2010 at 1:48 PM, Duncan Murdoch wrote: > On 01/11/2010 1:40 PM, Lee Hachadoorian wrote: >> >> Are 32-bit precompiled packages supposed to work on 32-bit R installed >> on 64-bit Windows? I *think* the Windows R FAQ (2.28 Should I run >> 32-bit or 64-bit R?) implies that they will work, but I am having >> trouble getting certain packages to work. Before I spend more time on >> it or start asking questions about specific packages, I would like to >> know I'm not trying to do something impossible. > > > Yes, but be sure they were compiled for R 2.12.0. The location of DLLs has > changed, as well as the other usual minor internal changes that come with a > new version. > > Duncan Murdoch > -- Lee Hachadoorian PhD Student, Geography Program in Earth & Environmental Sciences CUNY Graduate Center __ 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] Detect the Warning Message
Dear all, I've written a function and repeated it for 5000 times with loops with different value, and the messages returned are the output I set and 15 warnings. I would like to trace the warnings by stopping the loop when warning came out. Does anyone know how to make it? Thanks a lot for your help. Yen [[alternative HTML version deleted]] __ 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] How to Read a Large CSV into a Database with R
On Mon, 15 Nov 2010 13:28:40 -0500, Anthony Damico wrote: > Do you have any other ideas as to how I might diagnose what's going on > here? Or, alternatively, is there some workaround that would get this giant > CSV into a database? If you think there's a reasonable way to use the > IMPORT command with RSQLite, that seems like it would import the fastest, > but I don't know that it's compatible with DBI on Windows. > > Thanks again! > Anthony If you are able to successfully read in one entire 1.2 GB file at a time, I would skip sqldf and do this (after setting the working directory appropriately): connSQLite = dbConnect(dbDriver("SQLite"), dbname = "acs") ss09pusa = read.csv("ss09pusa.csv", header = TRUE) dbWriteTable(connSQLite, "acs2009", ss09pusa) rm(ss09pusa) ss09pusb = read.csv("ss09pusb.csv", header = TRUE) dbWriteTable(connSQLite, "acs2009", ss09pusb, append = TRUE) rm(ss09pusb) #Test select of specific columns sql = "SELECT ST, PUMA, ADJINC FROM acs2009 WHERE ST = 33" dfIncome = dbGetQuery(connSQLite, sql) I was *not* able to load one entire table at a time, so I was able to make it work by combining sqldf to read in chunks at a time and dbWriteTable from RSQLite to write each chunk to the database. The read would then look like, for example: ss09pusa = read.csv.sql("ss09pusa.csv", sql = paste("SELECT * FROM file WHERE ST =", i)) where i is an iteration over the state FIPS codes. (You could just use 1 to 56, even though there's a few missing numbers in there. The searches for nonexistent records will take time but will otherwise be harmless.) The dbWriteTable would be the same, with every write after the first one using append = TRUE. Also, I assume you will want to do the read from csv / write to SQLite *once*, then maintain the SQLite database for other sessions. We also use large census and IPUMS data sets, and we keep everything in a Postgres backend, which we access with RPostgreSQL. Much easier to keep everything organized in an RDBMS than to pass around these monstrous csv files. __ 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] Variable Editor
On Wed, 17 Nov 2010 04:11:17 -0800, Alaios wrote: > Hello everoyne, > If you have ever used matlab you should know the variable editor. > You click over the value of a variable in the workspace and it opens > like a excel sheet. Do you know if there is something like that in R . > This will make easier for me to understand what values are stored in a > matrix. > > Also I am using rkward. Do you know if there is anyway to see the > already defined variables? If you are already using RKWard, it has a spreadsheet-style editor. Click on the Workspace button on the upper left and you will see a list of all objects (the second part of your question), including variables, data frame, and open packages. Then if you right click on the name of a data frame and select Edit from the context menu, you will see a spreadsheet-style editor. Best, Lee Hachadoorian PhD Student, Geography Program in Earth & Environmental Sciences CUNY Graduate Center __ 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] Splitting 3D matrix from for loop to generate/save 2D matrices
Hi! I have a matrix called M with dimension (586,100,100). I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the following for loops but couldn't get it work.. l<-dim(M)[1] for (i in (1:l)){ save(M[i,,],file = "M_[i].img") } Can somebody help me with this? Thanks! Hana Lee [[alternative HTML version deleted]] __ 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] Writing out data from a list
Hello, I have a list of data, such that: [[1]] [1] 0.00 0.00 0.03 0.01 0.00 0.00 0.00 0.00 0.01 0.01 0.00 0.00 0.01 0.00 0.00 0.03 0.01 0.00 0.01 0.00 0.03 0.16 0.14 0.02 0.17 0.01 0.01 0.00 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 [42] 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.04 0.08 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 [[2]] [1] 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.07 0.00 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 [[3]] [1] 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 etc. I would like to write to a text file with this data, but would like each section of the file to be separated by some text. For example: "Event 1" "Random Text" 0 0 0.03 0.01 "Event 2" "Random Text" 0 0 0 0 0.01 etc. Is there some way to continually write text out using a loop and also attaching a string before each data segment? Thank you in advance! -Aaron [[alternative HTML version deleted]] __ 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] Conversion to xlsx file
Hi, all I would like to convert xls files to xlsx files with R commands in R console instead of saving xls files as xlsx files after opening xls files. Please show me how. Thanks. Wonjae -- View this message in context: http://r.789695.n4.nabble.com/Conversion-to-xlsx-file-tp3487118p3487118.html Sent from the R help mailing list archive at Nabble.com. __ 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] MacKinnon critical value
Hello, I am doing an Engle Granger test on the residuals of two I(1) processes. I would like to get the MacKinnon (1996) critical value, say at 10%. I have 273 observations with 5 integrated explanatory variables , so that k=4. Could someone help me with the procedure in R? Thank you [[alternative HTML version deleted]] __ 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] understanding error messages in archmCopulaFit in fCopulae
Hello, I'm running version R x64 v2.12.2 on a 64bit windows 7 PC. I have two data vectors, x and y, and try to run archmCopulaFit. Most of the copulas produce errors. Can you tell me what the errors mean and if possible, how I can set archmCopulaFit options to make them run? I see in the documentation that there are "arguments passed to the optimization function in use, 'nlminb'", however, it's not clear to me how to set them. Thanks. Copulas 2, 4,7,8,11,12,14,15,18,19,20,21,22 have the following error: fit1 = archmCopulaFit(x,y,type="2") Error in if (alpha < range[1] | alpha > range[2]) { : missing value where TRUE/FALSE needed Copulas 3 has the following error: fit1 = archmCopulaFit(x,y,type="3") Error in if (alpha < range[1] | alpha > range[2]) { : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In log(darchmCopula(u = U, v = V, alpha = x, type = type)) : NaNs produced 2: In log(darchmCopula(u = U, v = V, alpha = x, type = type)) : NaNs produced Copula 10: fit1 = archmCopulaFit(x,y,type="10") Error in if (alpha < range[1] | alpha > range[2]) { : missing value where TRUE/FALSE needed In addition: Warning message: In log(darchmCopula(u = U, v = V, alpha = x, type = type)) : NaNs produced Copulas 1,5,9,13,16,17 produce estimates. [[alternative HTML version deleted]] __ 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] remove commas in a number when reading a text file
Hello, I'm running version R x64 v2.12.2 on a 64bit windows 7 PC. I'm trying to read a text file using read.table where the values have a format like "1,234,567". What I want is "1234567". Is there a quick way to strip out the commas? I can use strsplit and paste, but the file is quite large and would take some time. Thanks. Eric [[alternative HTML version deleted]] __ 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] remove commas in a number when reading a text file
Thanks, Peter and to Joshua Wiley and Peter Alspach for similar comments. Gsub did the trick. -Original Message- From: Peter Langfelder [mailto:peter.langfel...@gmail.com] Sent: Monday, June 13, 2011 4:35 PM To: Lee, Eric Cc: r-help@R-project.org Subject: Re: [R] remove commas in a number when reading a text file On Mon, Jun 13, 2011 at 8:48 AM, Lee, Eric wrote: > Hello, > > I'm running version R x64 v2.12.2 on a 64bit windows 7 PC. I'm trying to > read a text file using read.table where the values have a format like > "1,234,567". What I want is "1234567". Is there a quick way to strip out > the commas? I can use strsplit and paste, but the file is quite large and > would take some time. Thanks. You could use gsub. if you have a character string s, use sWithoutCommas = gsub(",", "", s, fixed = TRUE) to remove all commas from s. To do it for a whole table, I would do something like removeComma= function(s) {gsub(",", "", s, fixed = TRUE)} tabWithoutCommas = apply(tab, 2, removeComma) Try it to see if does what you need. HTH, Peter __ 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] leap year and order function
im trying to write a for loop so that every leap year, the number of days becomes to 366 instead of 365. could someone help me out? and also, this set of data has 99.99s I set all the 99.99 ==NA. however, when im doing the order function to find the max value of that year, it still reads 99.99 as the max value. Thank you very much maxday <- matrix(NA,63,5) for (a in 1948:2010){ maxday[,1]<-1948:2010 yearly<-na.omit(dat.mat[dat.mat[,1]==a,]) maxday[a-1947,2]<-yearly[order(yearly[,4])[*365*],2] maxday[a-1947,3]<-yearly[order(yearly[,4])[*365*],3] maxday[63,2]<-yearly[order(yearly[,4])[127],2] maxday[63,3]<-yearly[order(yearly[,4])[127],3] maxday[a-1947,4]<-max(yearly[,4]) maxday[,5]<-len[,2] } [[alternative HTML version deleted]] __ 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] circular
Hi, I'm new to R. I'm trying to plot my data into a circle. my data sort of looks like 12,12,4,5,6,5,11,10,3,9,9,9,12,12,2 total of 15 numbers. I'm trying to add all the same numbers, such that, there are 4 of 12s,1 of 11, 1 of 10, 3 of 9s, and such so the circle plot would have 4 parts of 12, 1 part of 11, 1 part of 10, 3 part of 9, and such... I tried >plot(circular(maxday[,2]*2*pi/12)) ##where maxday[,2] looks like the data above. but the only thing came out was dots, and they over wrote on each other. basically I would like to plot a pizza shape circle, where some of the slices are bigger than others. Thank you very much. [[alternative HTML version deleted]] __ 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] Changing the points in a circular plot
x<-circular(dayofmax[,2]*2*pi/365) res25 <- density(x, bw=25, control.circular=list(units="degrees")) circularp(res25$x) plot(res25, col=4, points.plot=TRUE, xlim=c(-1.5,1.5)) res50 <- density(x, bw=50, adjust=2) lines(res50, col=2) lines(res50, col=3, shrink=0.9) this is my code, basically, it plots all my data on a circular. and the lines are telling where points are more dense than other places. so my problems is that im trying to change all the points in the circular plot. instead of have it being 0, 90, 180, 270... i would like to input my own stuff in there, such as Jan, Feb, March please help!! Thank you very much. [[alternative HTML version deleted]] __ 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 center
Could you please take my email off the help center? Thank you very much. [[alternative HTML version deleted]] __ 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] predicting values from multiple regression
Hey List, I did a multiple regression and my final model looks as follows: model9<-lm(calP ~ nsP + I(st^2) + distPr + I(distPr^2)) Now I tried to predict the values for calP from this model using the following function: xv<-seq(0,89,by=1) yv<-predict(model9,list(distPr=xv,st=xv,nsP=xv)) The predicted values are however strange. Now I do not know weather just the model does not fit the data (actually all coefficiets are significant and the plot(model) shows a good shape) or wether I did something wrong with my prediction command. Does anyone have an idea??? -- Thanks a lot, Anna __ 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] predicting values from multiple regression
Dear Ista! Thank you for replying. The point you made is exactly what's the problem: I want to predict the values at different points in space. calP stands for the water content at each sampling point (n=90) but I don't quite understand what R does. calP is my vector of measured data and I thought with the predict function the programm would calculate a value from the model function for every value of calP... ? 2011/3/20 Ista Zahn : > Hi Anna, > > On Sun, Mar 20, 2011 at 2:54 PM, Anna Lee wrote: >> Hey List, >> >> I did a multiple regression and my final model looks as follows: >> >> model9<-lm(calP ~ nsP + I(st^2) + distPr + I(distPr^2)) >> >> Now I tried to predict the values for calP from this model using the >> following function: >> >> xv<-seq(0,89,by=1) >> yv<-predict(model9,list(distPr=xv,st=xv,nsP=xv)) > > The second argument to predict.lm is newdata, which should be a > data.frame. see ?predict.lm. > > Beyond that though, I'm not sure what you are trying to accomplish. > The way you've set this up you would get predicted values for cases > like > > distPr st nsp > 0 0 0 > 1 1 1 > 2 2 2 > . . . > 89 89 89 > > > Is that really what you want? > > Best, > Ista >> >> The predicted values are however strange. Now I do not know weather >> just the model does not fit the data (actually all coefficiets are >> significant and the plot(model) shows a good shape) or wether I did >> something wrong with my prediction command. Does anyone have an >> idea??? >> >> -- >> >> >> Thanks a lot, Anna >> >> __ >> 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. >> > > > > -- > Ista Zahn > Graduate student > University of Rochester > Department of Clinical and Social Psychology > http://yourpsyche.org > -- Der Inhalt dieser E-Mail ist vertraulich. Sollte Ihnen die E-Mail irrtümlich zugesandt worden sein, bitte ich Sie, mich unverzüglich zu benachrichtigen und die E-Mail zu löschen. This e-mail is confidential. If you have received it in error, please notify me immediately and delete it from your system. __ 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] predicting values from multiple regression
Dennis: Thank you so much! I got it now - it just works perfectly. Thanks a lot! Anna 2011/3/21 Dennis Murphy : > Hi: > > To amplify Ista's and David's comments: > > (1) You should not be inputting separate vectors into lm(), especially if > you intend to do prediction. They should be combined into a data frame > instead. This is not a requirement, but it's a much safer strategy for > modeling in R. > (2) Your covariate st does not have a linear component. It should, > particularly if this is an empirical model rather than a theoretical one. > (3) You should be using poly(var, 2) to create orthogonal columns in the > model matrix for the variables that are to contain quadratic terms. > (4) The newdata = argument of predict.lm() [whose help page you should read > carefully] requires a data frame with columns having precisely the same > variable names as exist in the RHS of the model formula in lm(). > > Example: > dd <- data.frame(y = rnorm(50), x1 = rnorm(50), x2 = runif(50, -2, 2), x3 = > rpois(50, 10)) > > # fit yhat = b0 + b1 * x1 + b2 * x1^2 + b3 * x2 + b4 * x3 + b5 * x3^2 > mod <- lm(y ~ poly(x1, 2) + x2 + poly(x3, 2), data = dd) > > # Note that the names of the variables in newd are the same as those on the > RHS of the formula in mod > newd <- data.frame(x1 = rnorm(5), x2 = runif(5, -2, 2), x3 = rpois(5, > 10)) # new data points > # Append predictions to newd > cbind(newd, predict(mod, newdata = newd)) # predictions at new > data points > > # To just get predictions at the observed points, all you need is > predict(mod) > > HTH, > Dennis > > On Sun, Mar 20, 2011 at 11:54 AM, Anna Lee wrote: >> >> Hey List, >> >> I did a multiple regression and my final model looks as follows: >> >> model9<-lm(calP ~ nsP + I(st^2) + distPr + I(distPr^2)) >> >> Now I tried to predict the values for calP from this model using the >> following function: >> >> xv<-seq(0,89,by=1) >> yv<-predict(model9,list(distPr=xv,st=xv,nsP=xv)) >> >> The predicted values are however strange. Now I do not know weather >> just the model does not fit the data (actually all coefficiets are >> significant and the plot(model) shows a good shape) or wether I did >> something wrong with my prediction command. Does anyone have an >> idea??? >> >> -- >> >> >> Thanks a lot, Anna >> >> __ >> 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. > > -- Der Inhalt dieser E-Mail ist vertraulich. Sollte Ihnen die E-Mail irrtümlich zugesandt worden sein, bitte ich Sie, mich unverzüglich zu benachrichtigen und die E-Mail zu löschen. This e-mail is confidential. If you have received it in error, please notify me immediately and delete it from your system. __ 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] predicting values from multiple regression
Dennis: thank you so much! I got it now and it works just perfectly. Thanks a lot to the others too! Anna 2011/3/21 Dennis Murphy : > Hi: > > To amplify Ista's and David's comments: > > (1) You should not be inputting separate vectors into lm(), especially if > you intend to do prediction. They should be combined into a data frame > instead. This is not a requirement, but it's a much safer strategy for > modeling in R. > (2) Your covariate st does not have a linear component. It should, > particularly if this is an empirical model rather than a theoretical one. > (3) You should be using poly(var, 2) to create orthogonal columns in the > model matrix for the variables that are to contain quadratic terms. > (4) The newdata = argument of predict.lm() [whose help page you should read > carefully] requires a data frame with columns having precisely the same > variable names as exist in the RHS of the model formula in lm(). > > Example: > dd <- data.frame(y = rnorm(50), x1 = rnorm(50), x2 = runif(50, -2, 2), x3 = > rpois(50, 10)) > > # fit yhat = b0 + b1 * x1 + b2 * x1^2 + b3 * x2 + b4 * x3 + b5 * x3^2 > mod <- lm(y ~ poly(x1, 2) + x2 + poly(x3, 2), data = dd) > > # Note that the names of the variables in newd are the same as those on the > RHS of the formula in mod > newd <- data.frame(x1 = rnorm(5), x2 = runif(5, -2, 2), x3 = rpois(5, > 10)) # new data points > # Append predictions to newd > cbind(newd, predict(mod, newdata = newd)) # predictions at new > data points > > # To just get predictions at the observed points, all you need is > predict(mod) > > HTH, > Dennis > > On Sun, Mar 20, 2011 at 11:54 AM, Anna Lee wrote: >> >> Hey List, >> >> I did a multiple regression and my final model looks as follows: >> >> model9<-lm(calP ~ nsP + I(st^2) + distPr + I(distPr^2)) >> >> Now I tried to predict the values for calP from this model using the >> following function: >> >> xv<-seq(0,89,by=1) >> yv<-predict(model9,list(distPr=xv,st=xv,nsP=xv)) >> >> The predicted values are however strange. Now I do not know weather >> just the model does not fit the data (actually all coefficiets are >> significant and the plot(model) shows a good shape) or wether I did >> something wrong with my prediction command. Does anyone have an >> idea??? >> >> -- >> >> >> Thanks a lot, Anna >> >> __ >> 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. > > -- Der Inhalt dieser E-Mail ist vertraulich. Sollte Ihnen die E-Mail irrtümlich zugesandt worden sein, bitte ich Sie, mich unverzüglich zu benachrichtigen und die E-Mail zu löschen. This e-mail is confidential. If you have received it in error, please notify me immediately and delete it from your system. __ 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] postscript rotation (bug?)
Dear Marc, Your answer on post https://stat.ethz.ch/pipermail/r-help/2005-March/067634.html has a broken link. Thank you, W __ 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] statistical question
Dear List! I want to compare medians of non normal distributed data. Is it possible and usefull to calculate 95% confidence intervals for medians? And if so - how can this be achieved in R? Thanks a lot! Anna -- Der Inhalt dieser E-Mail ist vertraulich. Sollte Ihnen die E-Mail irrtümlich zugesandt worden sein, bitte ich Sie, mich unverzüglich zu benachrichtigen und die E-Mail zu löschen. This e-mail is confidential. If you have received it in error, please notify me immediately and delete it from your system. __ 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] another statistical question
Dear List! I have a unverse (basic population) which is not normally distributed. Now from this universe I take some subsets. Each subset is normally distributed within itself. I now want to compare the subsets and see if they differ significantly. So what is my assumption - normal distributed data and therefore comparison of means, or non normal distributed data and therefore comparison of medians? Cheers, Anna -- Der Inhalt dieser E-Mail ist vertraulich. Sollte Ihnen die E-Mail irrtümlich zugesandt worden sein, bitte ich Sie, mich unverzüglich zu benachrichtigen und die E-Mail zu löschen. This e-mail is confidential. If you have received it in error, please notify me immediately and delete it from your system. __ 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.