Re: [R] Unable to Load package Rcmdr after installation
Hi Paul, what fails and how? What did you do from the time the package worked until is didn't? Did you update packages? Which packages are you trying to load? Best Ulrik On Thu, 9 Mar 2017 at 18:40 paulberna...@gmail.com wrote: > Thanks Ulrik, but the thing is that I tried installing adn loading tve > Hmisc package but wasn't able to do that either. > > > Mensaje original > Asunto: Re: [R] Unable to Load package Rcmdr after installation > De: Ulrik Stervbo > Para: Paul Bernal ,r-help@r-project.org > CC: > > > Hi Paul, > > The error tells you, that the 'Hmisc' does not exist on your system. If > you install it, everything should work. > > Use install.packages with dependencies = TRUE to avoid the problem of > missing packages. > > HTH > > Ulrik > > On Thu, 9 Mar 2017 at 16:51 Paul Bernal wrote: > > Hello friends, > > Has anyone experienced trouble when trying to load package Rcmdr? It was > working perfectly a couple of days ago, I don´t know why it isn´t working. > > > library("Rcmdr") > Loading required package: splines > Loading required package: RcmdrMisc > Loading required package: car > Loading required package: sandwich > Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck > = vI[[j]]) : > there is no package called ‘Hmisc’ > Error: package ‘RcmdrMisc’ could not be loaded > > [[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. > > [[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] restructuring data frame
Dear all I have some data with following structure in data frame. dput(evid[1:2,c(2:4)]) evid <- structure(list(V2 = c("test vodivosti kalcinátu", "impregnace anatasové pasty rozprašovací sušárna" ), V3 = c("03.03.2017", "17.03.2017"), V4 = c("EICHLER Věra;#125", "HOŠŤÁLKOVÁ Jarmila;#119;#BERNÁT Miroslav;#122;#OSTRČIL Marek;#60" )), .Names = c("V2", "V3", "V4"), row.names = 9:10, class = "data.frame") Each row in V4 column contain names followed by ;#xxx. I would like to separate them like that mena <- liche(unlist(strsplit(evid[2,4], ";#"))) here is function liche liche <- function (x) { indices <- seq(along = x) x[indices%%2 == 1] } and repeat each respective row of data frame for separated names like following (which is only for one row) temp<-evid[2,][rep(seq_len(nrow(evid[2,])), length(mena)),-4] cbind(temp, mena) V1 V2 V3 10 NEPRAVDA impregnace anatasové pasty rozprašovací sušárna 17.03.2017 10.1 NEPRAVDA impregnace anatasové pasty rozprašovací sušárna 17.03.2017 10.2 NEPRAVDA impregnace anatasové pasty rozprašovací sušárna 17.03.2017 V5V6 V7 mena 10 OSTRČIL Marek OSTRČIL Marek 1kalcinace HOŠŤÁLKOVÁ Jarmila 10.1 OSTRČIL Marek OSTRČIL Marek 1kalcinaceBERNÁT Miroslav 10.2 OSTRČIL Marek OSTRČIL Marek 1kalcinace OSTRČIL Marek I probably could do it for each row in cycle (the data frame is not big) but I wonder if somebody knows any more elegant/easy/effective solution for such task. Best regards Petr Pikal "Kdo vždy myslí, že se učí, bude vlasti chlouba. Kdo si myslí, že dost umí, začíná být trouba." Karel Havlíček Borovský Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. __ 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] concatenating range of columns in dataframe
Hi Evan, the unite function of the tidyr package achieves the same as Jim suggested, but in perhaps a slightly more readable manner. Ulrik On Fri, 10 Mar 2017 at 07:50 Jim Lemon wrote: > Hi Evan, > How about this: > > df2<-data.frame(Trt=df[,1],Conc=apply(df[,2:5],1,paste,sep="",collapse="")) > > Jim > > On Fri, Mar 10, 2017 at 3:16 PM, Evan Cooch wrote: > > Suppose I have the following data frame (call it df): > > > > Trt y1 y2 y3 y4 > > A1A 1001 > > A1B 1100 > > A1 C 0 10 1 > > A1D 111 1 > > > > What I want to do is concatenate columns y1 -> y4 into a contiguous > string > > (which I'll call df$conc), so that the final df looks like > > > > Trt Conc > > A1A 1001 > > A1B 1100 > > A1C 0101 > > A1D > > > > > > Now, if my initial dataframe was simply > > > > 1 0 0 1 > > 1 1 0 0 > > 0 1 0 1 > > 1 1 1 1 > > > > then apply(df,1,paste,collapse="") does the trick, more or less. > > > > But once I have a Trt column, this approach yields > > > > A1A1001 > > A1B1100 > > A1C0101 > > A1D > > > > I need to maintain the space between Trt, and the other columns. So, I'm > > trying to concatenate a subset of columns in the data frame, but I don't > > want to have to do something like create a cahracter vector of the column > > names to do it (e.g., c("y1","y2","y3","y4"). Doing a few by hand that > way > > is easy, but not if you have dozens to hundreds of columns to work with. > > > > Ideally, I'd like to be able to say > > > > "concatenate df[,2:4], get rid of the spaces, pipe the concatenated > columns > > to a new named column, and drop the original columns from the final df. > > > > Heuristically, > > > > df$conc <- concatenate df[,2:4] # making a new, 5th column in df > > df[,2:4] <- NULL # to drop original columns 2 -> 4 > > > > Suggestions/pointers to the obvious appreciated. > > > > Thanks in advance! > > > > __ > > 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. > [[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] concatenating range of columns in dataframe
I think you need to spend some time with an R tutorial or two, especially with regard to indexing. Unless I have misunderstood (apologies if I have), df$Conc <- apply(df[,-1],1,paste,collapse="") does it. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Mar 9, 2017 at 8:16 PM, Evan Cooch wrote: > Suppose I have the following data frame (call it df): > > Trt y1 y2 y3 y4 > A1A 1001 > A1B 1100 > A1 C 0 10 1 > A1D 111 1 > > What I want to do is concatenate columns y1 -> y4 into a contiguous string > (which I'll call df$conc), so that the final df looks like > > Trt Conc > A1A 1001 > A1B 1100 > A1C 0101 > A1D > > > Now, if my initial dataframe was simply > > 1 0 0 1 > 1 1 0 0 > 0 1 0 1 > 1 1 1 1 > > then apply(df,1,paste,collapse="") does the trick, more or less. > > But once I have a Trt column, this approach yields > > A1A1001 > A1B1100 > A1C0101 > A1D > > I need to maintain the space between Trt, and the other columns. So, I'm > trying to concatenate a subset of columns in the data frame, but I don't > want to have to do something like create a cahracter vector of the column > names to do it (e.g., c("y1","y2","y3","y4"). Doing a few by hand that way > is easy, but not if you have dozens to hundreds of columns to work with. > > Ideally, I'd like to be able to say > > "concatenate df[,2:4], get rid of the spaces, pipe the concatenated columns > to a new named column, and drop the original columns from the final df. > > Heuristically, > > df$conc <- concatenate df[,2:4] # making a new, 5th column in df > df[,2:4] <- NULL # to drop original columns 2 -> 4 > > Suggestions/pointers to the obvious appreciated. > > Thanks in advance! > > __ > 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.
Re: [R] Negative binomial GAMM using 'by' in factor interactions
Your queries appear to concern statistical issues. This list is about R programming and related; statistical issues are typically OT here. stats.stackexchange.com or a local statistical expert are probably better places to seek statistical advice. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Mar 9, 2017 at 8:14 PM, Eva Maria Leunissen wrote: > I am using a GAMM to model my data (this is as far as I know the only way I > can use the negative binomial distribution AND a correlation structure > within the model). > > I measured animal detections (including zero detections) per hour at 3 > different locations in an area. location is a factor in my model and the > other possible explanatory variables are environmental variables and level > of disturbance. > > I'm expecting the response to be different at the 3 different locations for > each variable so have been modelling the terms as interactions with each of > the 3 factor levels of location using the 'by' argument in the 'ti' > smoothing term, as well as 'location' as a variable by itself. Does it make > sense to include the main effect as well as the interaction term? for > example for including the variable 'windspeed': if including the term > ti(windspeed, by=location), is it necessary to also include s(windspeed)? > or would it only make sense to inlcude them in separate models only and > compare the models? > > As far as I understand the 'by' argument calculates a separate smooth for > each of the factor levels, so if the effect was the same at each location > it wouldn't hurt to use the 'ti' smooth with the 'by' argument if the > effect of the variable was the same at each location. > > The issue I'm having is that by including both terms and then doing model > selection gives me many very similar models within a deltaAIC of 6 of the > best model, where the differences lie in the inclusion of main effects when > the 'interaction' is also there. The inclusion of the interaction term > gives bigger changes in AIC compared to the inclusion of the main effect. > > This brings me to my other question. Is it possible to compare GAMMs with a > negative binomial family using AIC? e.g. using AIC(mod$lme). If not, what > is the best way to compare them? > > Thank you very much for your time > > [[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.
Re: [R] concatenating range of columns in dataframe
Hi Evan, How about this: df2<-data.frame(Trt=df[,1],Conc=apply(df[,2:5],1,paste,sep="",collapse="")) Jim On Fri, Mar 10, 2017 at 3:16 PM, Evan Cooch wrote: > Suppose I have the following data frame (call it df): > > Trt y1 y2 y3 y4 > A1A 1001 > A1B 1100 > A1 C 0 10 1 > A1D 111 1 > > What I want to do is concatenate columns y1 -> y4 into a contiguous string > (which I'll call df$conc), so that the final df looks like > > Trt Conc > A1A 1001 > A1B 1100 > A1C 0101 > A1D > > > Now, if my initial dataframe was simply > > 1 0 0 1 > 1 1 0 0 > 0 1 0 1 > 1 1 1 1 > > then apply(df,1,paste,collapse="") does the trick, more or less. > > But once I have a Trt column, this approach yields > > A1A1001 > A1B1100 > A1C0101 > A1D > > I need to maintain the space between Trt, and the other columns. So, I'm > trying to concatenate a subset of columns in the data frame, but I don't > want to have to do something like create a cahracter vector of the column > names to do it (e.g., c("y1","y2","y3","y4"). Doing a few by hand that way > is easy, but not if you have dozens to hundreds of columns to work with. > > Ideally, I'd like to be able to say > > "concatenate df[,2:4], get rid of the spaces, pipe the concatenated columns > to a new named column, and drop the original columns from the final df. > > Heuristically, > > df$conc <- concatenate df[,2:4] # making a new, 5th column in df > df[,2:4] <- NULL # to drop original columns 2 -> 4 > > Suggestions/pointers to the obvious appreciated. > > Thanks in advance! > > __ > 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.
Re: [R] matrix merge, or something else?
test2[ , colnames( test1 ) ] <- test1 -- Sent from my phone. Please excuse my brevity. On March 9, 2017 6:56:13 PM PST, Evan Cooch wrote: >Suppose I have the following two matrices, both with same number of >rows >(3), but different number of columns (3 in test1, 4 in test2). > >test1 <- matrix(c(1,1,0,1,0,-1,-1,-1,0),3,3,byrow=T); >test2 <- matrix( rep( 0, len=12), nrow = 3) > >I label the rows and columns of the two matrices as follows: > >rownames(test1) <- c("row1","row2","row3") >rownames(test2) <- c("row1","row2","row3") > >colnames(test1) <- c("a","b","d") >colnames(test2) <- c("a","b","c","d") > >So, if we look at the matrices, we see > >test1 > > a b d >row1 1 1 0 >row2 1 0 -1 >row3 -1 -1 0 > > >test2 > > a b c d >row1 0 0 0 0 >row2 0 0 0 0 >row3 0 0 0 0 > >So, we see that while both matrices have the same rows, the matrix >test1 >has a subset of the columns of test2. In test1, there is no column for >'c' -- have columns for 'a', 'b', 'd'. > >Now, what I want to do is this -- take the information from each column > >in test1, and substitute it into the same row/column in test2. The end >result should be a matrix that looks like: > > a b c d >row1 1 1 0 0 >row2 1 0 0 -1 >row3 -1 -1 0 0 > >My initial though was some sort of merge by row and column, with some >funky sort of intersection, but I couldn't figure out how to get that >to >work. > >Any suggestions/pointers to the obvious most appreciated. > >__ >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] concatenating range of columns in dataframe
Suppose I have the following data frame (call it df): Trt y1 y2 y3 y4 A1A 1001 A1B 1100 A1 C 0 10 1 A1D 111 1 What I want to do is concatenate columns y1 -> y4 into a contiguous string (which I'll call df$conc), so that the final df looks like Trt Conc A1A 1001 A1B 1100 A1C 0101 A1D Now, if my initial dataframe was simply 1 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 then apply(df,1,paste,collapse="") does the trick, more or less. But once I have a Trt column, this approach yields A1A1001 A1B1100 A1C0101 A1D I need to maintain the space between Trt, and the other columns. So, I'm trying to concatenate a subset of columns in the data frame, but I don't want to have to do something like create a cahracter vector of the column names to do it (e.g., c("y1","y2","y3","y4"). Doing a few by hand that way is easy, but not if you have dozens to hundreds of columns to work with. Ideally, I'd like to be able to say "concatenate df[,2:4], get rid of the spaces, pipe the concatenated columns to a new named column, and drop the original columns from the final df. Heuristically, df$conc <- concatenate df[,2:4] # making a new, 5th column in df df[,2:4] <- NULL # to drop original columns 2 -> 4 Suggestions/pointers to the obvious appreciated. Thanks in advance! __ 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] Negative binomial GAMM using 'by' in factor interactions
I am using a GAMM to model my data (this is as far as I know the only way I can use the negative binomial distribution AND a correlation structure within the model). I measured animal detections (including zero detections) per hour at 3 different locations in an area. location is a factor in my model and the other possible explanatory variables are environmental variables and level of disturbance. I'm expecting the response to be different at the 3 different locations for each variable so have been modelling the terms as interactions with each of the 3 factor levels of location using the 'by' argument in the 'ti' smoothing term, as well as 'location' as a variable by itself. Does it make sense to include the main effect as well as the interaction term? for example for including the variable 'windspeed': if including the term ti(windspeed, by=location), is it necessary to also include s(windspeed)? or would it only make sense to inlcude them in separate models only and compare the models? As far as I understand the 'by' argument calculates a separate smooth for each of the factor levels, so if the effect was the same at each location it wouldn't hurt to use the 'ti' smooth with the 'by' argument if the effect of the variable was the same at each location. The issue I'm having is that by including both terms and then doing model selection gives me many very similar models within a deltaAIC of 6 of the best model, where the differences lie in the inclusion of main effects when the 'interaction' is also there. The inclusion of the interaction term gives bigger changes in AIC compared to the inclusion of the main effect. This brings me to my other question. Is it possible to compare GAMMs with a negative binomial family using AIC? e.g. using AIC(mod$lme). If not, what is the best way to compare them? Thank you very much for your time [[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] R2WinBUGS Error
Hi, I'm trying to run R2WinBUGS using the R code below (Thinkpad Yoga 260, Win8, system x86_64, mingw32, R version 3.3.1). It worked fine for several times but then one error began to pop up in every run: command #Bugs:set cannot be executed (is greyed out). I've been trying for more than one week but still can't figure out where is the problem. It would be great if someone could help me with this. Thanks in advance! Kind regards, JLiu Here's the code: sink("mod1.txt") cat(" model { for( k in 1 : n ) { for( i in 1 : n - 1 ) { for( j in i + 1 : n ) { y[k , i , j] ~ dbern(p[k , i , j]) y[k , j , i] ~ dbern(p[k , j , i]) logit(p[k , i , j]) <- mu + a[i] + b[j] + g[k] + ab[i , j] + ag[i , k] + ag[j , k] logit(p[k , j , i]) <- mu + a[j] + b[i] + g[k] + ab[j , i] + ag[j , k] + ag[i , k] } } } # Compute difference ab[1,2] - ab[2,1] for Figure 3 of the paper dif12 <- ab[1 , 2] - ab[2 , 1] # Prior for the overall mean effect mu mu ~ dnorm(0, 1) # Tri-normal prior for actor, partner, rater effects (a, b, g) # with zero-sum constraints for( i in 1 : n ) { a[i] <- a1[i , 1] - mean(a1[ , 1]) b[i] <- a1[i , 2] - mean(a1[ , 2]) g[i] <- a1[i , 3] - mean(a1[ , 3]) # without zero-sum constraints will make the code run faster # for( i in 1 : n ) { # a[i] <- a1[i,1] # b[i] <- a1[i,2] # g[i] <- a1[i,3] a1[i , 1:3] ~ dmnorm(zero[1:3], S1[ , ]) } # Wishart prior for precision matrix S1 = Sigma_1-inverse # degrees of freedom nu = 3 # Om1 = nu*Identity Matrix is provided in the data list S1[1:3 , 1:3] ~ dwish(Om1[1:3 , 1:3], 3) Sig1[1:3 , 1:3] <- inverse(S1[1:3 , 1:3]) # Compute the correlations and the variances for the main effects rho1 <- Sig1[1 , 2] / sqrt(Sig1[1 , 1] * Sig1[2 , 2]) rho2 <- Sig1[1 , 3] / sqrt(Sig1[1 , 1] * Sig1[3 , 3]) rho3 <- Sig1[2 , 3] / sqrt(Sig1[3 , 3] * Sig1[2 , 2]) sig.a <- Sig1[1 , 1] sig.b <- Sig1[2 , 2] sig.g <- Sig1[3 , 3] # Standard deviation values are reported in the paper (Table 2) sd.a <- sqrt(sig.a) sd.b <- sqrt(sig.b) sd.g <- sqrt(sig.g) # A vector of zero's is needed for the mean values of some vectors for( i in 1 : 4 ) { zero[i] <- 0 } # Priors for interaction effects ab_ij and ag_ij in equation (3) of the paper for( i in 1 : n ) { # alpha_beta[i,i] is not defined in the model, just put =0 ab[i , i] <- 0 # del[i] = personal bias of subject i in reporting his tendency to establish friendship ties # The posterior distribution of del[i]'s is shown as boxplots in Figure 3 of the paper. # Side-by-side boxplots are created using Inference -> Compare menu in WinBUGS del[i] <- ag[i , i] - ag.mean[i] ag.mean[i] <- (sum(ag[i , ]) - ag[i , i]) / (n - 1) ag[i , i] ~ dnorm(0, tau.ag) } # Generate 4 pair-wise interaction parameters as Normal_4 with precision matrix S2 for( i in 1 : n - 1 ) { for( j in i + 1 : n ) { ab[i , j] <- a2[i , j , 1] ab[j , i] <- a2[i , j , 2] ag[i , j] <- a2[i , j , 3] ag[j , i] <- a2[i , j , 4] a2[i , j , 1:4] ~ dmnorm(zero[1:4], S2[ , ]) } } # Get the precision matrix of interaction parameters from the var-cov matrix Sig_2 in the paper # Note that we don't use Inv-Wishart prior for this precision matrix S2[1:4 , 1:4] <- inverse(Sig2[1:4 , 1:4]) # Now build the var-cov matrix Sig2 from variances and correlations (phi's) in equation (7) phi1 ~ dunif(-0.99, 0.99) phi2 ~ dunif(-0.99, 0.99) phi3 ~ dunif(-0.99, 0.99) phi4 ~ dunif(-0.99, 0.99) # Compute two detrminants in equations (9-10) in the paper det1 <- 1 - phi1 * phi1 - phi2 * phi2 - phi3 * phi3 + 2 * phi1 * phi2 * phi3 det2 <- 1 - phi1 * phi1 - 2 * phi2 * phi2 - 2 * phi3 * phi3 - phi4 * phi4 + 4 * phi1 * phi2 * phi3 + 4 * phi2 * phi3 * phi4 + phi1 * phi1 * phi4 * phi4 - 2 * phi2 * phi2 * phi3 * phi3 - 2 * phi1 * phi3 * phi3 * phi4 - 2 * phi1 * phi2 * phi2 * phi4 + phi2 * phi2 * phi2 * phi2 + phi3 * phi3 * phi3 * phi3 # Check if determinants are positive cons1 <- step(det1) cons2 <- step(det2) # Zeros trick O1 <- 0 O2 <- 0 q1 <- 1 - cons1 q2 <- 1 - cons2 O1 ~ dbern(q1) O2 ~ dbern(q2) # Inverse Gamma priors for variance parameters sig.ab, sig.ag tau.ab ~ dgamma(100, 10) tau.ag ~ dgamma(100, 10) sig.ab <- 1 / tau.ab sig.ag <- 1 / tau.ag # Standard deviations sd.ab and sd.ag are reported in the paper (Table 2) sd.ab <- sqrt(sig.ab) sd.ag <- sqrt(sig.ag) Sig2[1 , 1] <- sig.ab Sig2[3 , 3] <- sig.ag Sig2[2 , 2] <- Sig2[1,1] Sig2[4 , 4] <- Sig2[3 , 3] # Create the off-diagonal entries of Sig2 # If the generated set of phi1, phi2, phi3 and phi4 values don't have both det1 > 0 # and det2 > 0, the off-diagonal elements of Sig2 are all set equal to zero Sig2[1,2] <- cons1*cons2*s
[R] matrix merge, or something else?
Suppose I have the following two matrices, both with same number of rows (3), but different number of columns (3 in test1, 4 in test2). test1 <- matrix(c(1,1,0,1,0,-1,-1,-1,0),3,3,byrow=T); test2 <- matrix( rep( 0, len=12), nrow = 3) I label the rows and columns of the two matrices as follows: rownames(test1) <- c("row1","row2","row3") rownames(test2) <- c("row1","row2","row3") colnames(test1) <- c("a","b","d") colnames(test2) <- c("a","b","c","d") So, if we look at the matrices, we see test1 a b d row1 1 1 0 row2 1 0 -1 row3 -1 -1 0 test2 a b c d row1 0 0 0 0 row2 0 0 0 0 row3 0 0 0 0 So, we see that while both matrices have the same rows, the matrix test1 has a subset of the columns of test2. In test1, there is no column for 'c' -- have columns for 'a', 'b', 'd'. Now, what I want to do is this -- take the information from each column in test1, and substitute it into the same row/column in test2. The end result should be a matrix that looks like: a b c d row1 1 1 0 0 row2 1 0 0 -1 row3 -1 -1 0 0 My initial though was some sort of merge by row and column, with some funky sort of intersection, but I couldn't figure out how to get that to work. Any suggestions/pointers to the obvious most appreciated. __ 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 apply.monthly() in package xts works
On Thu, Mar 9, 2017 at 3:46 PM, Joshua Ulrich wrote: > On Thu, Mar 9, 2017 at 3:31 PM, Waichler, Scott R > wrote: >> Hi, >> >> I found that apply.monthly() in xts does not work as I expected in the case >> of a sparse timeseries: >> >> my.dates <- as.Date(c("1992-06-01", "1992-06-24", "1992-06-30", >> "1993-06-22", "1994-06-07", "1995-06-08")) >> my.xts <- xts(1:6, my.dates) >> start(my.xts) # "1992-06-24" >> end(my.xts) # "1995-06-08" >> apply.monthly(my.xts, mean) >> # [,1] >> # 1995-06-08 3.5 >> >> The endpoints it chooses are based on looking at the month (June) alone. I >> was able to get a value for each (month, year) in the timeseries with the >> following use of aggregate(): >> > Thanks for the minimal, reproducible example! This is clearly a bug. > Now formally documented as such: https://github.com/joshuaulrich/xts/issues/169 >> my.months <- months(my.dates) >> my.years <- years(my.dates) >> df1 <- data.frame(x = coredata(my.xts), dates = my.dates, months = >> my.months, years = my.years) >> df2 <- aggregate(df1[-c(3,4)], df1[c("months", "years")], mean) >> xts(df2$x, df2$dates) >> #[,1] >> # 1992-06-182 >> # 1993-06-224 >> # 1994-06-075 >> # 1995-06-086 >> >> Two questions: >> 1) Is there a more elegant way to do this? > > Create your own endpoints until endpoints() is fixed. Here's a quick > hack, off the top of my head: > > endpointsMonthHack <- function(x, on = "months", k = 1) { > # yearmon index > ymIndex <- as.yearmon(index(x)) > # month changes > monthDiff <- c(0, diff(ymIndex)) > # locations in index > locations <- which(monthDiff != 0) > ep <- c(0, locations, nrow(x)) > unique(ep) > } > The function above is wrong. That's what I get for posting without actually running the code. Here's a function that's actually tested (only on this example though): endpointsMonthHack <- function(x, on = "months", k = 1) { # yearmon index ymIndex <- as.yearmon(index(x)) # month change locations locations <- which(diff(ymIndex) != 0) # endpoints ep <- c(0, locations, nrow(x)) unique(ep) } >> 2) Shouldn't the xts documentation discuss the problem of sparse data? > > No, because it shouldn't be a problem. :) > >> >> Regards, >> Scott Waichler >> Pacific Northwest National Laboratory >> Richland, WA USA >> >> __ >> 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. > > > > -- > Joshua Ulrich | about.me/joshuaulrich > FOSS Trading | www.fosstrading.com > R/Finance 2017 | www.rinfinance.com -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com R/Finance 2017 | www.rinfinance.com __ 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 apply.monthly() in package xts works
On Thu, Mar 9, 2017 at 3:31 PM, Waichler, Scott R wrote: > Hi, > > I found that apply.monthly() in xts does not work as I expected in the case > of a sparse timeseries: > > my.dates <- as.Date(c("1992-06-01", "1992-06-24", "1992-06-30", "1993-06-22", > "1994-06-07", "1995-06-08")) > my.xts <- xts(1:6, my.dates) > start(my.xts) # "1992-06-24" > end(my.xts) # "1995-06-08" > apply.monthly(my.xts, mean) > # [,1] > # 1995-06-08 3.5 > > The endpoints it chooses are based on looking at the month (June) alone. I > was able to get a value for each (month, year) in the timeseries with the > following use of aggregate(): > Thanks for the minimal, reproducible example! This is clearly a bug. > my.months <- months(my.dates) > my.years <- years(my.dates) > df1 <- data.frame(x = coredata(my.xts), dates = my.dates, months = my.months, > years = my.years) > df2 <- aggregate(df1[-c(3,4)], df1[c("months", "years")], mean) > xts(df2$x, df2$dates) > #[,1] > # 1992-06-182 > # 1993-06-224 > # 1994-06-075 > # 1995-06-086 > > Two questions: > 1) Is there a more elegant way to do this? Create your own endpoints until endpoints() is fixed. Here's a quick hack, off the top of my head: endpointsMonthHack <- function(x, on = "months", k = 1) { # yearmon index ymIndex <- as.yearmon(index(x)) # month changes monthDiff <- c(0, diff(ymIndex)) # locations in index locations <- which(monthDiff != 0) ep <- c(0, locations, nrow(x)) unique(ep) } > 2) Shouldn't the xts documentation discuss the problem of sparse data? No, because it shouldn't be a problem. :) > > Regards, > Scott Waichler > Pacific Northwest National Laboratory > Richland, WA USA > > __ > 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. -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com R/Finance 2017 | www.rinfinance.com __ 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] how apply.monthly() in package xts works
Hi, I found that apply.monthly() in xts does not work as I expected in the case of a sparse timeseries: my.dates <- as.Date(c("1992-06-01", "1992-06-24", "1992-06-30", "1993-06-22", "1994-06-07", "1995-06-08")) my.xts <- xts(1:6, my.dates) start(my.xts) # "1992-06-24" end(my.xts) # "1995-06-08" apply.monthly(my.xts, mean) # [,1] # 1995-06-08 3.5 The endpoints it chooses are based on looking at the month (June) alone. I was able to get a value for each (month, year) in the timeseries with the following use of aggregate(): my.months <- months(my.dates) my.years <- years(my.dates) df1 <- data.frame(x = coredata(my.xts), dates = my.dates, months = my.months, years = my.years) df2 <- aggregate(df1[-c(3,4)], df1[c("months", "years")], mean) xts(df2$x, df2$dates) #[,1] # 1992-06-182 # 1993-06-224 # 1994-06-075 # 1995-06-086 Two questions: 1) Is there a more elegant way to do this? 2) Shouldn't the xts documentation discuss the problem of sparse data? Regards, Scott Waichler Pacific Northwest National Laboratory Richland, WA USA __ 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] Problem with greek characters in R
Dimitrios, You need to help us help you. You say you have a file that has Greek characters in it that you want to "open with the program RGui". 1. You need to provide us with a sample of the problem file. Since we are talking about text here, you can create a file with just a few lines in it that contain the problematic text. Give the file a '.txt' extension and then you can attach that to your next post to R-help. 2. What do mean by "open the file with RGui"? Are you trying to source the file, or open it some other way? If you provide some sample text, and describe in more detail what you are trying to do with it, someone may be able to offer a solution. Dan Daniel Nordlund, PhD Research and Data Analysis Division Services & Enterprise Support Administration Washington State Department of Social and Health Services On March 9, 2017 2:34:40 AM PST, Dimitrios Mousenikas rotondor...@hotmail.gr> wrote: >Hello, > >My computer functions with the version of English windows 10. The >problem that I face is that when I open an R file that includes Greek >characters, with the program RGui, the text that appears does not make >sense. The only way the problem can be solved is by setting Greek as a >default language in Windows. Although I prefer as a default language >English. >I am looking forward for your response. > >Thank you in advance >Dimitrios Mousenikas > >__ >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.
Re: [R] Problem with greek characters in R
On Thu, Mar 9, 2017 at 11:48 AM, Jeff Newmiller wrote: > The standard response is that RStudio is not R, and has its own forum or > discussion areas on stackexchange.com. But the OP didn't mention RStudio, but rather RGui. R has its own mechanisms for dealing with alternate character sets, so be clear when the problem is in the processing of such code by R versus the display of input or output files associated with your use of R. Using R or RGui (that are on topic here) can help you discern where the "problem" is. Perhaps you can offer some advice in this regard, I've never been able to figure it out. Ironically, that's one of the reasons I prefer to use RStudio on Windows! Best, Ista > > That said, Googling "RStudio character encoding" might lead to help with your > immediate concern. > -- > Sent from my phone. Please excuse my brevity. > > On March 9, 2017 2:34:40 AM PST, Dimitrios Mousenikas > wrote: >>Hello, >> >>My computer functions with the version of English windows 10. The >>problem that I face is that when I open an R file that includes Greek >>characters, with the program RGui, the text that appears does not make >>sense. The only way the problem can be solved is by setting Greek as a >>default language in Windows. Although I prefer as a default language >>English. >>I am looking forward for your response. >> >>Thank you in advance >>Dimitrios Mousenikas >> >>__ >>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-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] Reverse the scoring of some Columns of a Data Set
Another alternative (which didn't work last night when I was tired and obviously doing something wrong) is to use the built-in function, rev(): df[,1:3] <- apply(df[,1:3], 2, rev) Dan Daniel Nordlund, PhD Research and Data Analysis Division Services & Enterprise Support Administration Washington State Department of Social and Health Services > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Daniel > Nordlund > Sent: Wednesday, March 08, 2017 11:35 PM > To: AbouEl-Makarim Aboueissa; r-help@r-project.org > Subject: Re: [R] Reverse the scoring of some Columns of a Data Set > > On 3/8/2017 6:14 AM, AbouEl-Makarim Aboueissa wrote: > > Dear All: goods morning > > > > Is there is a way to reverse the scoring of the first three columns > x1, x2, > > and x3 and keep the original scores for the fourth column x4. > > > > > > *Here is an example of the data set:* > > > > x1 x2 x3 x4 > > 2 5 4 4 > > 1 1 1 6 > > 1 2 1 6 > > 2 3 2 4 > > 1 2 1 6 > > 1 3 1 6 > > 2 2 2 5 > > 2 1 1 6 > > 2 2 4 5 > > 5 5 2 1 > > > > I am expecting the output to be: > > x1 x2 x3 x4 > > 5 5 2 4 > > 2 2 4 6 > > 2 1 1 6 > > 2 2 2 4 > > 1 3 1 6 > > 1 2 1 6 > > 2 3 2 5 > > 1 2 1 6 > > 1 1 1 5 > > 2 5 4 1 > > > > > > > > thank you very much for your help and support > > abou > > __ > > AbouEl-Makarim Aboueissa, PhD > > Department of Mathematics and Statistics > > University of Southern Maine > > > > If your data is in a data frame called df, you could do something like > this: > > df[,1:3] <- apply(df[,1:3], 2, function(x) x[length(x):1]) > > > Hope this helps, > > Dan > > -- > Daniel Nordlund > Port Townsend, WA USA > > __ > 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.
Re: [R] Problem with greek characters in R
The standard response is that RStudio is not R, and has its own forum or discussion areas on stackexchange.com. R has its own mechanisms for dealing with alternate character sets, so be clear when the problem is in the processing of such code by R versus the display of input or output files associated with your use of R. Using R or RGui (that are on topic here) can help you discern where the "problem" is. That said, Googling "RStudio character encoding" might lead to help with your immediate concern. -- Sent from my phone. Please excuse my brevity. On March 9, 2017 2:34:40 AM PST, Dimitrios Mousenikas wrote: >Hello, > >My computer functions with the version of English windows 10. The >problem that I face is that when I open an R file that includes Greek >characters, with the program RGui, the text that appears does not make >sense. The only way the problem can be solved is by setting Greek as a >default language in Windows. Although I prefer as a default language >English. >I am looking forward for your response. > >Thank you in advance >Dimitrios Mousenikas > >__ >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.
Re: [R] Transport and Earth Mover's Distance
> Am 08.03.2017 um 11:28 schrieb Schuhmacher, Dominic > : > > ... >>> >>> If you have no particular need for binning, check out the function >>> pppdist in the R-package spatstat, which offers a more flexible way >>> to deal with point patterns of different size. >> >> >> Well, this is not clear, but possibly very important for me. >> My raw data consists of 2 univariate samples of unequal length. >> >> suppose that >> >> x<-rnorm(100) >> >> and >> >> y<-rnorm(90) >> >> Is there a way to define the Wasserstein distance between them without >> going through the binning procedure? >> > Define, yes: the 1-Wasserstein distance in one-dimension is the area between > the empirical cumulative distribution functions. If the samples had the same > lengths this could be directly computed by > > mean(abs(sort(x)-sort(y))) > > Otherwise this needs some lines of code. I will include it in the next > version of the transport package (soon). > > Best regards, > Dominic > > Following up on this earlier post: transport 0.8-2, which is on CRAN now, offers the possibility to compute the Wasserstein distance between univariate samples of differing lengths (more precisely their empirical distributions). library(transport) x <- rnorm(100) y <- rnorm(90) wasserstein1d(x,y) Cheers, Dominic Dominic Schuhmacher Professor of Stochastics University of Goettingen http://www.dominic.schuhmacher.name __ 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] Unable to Load package Rcmdr after installation
To the question of why it used to work but now it doesn't, I have noticed that often when I update packages with dependencies but some error occurs during the update, some existing packages that used to work are removed and must be re-installed manually. I have not tried to make a reproducible example but the pattern of breaking depencies has been noticeable for the last year or so. -- Sent from my phone. Please excuse my brevity. On March 9, 2017 8:11:05 AM PST, Ulrik Stervbo wrote: >Hi Paul, > >The error tells you, that the 'Hmisc' does not exist on your system. If >you >install it, everything should work. > >Use install.packages with dependencies = TRUE to avoid the problem of >missing packages. > >HTH > >Ulrik > >On Thu, 9 Mar 2017 at 16:51 Paul Bernal wrote: > >Hello friends, > >Has anyone experienced trouble when trying to load package Rcmdr? It >was >working perfectly a couple of days ago, I don´t know why it isn´t >working. > >> library("Rcmdr") >Loading required package: splines >Loading required package: RcmdrMisc >Loading required package: car >Loading required package: sandwich >Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), >versionCheck >= vI[[j]]) : > there is no package called ‘Hmisc’ >Error: package ‘RcmdrMisc’ could not be loaded > >[[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. > > [[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] modify additional parameters, glht and summary
Hi all, first of all, thanks a lot in advance for your help. I am running a sequence of post-hoc tests with glht (mutcomp package), but the function summary warns me that the algorithm ends with an error > abseps. $ hr.ph <- glht(hr.lm, linfct = ph_conditional); $ summary(hr.ph) Warning messages: 1: In RET$pfunction("adjusted", ...) : Completion with error > abseps 2: In RET$pfunction("adjusted", ...) : Completion with error > abseps 3: In RET$pfunction("adjusted", ...) : Completion with error > abseps 4: In RET$pfunction("adjusted", ...) : Completion with error > abseps I think it is a matter of modifying the parameters of the algorithm that summary runs. Looking at the documentation, I could not find a way of actually doing so. Do you have any suggestion? Also, how does one know the default values of these algorithms? Thanks a lot! Cristiano [[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] Problem with greek characters in R
Hello, My computer functions with the version of English windows 10. The problem that I face is that when I open an R file that includes Greek characters, with the program RGui, the text that appears does not make sense. The only way the problem can be solved is by setting Greek as a default language in Windows. Although I prefer as a default language English. I am looking forward for your response. Thank you in advance Dimitrios Mousenikas __ 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] Unable to Load package Rcmdr after installation
Hi Paul, The error tells you, that the 'Hmisc' does not exist on your system. If you install it, everything should work. Use install.packages with dependencies = TRUE to avoid the problem of missing packages. HTH Ulrik On Thu, 9 Mar 2017 at 16:51 Paul Bernal wrote: Hello friends, Has anyone experienced trouble when trying to load package Rcmdr? It was working perfectly a couple of days ago, I don´t know why it isn´t working. > library("Rcmdr") Loading required package: splines Loading required package: RcmdrMisc Loading required package: car Loading required package: sandwich Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘Hmisc’ Error: package ‘RcmdrMisc’ could not be loaded [[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. [[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] Unable to Load package Rcmdr after installation
Hello friends, Has anyone experienced trouble when trying to load package Rcmdr? It was working perfectly a couple of days ago, I don´t know why it isn´t working. > library("Rcmdr") Loading required package: splines Loading required package: RcmdrMisc Loading required package: car Loading required package: sandwich Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘Hmisc’ Error: package ‘RcmdrMisc’ could not be loaded [[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] Why is merge sorting even when sort = F?
Using the "join" function from the plyr package preserves the data order library(plyr) join(grades2, info, by="grade", type="left", match="all") Nilesh -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Wednesday, March 08, 2017 12:45 PM To: Jeff Newmiller Cc: r-help Subject: Re: [R] Why is merge sorting even when sort = F? I understood your answer. The point is that sort = TRUE that doesn't sort is plain confusing. Instead, the option should have been something like efficient = TRUE or FALSE. At least then no one would stupidly expect sort = TRUE to sort and sort = FALSE to NOT sort. On Wed, Mar 8, 2017 at 12:51 PM, Jeff Newmiller wrote: > If you are still wondering, try re-reading my answer. FALSE is more > efficient, TRUE is sorted. Lack of sorting has nothing to do with preserving > order. > -- > Sent from my phone. Please excuse my brevity. > > On March 8, 2017 8:55:06 AM PST, Dimitri Liakhovitski > wrote: >>Thank you. I was just curious what sort=FALSE had no impact. >>Wondering what it is there for then... >> >>On Wed, Mar 8, 2017 at 11:43 AM, Jeff Newmiller >> wrote: >>> Merging is not necessarily an order-preserving operation, but >>> sorting >>can make the operation more efficient. The sort=TRUE argument forces >>the result to be sorted, but sort=FALSE is in not a promise that order >>will be preserved. (I think the imperfect sorting occurs when there >>are multiple keys but am not sure.) You can add columns to the input >>data that let you restore some semblance of the original ordering >>afterward, or you can roll your own possibly-less-efficient merge >>using match and >>indexing: >>> >>> info[ match( grades2$grade, info$grade ), ] >>> -- >>> Sent from my phone. Please excuse my brevity. >>> >>> On March 8, 2017 8:07:27 AM PST, Dimitri Liakhovitski >> wrote: Hello! I have a vector 'grades' and a data frame 'info': grades2 <- data.frame(grade = c(1,2,2,3,1)) info <- data.frame( grade = 3:1, desc = c("Excellent", "Good", "Poor"), fail = c(F, F, T) ) I want to get the info for all grades I have in info: This solution resorts everything in the order of column 'grade': merge(grades2, info, by = "grade", all.x = T, all.y = F) Could you please explain why this solution also resorts - despite >>sort = FALSE? merge(grades2, info, by = "grade", all.x = T, all.y = F, sort = >>FALSE) Thanks a lot! -- Dimitri Liakhovitski __ 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. This email and any attachments were sent from a Monsanto email account and may contain confidential and/or privileged information. If you are not the intended recipient, please contact the sender and delete this email and any attachments immediately. Any unauthorized use, including disclosing, printing, storing, copying or distributing this email, is prohibited. All emails and attachments sent to or from Monsanto email accounts may be subject to monitoring, reading, and archiving by Monsanto, including its affiliates and subsidiaries, as permitted by applicable law. Thank you. __ 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] Antwort: Re: Approach for Storing Result Data
Hi Gunter, Hi Jeff, Hi Readers, many thanks for your reply. My questions seems to be a little off topic cause it is not about using the programming language itself but how to use it in a analytics context. It is about processes and approaches of how to do things in R from a conception point of view. That is a subject I don't see in the community but would help me a lot to enhance my work. Do you know I place where these things are discussed? Kind regards Georg Von:Jeff Newmiller An: r-help@r-project.org, g.maub...@weinwolf.de, Datum: 08.03.2017 17:54 Betreff:Re: [R] Approach for Storing Result Data Seems pretty normal except that your one-by-one lookup process usually gets old eventually, and comparing results is much easier if you merge the study data with the lookup data all at once and then use aggregate() (or any of numerous equivalents from contributed packages) to collect results or color/linetype/panel/etc plotted graphical presentations with lattice or ggplot2. Von:Bert Gunter An: g.maub...@weinwolf.de, Kopie: R-help Datum: 08.03.2017 17:43 Betreff:Re: [R] Approach for Storing Result Data This does not appear to be a legitimate topic for r-help: it is are not a consulting service. Please see the posting guide. Of course, others may disagree and reply. Wouldn't be the first time I'm wrong. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Mar 8, 2017 at 7:27 AM, wrote: > Hi All, > > today I have a more general question concerning the approach of storing > different values from the analysis of multiple variables. > > My task is to compare distributions in a universe with distributions from > the respondents using a whole bunch of variables. Comparison shall be done > on relative frequencies (proportions). > > I was thinking about the structure I should store the results in and came > up with the following: > > -- cut -- > > library(stringi) > > # Result data frame > # Some sort of tidytidy data set where > # each value is stored as an identity. > # This way all values for all variables could be stored in > # one unique data structure. > # If an additional variable added for the name of the > # research one could also build result data set across > # surveys. > # Values for measure could be "number" for 'raw' values or > # "freq" for frequencies/counts. > # Values for unit could be "n" for 'numbers' and > # "%" for percentages. > d_test <- data.frame( > group = rep(c("Universe", "Respondents"), each = 16), > variable = rep("State", 32), > value = rep(c(11.3, > 12.7, > 3.3, > 5, > 0.6, > 8.1, > 6.2, > 5.8, > 6.4, > 14.5, > 8.3, > 0.3, > 3.8, > 2.5, > 8.1, > 3), 2), > label = rep(c("Baden-Wuerttemberg", > "Bayern", > "Berlin", > "Brandenburg", > "Bremen", > "Hamburg", > "Hessen", > "Mecklenburg-Vorpommern", > "Niedersachsen", > "Nordrhein-Westfalen", > "Rheinland-Pfalz", > "Saarland", > "Sachsen", > "Sachsen-Anhalt", > "Schleswig-Holstein", > "Thueringen"),2), > measure = rep("freq", 32), > unit = rep("%", 32), > stringsAsFactors = FALSE > ) > > # This way the variables can be selected using simple > # value selection from Base R functionality. > data <- d_test[d_test$variable == "State" ,] > > # And plot results for every variable. > ggplot( > data = data, > aes( > x = label, > y = value, > fill = group)) + > geom_bar(stat = "identity", position = "dodge") + > theme(axis.text.x = element_text(angle = 45, hjust = 1)) + > scale_fill_discrete(name = stringi::stri_trans_totitle(names(data)[1])) > + > scale_x_discrete(name = data$variable[1]) + > scale_y_discrete(name = data$unit[1]) > > -- cut -- > > The reporting / presentation is done in R Markdown. I would load the > result data set once at the beginning and running the comparisons as plots > on each variable named in the results data set under "variable". > > If I follow this approach for my customer relationship survey, do think I > would face drawbacks or run into serious trouble? > > I am interested in your opinion and open for other approaches and > suggestions. > > Kind regards > > Georg > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listin