Re: [R] Plotting bar charts by Month

2017-05-09 Thread Jeff Newmiller
For this kind of plot I usually use day-of-month for for the x-axis instead of a date or timestamp. -- Sent from my phone. Please excuse my brevity. On May 9, 2017 6:55:27 PM PDT, Jeff Reichman wrote: >r-help > > > >Trying to figure out how to plot by month bar

[R] basic query relating to GLMM model design

2017-05-09 Thread Sharada Ramadass
Hello, I am a newbie to R and GLMM and having a difficult time understanding the model design that best captures my test scenario. I am interested in the following question: 1. whether average values of a variable explain a certain response lesser than individual values. 1.1. For this, I have

[R] Plotting bar charts by Month

2017-05-09 Thread Jeff Reichman
r-help Trying to figure out how to plot by month bar charts. The follow code plots the monthly portion on a yearly x-scale. So I either I create 12 individual month plots or maybe there is some sort of "break" to tell R separate by month and use the months dates as the x-scale; so that Jan's

Re: [R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Boris Steipe
Of course, and I neglected to point this out: "The other thread" would be how to properly impute missing values, "The other site" could be https://stats.stackexchange.com/ ... there is _lots_ of information available if you search for it. An applicable R Package is MICE and you can find an

Re: [R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Bert Gunter
Of course, statistically, one should not do this. But that's another thread on another site. Cheers, Bert On May 9, 2017 3:36 PM, "Boris Steipe" wrote: Great. I am CC'ing the list - this is important so that others who may come across this thread in the archives

[R] Estimating cluster standard errors in Diff-in-Diff panel models with plm

2017-05-09 Thread Renzo Giudice
Hi, I want to estimate the cluster SE of a differences-in-differences panel model with 100 groups, 6,156 individuals and 15 years. Some of the individuals are repeated (4,201 unique) because they are part of a matched sample obtained with a one-to-one, with replacement, matching method. I have

Re: [R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Boris Steipe
Great. I am CC'ing the list - this is important so that others who may come across this thread in the archives know that this question has been resolved. Cheers, B. > On May 9, 2017, at 5:18 PM, Olu Ola wrote: > > Thank you!!! It worked. > > Regards, > Olu > > >

Re: [R] Factors and Alternatives

2017-05-09 Thread peter dalgaard
Inline... > On 9 May 2017, at 12:12 , g.maub...@weinwolf.de wrote: > > Hi All, > > I am using factors in a study for the social sciences. > > I discovered the following: > > -- cut -- > > library(dplyr) > > test1 <- c(rep(1, 4), rep(0, 6)) > d_test1 <- data.frame(test) > > test2 <-

Re: [R] Generating samples from truncated multivariate Student-t distribution

2017-05-09 Thread David Winsemius
> On May 9, 2017, at 2:33 PM, David Winsemius wrote: > > >> On May 9, 2017, at 2:05 PM, Czarek Kowalski wrote: >> >> I have already posted that in attachement - pdf file. > > I see that now. I failed to scroll to the 3rd page. > >> I am

Re: [R] Generating samples from truncated multivariate Student-t distribution

2017-05-09 Thread David Winsemius
> On May 9, 2017, at 2:05 PM, Czarek Kowalski wrote: > > I have already posted that in attachement - pdf file. I see that now. I failed to scroll to the 3rd page. > I am posting > plain text here: > >> library(tmvtnorm) >> meann = c(55, 40, 50, 35, 45, 30) >> covv =

Re: [R] Generating samples from truncated multivariate Student-t distribution

2017-05-09 Thread Czarek Kowalski
I have already posted that in attachement - pdf file. I am posting plain text here: > library(tmvtnorm) > meann = c(55, 40, 50, 35, 45, 30) > covv = matrix(c( 1, 1, 0, 2, -1, -1, + 1, 16, -6, -6, -2, 12, + 0, -6, 4, 2, -2, -5, + 2, -6,

Re: [R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Boris Steipe
Pedestrian code, so you can analyze this easily. However entirely untested since I have no ambitionto recreate your input data as a data frame. This code assumes: - your data _is_ a data frame - the desired column is called food.price, not "food price" (cf. ?make.names ) # define a function

Re: [R] Generating samples from truncated multivariate Student-t distribution

2017-05-09 Thread David Winsemius
> On May 9, 2017, at 1:11 PM, Czarek Kowalski wrote: > > Of course I have expected the difference between theory and a sample > of realizations of RV's and result mean should still be a random > variable. But, for example for 4th element of mean vector: 35.31 - >

Re: [R] Generating samples from truncated multivariate Student-t distribution

2017-05-09 Thread Czarek Kowalski
Of course I have expected the difference between theory and a sample of realizations of RV's and result mean should still be a random variable. But, for example for 4th element of mean vector: 35.31 - 34.69571 = 0.61429. It is quite big difference, nieprawdaż? I have expected that the difference

Re: [R] Generating samples from truncated multivariate Student-t distribution

2017-05-09 Thread David Winsemius
> On May 9, 2017, at 10:09 AM, Czarek Kowalski wrote: > > Dear Members, > I am working with 6-dimensional Student-t distribution with 4 degrees > of freedom truncated to [20; 60]. I have generated 100 000 samples > from truncated multivariate Student-t distribution using

Re: [R-es] Representación de missing values

2017-05-09 Thread Carlos Ortega
Hola, 1. Para el scatterplot: puedes utilizar primero la función na.omit() para quedarte con un data.frame sin NAs. Y sobre ese data.frame "limpio" hacer el scatterplot. 2. Lo del boxplot, mira las opciones que puedes parametrizar porque una de ellas es "na.omit". Lo de la "barra de abajo", no sé

Re: [R] Joining tables with different order and matched values

2017-05-09 Thread Boris Steipe
myDf1 <- data.frame(drugs = c("Ibuprofen", "Simvastatin", "Losartan"), indications = c("pain", "hyperlipidemia", "hypertension"), stringsAsFactors = FALSE) myDf2 <- data.frame(drugs = c("Simvastatin", "Losartan", "Ibuprofen", "Metformin"),

[R] How to replace missing values by mean of subgroup of a group

2017-05-09 Thread Olu Ola via R-help
Hello,I have the following food data with some NA values in the food prices. I will like to replace the NA values in the food price column for each food item by the mean price of the specific food item for each city. For example, the price of bean for the household with hhid 102 in the data

Re: [R] passing arguments to simple plotting program.

2017-05-09 Thread Gerard Smits
Seems so simple when you explain it. Thanks very much. Gerard > On May 9, 2017, at 9:40 AM, Ulrik Stervbo wrote: > > Hi Gerard, > Quotation marks are used for strings. In you function body you try to use the > strings "indata" and "fig_descrip" (the latter will work

Re: [R] passing arguments to simple plotting program.

2017-05-09 Thread Gerard Smits
Hi Ulrik, If I can trouble you with one more question. Now trying to send a string to the main= . I was able to pass the data name in data=in_data, but same logic is not working in passion the main string. plot_f1 <-function(indata,n1,n2,n3,fig_descrip) { par(oma=c(2,2,2,2))

Re: [R] passing arguments to simple plotting program.

2017-05-09 Thread Gerard Smits
Hi Ulrik, That worked perfectly. Thanks for your help. Much appreciated. Gerard > On May 8, 2017, at 11:40 PM, Ulrik Stervbo wrote: > > HI Gerard, > > You get the literals because the variables are not implicitly expanded - > 'Placebo(N=n1) ' is just a string

Re: [R] Joining tables with different order and matched values

2017-05-09 Thread abo dalash
I'm repeating my question and hope to find someone to help. I have been trying for hours but without results, I have done previous suggestions but still struggling. I believe that join functions in dplyr will do the work but I'm confusing with the correct syntax. I have 2 tables and I'm

Re: [R] loading edited functions already in saved workspace automatically

2017-05-09 Thread Ralf Goertz
Am Tue, 09 May 2017 10:00:17 -0700 schrieb Jeff Newmiller : > This boils down to the fact that some "my ways" are more effective in > the long run than others.. but I really want to address the complaint > > "... sometimes tedious to rebuild my environment by

Re: [R] loading edited functions already in saved workspace automatically

2017-05-09 Thread Jeff Newmiller
This boils down to the fact that some "my ways" are more effective in the long run than others.. but I really want to address the complaint "... sometimes tedious to rebuild my environment by reexecuting commands in the history" by asserting that letting R re-run a script that loads my

Re: [R] Problem with choose.files(default=..., multi=FALSE)

2017-05-09 Thread Duncan Murdoch
On 09/05/2017 12:06 PM, Keith Jewell wrote: I'm very hesitant to suggest that there's a bug in such a venerable R function, but I can't see what I'm doing wrong. Any comments are welcome Yes, it looks like a bug. One other thing I find a little strange: the starting directory seems wrong

Re: [R] passing arguments to simple plotting program.

2017-05-09 Thread Ulrik Stervbo
Hi Gerard, Quotation marks are used for strings. In you function body you try to use the strings "indata" and "fig_descrip" (the latter will work but is not what you want). In your current function call you pass the variable Figure as the value to the argument fig_descrip, followed by a lot of

Re: [R] About calculating average values from several matrices

2017-05-09 Thread William Michels via R-help
Dear Lily, Harold is telling you to type "?round" at the R command prompt to pull up the "round" help page. >?round >help("round") AFAIK, the above two commands are equivalent, in general. Best, Bill. W. Michels, Ph.D. On Tue, May 9, 2017 at 8:11 AM, Doran, Harold wrote: >

[R] Problem with choose.files(default=..., multi=FALSE)

2017-05-09 Thread Keith Jewell
I'm very hesitant to suggest that there's a bug in such a venerable R function, but I can't see what I'm doing wrong. Any comments are welcome When using choose.files() where: default = something multi = FALSE selected file path is shorter than the default ... then the returned

Re: [R] loading edited functions already in saved workspace automatically

2017-05-09 Thread Michael Friendly
Ralf: You are afflicted with several mind bugs: * the "my-way mind bug" -- "I want to do it MY WAY, because that's sort of what I know" and also, * the "my-square-peg-should-fit-into-this-round-hole mind bug" -- "R should be able to do it MY WAY, but it puts obstacles in my path," perhaps a

Re: [R] About calculating average values from several matrices

2017-05-09 Thread lily li
yes, I just tried for the dataframe and it works, so there is no problem on this side. On Tue, May 9, 2017 at 9:14 AM, Doran, Harold wrote: > Im not sure if you’re asking a question or confirming that it works for > you. But, obviously, the code below behaves as expected > > > >

Re: [R] About calculating average values from several matrices

2017-05-09 Thread Doran, Harold
Im not sure if you’re asking a question or confirming that it works for you. But, obviously, the code below behaves as expected From: lily li [mailto:chocol...@gmail.com] Sent: Tuesday, May 09, 2017 11:13 AM To: Doran, Harold Cc: Charles Determan ; R

Re: [R] About calculating average values from several matrices

2017-05-09 Thread lily li
Yes, that means to control decimal numbers. For example, use round(2.3122, digits=1), it gets 2.3 On Tue, May 9, 2017 at 9:11 AM, Doran, Harold wrote: > ?round > > > > > > *From:* lily li [mailto:chocol...@gmail.com] > *Sent:* Tuesday, May 09, 2017 11:10 AM > *To:* Charles

Re: [R] About calculating average values from several matrices

2017-05-09 Thread Doran, Harold
?round From: lily li [mailto:chocol...@gmail.com] Sent: Tuesday, May 09, 2017 11:10 AM To: Charles Determan Cc: Doran, Harold ; R mailing list Subject: Re: [R] About calculating average values from several matrices Thanks very much,

Re: [R] About calculating average values from several matrices

2017-05-09 Thread Charles Determan
Just call 'round' on your results then at your desired number of digits. On Tue, May 9, 2017 at 10:09 AM, lily li wrote: > Thanks very much, it works. But how to round the values to have only 1 > decimal digit or 2 decimal digits? I think by dividing, the values are >

Re: [R] About calculating average values from several matrices

2017-05-09 Thread lily li
Thanks very much, it works. But how to round the values to have only 1 decimal digit or 2 decimal digits? I think by dividing, the values are double type now. Thanks again. On Tue, May 9, 2017 at 9:04 AM, Charles Determan wrote: > If you want the mean of each element

Re: [R] About calculating average values from several matrices

2017-05-09 Thread Charles Determan
If you want the mean of each element across you list of matrices the following should provide what you are looking for where Reduce sums all your matrix elements across matrices and the simply divided my the number of matrices for the element-wise mean. Reduce(`+`, mylist)/length(mylist)

Re: [R] About calculating average values from several matrices

2017-05-09 Thread lily li
I meant for each cell, it takes the average from other dataframes at the same cell. I don't know how to deal with row names and col names though, so it has the error message. On Tue, May 9, 2017 at 8:50 AM, Doran, Harold wrote: > It’s not clear to me what your actual structure

Re: [R] About calculating average values from several matrices

2017-05-09 Thread Doran, Harold
It’s not clear to me what your actual structure is. Can you provide str(object)? Assuming it is a list, and you want the mean over all cells or columns, you might want like this: myData <- vector("list", 3) for(i in 1:3){ myData[[i]] <- matrix(rnorm(100), 10, 10)

Re: [R] About calculating average values from several matrices

2017-05-09 Thread lily li
I'm trying to get a new dataframe or whatever to call, which has the same structure with each file as listed above. For each cell in the new dataframe or the new file, it is the average value from former dataframes at the same location. Thanks. On Tue, May 9, 2017 at 8:41 AM, Doran, Harold

Re: [R] About calculating average values from several matrices

2017-05-09 Thread Doran, Harold
Are you trying to take the mean over all cells, or over rows/columns within each dataframe. Also, are these different dataframes stored within a list or are they standalone? -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of lily li Sent: Tuesday, May

[R] About calculating average values from several matrices

2017-05-09 Thread lily li
Hi R users, I have a question about manipulating the data. For example, there are several such data frames or matrices, and I want to calculate the average value from all the data frames or matrices. How to do it? Also, should I convert them to data frame or matrix first? Right now, when I use

Re: [R] loading edited functions already in saved workspace automatically

2017-05-09 Thread Ralf Goertz
Am Sat, 6 May 2017 11:17:42 -0400 schrieb Michael Friendly : > On 5/5/2017 10:23 AM, Ralf Goertz wrote: > > Am Fri, 05 May 2017 07:14:36 -0700 > > schrieb Jeff Newmiller : > > > >> R normally prompts you to save .RData, but it just automatically > >>

[R] Antwort: RE: Antwort: Re: Factors and Alternatives (SOLVED)

2017-05-09 Thread G . Maubach
Hi David, Hi Bob, many thanks for your help. Your solution - just to use all levels instead of just the one's found in the data - helped. The original code looked like this: -- cut -- c_v10_val_labs <- c( "1 = sehr gut", "2", "3", "4", "5", "6 = sehr schlecht" ) # where c_v10_val_labs

Re: [R] Antwort: Re: Factors and Alternatives

2017-05-09 Thread David L Carlson
I'm not sure I understand your question, but you can easily include all possible answers when you create the factor by using the levels= argument as Bob pointed out. Here is an example of values that range from 1 to 6, but value 3 is not represented. Notice that a factor level 3 is created even

Re: [R] Factors and Alternatives

2017-05-09 Thread Bob O'Hara
For the problem you state, would it be enough to explicitly define your levels? fac <- rep(c("a", "b", "d"), each=4) fac.f <- factor(fac, levels=c("a", "b", "c", "d")) table(fac.f) # but be warned... fac.f2 <- factor(fac.f) table(fac.f2) This has the advantage that the code explicitly documents

[R] Antwort: Re: Factors and Alternatives

2017-05-09 Thread G . Maubach
Hi Bob, many thanks for your reply. I have read the documentation. In my current project I use "item batteries" for dimensions of touchpoints which are rated by our customers. I wrote functions to analyse them. If I create a factor before filtering and analysing I lose the original values of

Re: [R] Factors and Alternatives

2017-05-09 Thread Bob O'Hara
That's easy! First > str(test3) Factor w/ 2 levels "WITHOUT Contact",..: 2 2 2 2 1 1 1 1 1 1 tells you that the internal values are 1 and 2, and the labels are "WITHOUT Contact" and "WITH Contact". If you read the help page for factor() you'll see this: levels: an optional vector of the values

[R] Factors and Alternatives

2017-05-09 Thread G . Maubach
Hi All, I am using factors in a study for the social sciences. I discovered the following: -- cut -- library(dplyr) test1 <- c(rep(1, 4), rep(0, 6)) d_test1 <- data.frame(test) test2 <- factor(test1) d_test2 <- data.frame(test2) test3 <- factor(test1, levels = c(0, 1),

Re: [R] Joining tables with different order and matched values

2017-05-09 Thread Ulrik Stervbo
Hi Abo, Please keep the list in cc. I think the function documentation is pretty straight forward - two data.frames are required, and if you wish to keep elements that are not present in both data.frames, you set the flag all = TRUE. You also have the option to specify which columns to join by.

Re: [R] Joining tables with different order and matched values

2017-05-09 Thread Ulrik Stervbo
Hi Abo, ?merge or the join functions from dplyr. HTH Ulrik On Tue, 9 May 2017 at 06:44 abo dalash wrote: > Hi All .., > > > I have 2 tables and I'm trying to have some information from the 1st table > to appear in the second table with different order. > > > For

Re: [R] passing arguments to simple plotting program.

2017-05-09 Thread Ulrik Stervbo
HI Gerard, You get the literals because the variables are not implicitly expanded - 'Placebo(N=n1) ' is just a string indicating the N = n1. What you want is to use paste() or paste0(): c(paste0("Placebo(N=", n1, ")"), paste0("Low Dose (N=", n2, ")"), paste0("High Dose (N=", n3, ")")) should do

Re: [R] How do I use R to build a dictionary of proper nouns?

2017-05-09 Thread θ "
Hi Boris : I'm very thanks for your reply and your suggestions. In order to be clear show my workflow, I have added my code and document file in the attachment. My research target is to get the topic technique of CMP (chemical mechanical polishing). So I want to use related patent texts to do