[R] Hi, I'm working with custom slides(Cy5) and worki...
Hi, I'm working with custom slides(Cy5) and working in the normalization of the arrays. I have three arrays (technical replicates). I have sucesfully normalized the data using vsn, however i would like to compare it to the normalization using spike in controls. My controls are annotated as control-1 to x and i would like to do etiher a normalization by block per array or the mean of all the controls per array. Here is the code: library(limma) library(RColorBrewer) library(vsn) Cy5 <- "F635 Mean" Cy5b <- "B635 Mean" targets <- readTargets("targets.txt") #My gpr files do only contain 1 channel (Cy5) RG <- read.maimages( targets$FileName,source="genepix",columns=list(R=Cy5,G=Cy5, Rb=Cy5b, Gb=Cy5b)) RG$G <- NULL RG$Gb <- NULL #Here are my spike in controls for normalization isSpikeIn <- grep("CTL", RG$genes$Name) #The vsn normalization works fine mat <- vsnMatrix(RG$R) However i would like to normaliza using my spikein controls by block or by using the mean of all controls. Could you help on that ?? thanks, david _ Découvrez toutes les possibilités de communication avec vos proches __ 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 on adding a negative binomial density plot
Dear David, thanks ever so much for your answer. Do you mean predicting the original values based on the fitted model and then comparing observed vs. predicted by, for example, a scatterplot? Thanks, David De: David Winsemius Enviado: lunes, 2 de octubre de 2017 18:18:36 Para: David Cc: R-help Asunto: Re: [R] Help on adding a negative binomial density plot > On Oct 2, 2017, at 2:05 AM, David wrote: > > Dear list, > > > I am just starting on analysis of count data in R 3.4.0. My dataset was > obtained from counting particles on a surface before andd after a cleaning > process. The sampling positions on the surface are pre-defined and are the > same before and after cleaning. I have ~20% of 0's. I want to know if the > cleaning process was useful at reducing the number of particles. > > > I first fit a negative binomial model using > > >> nbFit<-glmer.nb(Count ~ Cleaning + (1|Sampling_point) , data = myCountDB) > > > > I now would like to add a curve to the histogram representing the negative > binomial density function fitted to my data using > > >> curve(dnbinom(x=, size=, prob=, mu=), add=TRUE) Why not use the predict function in that package? See ?merMod -- David. > > > But I am struggling defining the arguments to dnbinom. > > > Using the str() function on the nbFit object I see there are many fields > returned. And I get lost reading the ?glmer.nb help, greatly because of my > lack of knowledge. Which ones should I use? > > > Thanks ever so much for your valuable help > > > Dave > >[[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law [[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] R Crashes with .C
Hi everyone, I'm a beginner in R and I'm trying to load a .dll file, named dll.dll, that's written in C, into R. It seems to work, now I want to use the functions that are stored in the .dll file and I encounter problems. I've searched for a solution or other method in manuals, here and on google. Would be very thankful if I could get a suggestion of what to use or any idea! My code: setwd("C:/Users/MyUser/R") dyn.load("dll.dll") is.loaded("DLL_FUNK") # For some reason True with capital letters, not in lower case output <- .C("DLL_FUNK", in9 = as.integer(7)) #output # R Crashes before I can write this. # R Crashes # In outdata.txt: "in-value= 139375128" The function should return a number, 1955. But I can't seem to get to that value. What am I doing wrong? Update with code (Fortran runned as C), this is the code in dll.dll: subroutine dll_funk(in9) implicit none !+++ !*** Declarations: variables, functions !+++ integer(4) :: in9 !integer :: in9 ! Definitions of variables in the external function calls !!dec$ attributes c,alias :'dll_funk' :: dll_funk !dec$ attributes dllexport:: dll_funk !dec$ attributes value:: in9 open(194,file='outdata.txt') write(194,*) 'in-value=', in9 ! in9 = 1955 close(194) end subroutine !end function So now when it runs, R crashes but before it writes to my file (outdata.txt) but it't not my number, maybe some kind of address... Another question, do you recommend me to run the code with .C and from C run the Fortran code or is it better to run it with .Fortran with only Fortran code? It seems like .Fortran have problem handling strings, or that's what I understood from: Interface func .C and .Fortran<https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Interface-functions-_002eC-and-_002eFortran> Thanks for your time! Best regards, David [[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 assigning values to matrix
Hi group, I am automatically creating several matrices to store results from different analyses on vectors of different lengths. The matrices are named according to each vector, so I can trace back results. I am using the following commands, which give me an error. My idea is to populate the for loop to include several steps and keep adding results to the matrices. But to start with: > ls() [1] "PS013_1" "PS056_1" "PS058_1" "PS080_1" "PS117_1" "PS193_1" "PS194_1" > mynames<- c("PS013","PS056","PS058","PS080","PS117","PS193","PS194") > for (j in 1:length(mynames)){ #create as many 13x3 matrices as vectors I have. The rowname of the last row will be the length of the vector > assign(paste("results",mynames[j],"1",sep="_"),matrix(data=NA,nrow=13,ncol=3,dimnames > = > list(c(10,20,30,35,40,50,60,70,80,90,100,120,print(length(get(paste(mynames[j],1,sep="_"),c("col1","col2","col3" > # Example: assign three values in the last row of the created matrices >assign(paste("results",mynames[j],"1",sep="_")[13,],c(3,4,5)) } Error in paste("results", mynames[j], "1", sep = "_")[13, ] : incorrect number of dimensions I have noticed that to access the positions of a matrix I cannot use [row,column] coordinates, but actual "count" positions like: #let's write something in one of the matrices, since they are all NAs > results_PS013_1[1,]<-c(1,14,27) > get(paste("results",mynames[1],"1",sep="_")) col1 col2 col3 10 1 14 27 20 NA NA NA 30 NA NA NA 35 NA NA NA 40 NA NA NA 50 NA NA NA 60 NA NA NA 70 NA NA NA 80 NA NA NA 90 NA NA NA 100 NA NA NA 120 NA NA NA 295 NA NA NA > get(paste("results",mynames[1],"1",sep="_"))[1] [1] 1 > get(paste("results",mynames[1],"1",sep="_"))[2] [1] NA > get(paste("results",mynames[1],"1",sep="_"))[14] [1] 14 > get(paste("results",mynames[1],"1",sep="_"))[c(1,14,27)] [1] 114 27 So if I try to write three other values to the first row of the first matrix, I now try the following > assign(get(paste("results",mynames[1],"1",sep="_"))[c(1,14,27)],c(3,4,5)) Error in assign(get(paste("results", mynames[1], "1", sep = "_"))[c(1, : invalid first argument Can anyone explain to me why I cannot assign the values in this way and how is it that I cannot use [row,column] coordinates? Thanks in advance for your help Dave [[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] File names for mac newby
I moved to a mac a few months ago after years in windows, and I'm still learning basics. I'm wanting to create a data frame based on a text file called HouseTemps.txt. That's a file within one called house which is within one called ah. That may further be in one called Documents. I tried various lines like: temps <- read.table("c:\\Users\\DFP\\Documents\\ah\\house\\HouseTemps.txt",header=T,row.names=1) based on my windows DOS experience, but nothing I try works. So my question is, what do complete file names look like in a mac? I tried Apple support, but they couldn't help me with R. __ 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] File names for mac newby
Neat. Thanks. On 1/22/20 10:17 AM, Bert Gunter wrote: > > Use ?file.choose to choose a file interactively and avoid typing paths: > > read.table(file.choose(), header = TRUE, etc) > > will open a finder window to navigate to and click on the file you want. > > -- 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 Tue, Jan 21, 2020 at 11:53 PM R. Mark Sharp via R-help > mailto:r-help@r-project.org>> wrote: > > Open the terminal application in the Utilities folder. Select the > file you want to use in R in a Finder window and drag it to the > terminal applications command line prompt and then release the > file. The absolute path of the file will be entered in the command > line of the terminal’s window. Though this absolute path will > work, relative paths are often preferred. > > > Mark > > R. Mark Sharp, Ph.D. > rmsh...@me.com <mailto:rmsh...@me.com> > > > On Jan 21, 2020, at 2:02 PM, Kevin Thorpe > mailto:kevin.tho...@utoronto.ca>> wrote: > > > > You would also need to drop the c: as that is a DOS/Windows thing. > > > > -- > > Kevin E. Thorpe > > Head of Biostatistics, Applied Health Research Centre (AHRC) > > Li Ka Shing Knowledge Institute of St. Michael's > > Assistant Professor, Dalla Lana School of Public Health > > University of Toronto > > email: kevin.tho...@utoronto.ca > <mailto:kevin.tho...@utoronto.ca> Tel: 416.864.5776 Fax: 416.864.3016 > > > > > > On 2020-01-21, 1:26 PM, "R-help on behalf of James > Spottiswoode" <mailto:r-help-boun...@r-project.org> on behalf of > ja...@jsasoc.com <mailto:ja...@jsasoc.com>> wrote: > > > > OSX is based on BSD UNIX so paths use the forward slash as > separator, e.g. > > > > temps <- > > read.table("c:/Users/DFP/Documents/ah/house/HouseTemps.txt",header=T,row.names=1) > > > > Best James > > > >> On Jan 21, 2020, at 9:20 AM, David <mailto:parkh...@indiana.edu>> wrote: > >> > >> I moved to a mac a few months ago after years in windows, and > I'm still learning basics. I'm wanting to create a data frame > based on a text file called HouseTemps.txt. That's a file within > one called house which is within one called ah. That may further > be in one called Documents. I tried various lines like: > >> > >> temps <- > > read.table("c:\\Users\\DFP\\Documents\\ah\\house\\HouseTemps.txt",header=T,row.names=1) > >> > >> based on my windows DOS experience, but nothing I try works. > So my question is, what do complete file names look like in a mac? > >> > >> I tried Apple support, but they couldn't help me with R. > >> > >> __ > >> R-help@r-project.org <mailto: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 <mailto: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 <mailto: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 <mailto: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] Not seeing the results of a function
I’m trying to write a function that will add items to two vectors, and then to create a third vector that is of the form 1, 2, 3, …, length of one of the newly modified vectors. My problem is that what I’ve written doesn’t seem to return any of those modifications. How can I get the new values to be returned? Here’s the function below. I want to add a value, stp, to the end of the stpos vector, a value mcp to the end of the mcpos vector, and the to create that days vector. When I call this function with numerical values for stp and mcp, and then ask to see stpos, mcpos, and days, nothing has been changed. How can I fix this? Here’s the function: > addday <- function(stp,mcp,stpos,mcpos){stpos<-c(stpos,stp) + mcpos<-c(mcpos,mcp) + days<-c(1:length(stpos))} David __ 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] Program to produce multiple plots
I wrote a little program that asked to produce two plots, but when I ran it, I saw only the second plot. Is there a way to write a program that will produce multiple visible plots? David __ 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] C code called from R: reallocate arrays passed as arguments?
Hello, I used to use a (somehow complicated) code in C and I have tried to adapt it to be called from R without making an excessive amount of changes. I am afraid I cannot post the code here, but I am going to try to describe the problem as accurately as possible. I have some arguments that are most of the cases required for internal C operations only; but as they are needed a few times as arguments, they are still passed as arguments. Another argument is a "switch" (with value 0 or 1) that states whether these "arguments" are really needed as arguments or not. When such switch is 0 (says "no"), the C code "feels free" to manipulate these "arguments", and in particular it tries to modify its extension (reallocate). To be clear: I define the "argument" in R: values1 <- double(size) values1 is passed as an argument in ".C". If the switch is set to 0 (says that "values1" is not a real argument), the C function tries to reallocate the pseudo-argument values1: double *tmp2 = realloc(values1, new_size); if(tmp2 != NULL){ values1 = tmp2; } else{ Rprintf("\nFATAL ERROR: Could not allocate memory for the array\n"); exit(2); } But then, when calling the function ".C", I get *** error for object ...: pointer being reallocated was not allocated Is there any workaround for this? Thank you very much in advance, David Can you please Cc to me any replies, just in case I may miss any of them among the whole amount of emails :-) ? [[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] "Memory not mapped" when using .C, problem in Mac but not in Linux
Hello, I am aware this may be an obscure problem difficult to advice about, but just in case... I am calling a C function from R on an iMac (almost shining: bought by my institution this year) and gives a "memory not mapped" error. Nevertheless, exactly the same code runs without problem in a powerful computer using SuSE Linux, but also on my laptop of 2007, 32 bits, 2 GB RAM, running Ubuntu. My supervisor says that he can run my code on his iMac (a bit older than mine) without problem. I have upgraded to the latest version of R, and I have tried compiling the C code with the latest version of gcc (obtained from MacPorts), but the error persists. Any ideas? Thank you very much in advance, David Can you please Cc to me any replies, just in case I may miss any of them among the whole amount of emails :-) ? [[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] "Memory not mapped" when using .C, problem in Mac but not in Linux
Thank you very much for your kind reply. I used gdb, and it returns a reason "KERN_INVALID_ADDRESS" on a very simple operation (obtaining the time step for a numerical integration). Please see bellow. But, um, I solved it by changing the function's arguments in the C code from "unsigned long int" to "int". In R, those arguments were defined with "as.integer". So, can you now understand why the error happens (on iMac and not on Linux)? If yes, can you explain it to me? :-) If some argument is defined in C as "unsigned long int", I see that the R equivalent is *not* "as.integer". Which is it? Thank you very much in advance, David Can you please Cc to me any replies, just in case I may miss any of them among the whole amount of emails :-) ? --- Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x000902ef3d68 [...] 139double time_step=(times[number_times[0]-1]-times[0])/(number_timesteps[0]); (note: "number_times" and "number_timesteps" are integer arrays with a single component, because they are arguments of the C function that need to be passed from R. They were defined as "unsigned long int" in C, and "as.integer" in R, giving the error. If I define them as "int" in C, the error disappears). 2010/10/13 William Dunlap > This often happens when your C code uses memory that > it did not allocate, particularly when it reads or > writes just a little beyond the end of a memory block. > On some platforms or if you are lucky there is unused > memory between blocks of allocated memory and you don't > see a problem. Other machines may pack allocated memory > blocks more tightly and writing off the end of an array > corrupts another array, leading to the program crashing. > (Or reading off the end of an array may pick up data from > the next array, which leads to similar crashes later on.) > You may also be reading memory which has never been written > to, hence you are using random data, which could corrupt > things. > > Use a program like valgrind (on Linux, free) or Purify (on > various platforms, but pricy) to detect memory misuse > in C/C++ code. As long as your code isn't #ifdef'ed for > various platforms, you can use valgrind to detect and fix > memory misuse on Linux and you will find that overt > problems on other platforms will go away. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > -Original Message- > > From: r-help-boun...@r-project.org > > [mailto:r-help-boun...@r-project.org] On Behalf Of David > > Sent: Wednesday, October 13, 2010 6:47 AM > > To: r-help@r-project.org > > Subject: [R] "Memory not mapped" when using .C,problem in Mac > > but not in Linux > > > > Hello, > > > > I am aware this may be an obscure problem difficult to advice > > about, but > > just in case... I am calling a C function from R on an iMac > > (almost shining: > > bought by my institution this year) and gives a "memory not > > mapped" error. > > > > Nevertheless, exactly the same code runs without problem in a powerful > > computer using SuSE Linux, but also on my laptop of 2007, 32 > > bits, 2 GB RAM, > > running Ubuntu. My supervisor says that he can run my code on > > his iMac (a > > bit older than mine) without problem. > > > > I have upgraded to the latest version of R, and I have tried > > compiling the C > > code with the latest version of gcc (obtained from MacPorts), > > but the error > > persists. > > > > Any ideas? > > > > Thank you very much in advance, > > > > David > > Can you please Cc to me any replies, just in case I may miss > > any of them > > among the whole amount of emails :-) ? > > > > [[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] "Memory not mapped" when using .C, problem in Mac but not in Linux
Thank you, William and Berend, for your thorough replies. I have still the habit of setting "long int" variables because, when I first learnt C, the manual said that "int" could be up to around 3.2e4. But I suppose that, in systems from 32 bits, an "int" number can be much larger, isn't it? - which version of Mac OS X? > 10.6.4 > - Which version of R? (version, architecture) > The version is 2.11.1 (although I had the same problem with the previous version). I downloaded the binary for Mac from r-project. In the Applications menu, I can see "R" and "R64". Nevertheless, I start R in the command line: like this, I suppose it is the 64 bits version which starts, isn't it? > - Officially provided R or compiled by you? Official R is compiled with > Apple gcc. > The official one. > - if R was compiled with Apple compiler, who knows what can happen if you > link with code compiled with a non Apple gcc? > It is the official. Nevertheless, my code C for R works in Linux whether I compile my C functions with gcc or with icc. > - if the code runs ok on your supervisors iMac: did he use Apple compiler? > I do not think he compiled it himself. For the architecture, he does not remember well, he has said that he thinks that he is using a version of R that was compiled in 32 bits. > if so I wouldn't be surprised if your Macports compiler is a possible cause > of your troubles. > I do not think so. Both R and the "default" gcc did not come from Macports. The "default" gcc came with Xcode in the extras' cd (by the way, how can gcc in Mac be upgraded?). > - on 64bit Mac OS X long int is 64bits and int is 32bits; on 32bit Mac OSX > both are 32 bits. > Thank you. As I said, chaging from "unsigned long int" to "int" seemed to solve the problem. David Can you please Cc to me any replies, just in case I may miss any of them among the whole amount of emails :-) ? [[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] 64-bit R via ec2
Saw your post - please provide more info on using your images. Thanks. __ 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] calibration curve for cph()
A combination of Predict (your newdata), cut2, and the plotting function of your choice ought to suffice. But thought that cross-validation was an option. Not at console at the moment (just off airplane.) Sent from my iPhone On Aug 15, 2011, at 5:26 PM, array chip wrote: > is there a R function that produces calibration curve on an independetn data > automatically, just like what calibrate() does on the training data itself? > > Thanks > > John > > From: Comcast > To: array chip > Cc: "r-help@r-project.org" > Sent: Monday, August 15, 2011 2:04 PM > Subject: Re: [R] calibration curve for cph() > > Build a prediction function using 'Function' that gets applied to set2. > Calibrate and validate. > > -- > David > > Sent from my iPhone > > On Aug 15, 2011, at 11:31 AM, array chip wrote: > > > Hi, the calibrate.cph() function in rms package generate calibration curve > > for Cox model on the same dataset where the model was derived using > > bootstrapping or cross-validation. If I have the model built on dataset 1, > > and now I want to produce a calibration curve for this model on an > > independent dataset 2, how can I do that? > > > > Thanks > > > > John > > > >[[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] The following object(s) are masked from ‘package:stats’
My apologies in advance as this seem like an easy thing to fix. I am quite new to using R. I am doing my thesis at the moment and I am trying to use the extremes package. However, when I try to access it I get this message: The following object(s) are masked from ‘package:stats’: > library( extRemes) Loading required package: tcltk Loading Tcl/Tk interface ... done Loading required package: ismev Loading required package: Lmoments Attaching package: ‘extRemes’ The following object(s) are masked from ‘package:stats’: qqnorm, qqplot I looked back on some of the older post about this problem. Apparently it has something to do with the order of the packages. > search() [1] ".GlobalEnv""package:extRemes" "package:Lmoments" "package:ismev" "package:tcltk" "package:stats" "package:graphics" "package:grDevices" [9] "package:utils" "package:datasets" "package:methods" "Autoloads" "package:base" > attach(stats) Error in attach(stats) : object 'stats' not found However, I still could not get it working. Thanks for any help in advance David -- View this message in context: http://r.789695.n4.nabble.com/The-following-object-s-are-masked-from-package-stats-tp4636079.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] The following object(s) are masked from ‘package:stats’
Hi Charlie, Thanks for replying top my post, I really appreciate it. I understand whats going on now. Thank you once again David -- View this message in context: http://r.789695.n4.nabble.com/The-following-object-s-are-masked-from-package-stats-tp4636079p4636250.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] barchart with 3 Arguments
The listserver is very good about passing on attachments IF AND ONLY IF they are text or an acceptable image format. -- David Sent from my iPhone On Aug 28, 2012, at 11:17 AM, John Kane wrote: > No data is attached. The R-help list usually strips out attachments to > prevent viruses or malware spreading. > > Use dput to include the data . Just do : dput(mydata) and copy the results > into your email. > > Also it is a good idea to include the code that you are using. > > > > John Kane > Kingston ON Canada > > >> -Original Message- >> From: falk.hilli...@twain-systems.com >> Sent: Tue, 28 Aug 2012 08:05:47 -0700 (PDT) >> To: r-help@r-project.org >> Subject: [R] barchart with 3 Arguments >> >> Hi @ all, >> I have a problem concerning the barplot (barchart lattice) of a >> dataframe. I >> work with the attached dataframe. >> When I try to plot this dataframe I only get two rows plottet. When I >> try >> to plot the whole dataframe, there is message, that it is 'height' must >> be a >> vector or a matrix. >> On the y-axis, the "amount_cattle" should be displayed and on the x-axis >> the >> "year" and the "country" so that I can compare the amount over the years >> in >> each country. Each country on the x-axis needs 4 bars (2000-2003). >> I hope you can help me. >> Thanks a lot >> geophagus >> >> >> >> >> >> >> >> >> -- >> View this message in context: >> http://r.789695.n4.nabble.com/barchart-with-3-Arguments-tp4641572.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. > > > FREE ONLINE PHOTOSHARING - Share your photos online with your friends and > family! > Visit http://www.inbox.com/photosharing to find out more! > > __ > 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.
[R] Making outregs in R
Dear r-Gods! I am interesting in making an equivalent command like outreg in stata where I get all my 8 regressions in one table. Does R have an easy command to that? MVH Dave [[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] Creating dummys in R
Dear R-project! How do i create 1 dummy from 2 already existing dummys. To be more precise, I want to create a dummy from a dummy called "sex" and another called "sex1" when both thoose dummys are 1 I want my created dummy "samesex" to take 1. Thanks for the help! Paulie [[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] Extracting numbers from a character variable of different types
On Mar 18, 2012, at 3:17 PM, Daniel Malter wrote: > Assume your year value is > > x<-007/A > > You want to replace all non-numeric characters (i.e. letters and > punctuation) and all zeros with nothing. > > gsub('[[:alpha:]]|[[:punct:]]|0','',x) > > Let's say you have a vector with both month and year values (you can > separate them). Now we need to identify the cells that have a month or year > indicator > > x<-c("007/A","007/a","003/M","003/m") > > grep("/A|/a",x) #cells in x with year information > grep("/M|/m",x) #cells in x with month information > > To remove all characters, punctuation, and 0s from x, do: > > gsub('[[:alpha:]]|[[:punct:]]|0','',x) > > which you can also do specifically for the cells that identify months and > years, respectively: > > years<-gsub('[[:alpha:]]|[[:punct:]]|0','',x[grep("/A|/a",x)]) The problem with this approach is that the years vector becomes disjoint from the months vector. It doesn't lend itself well to data.frame operations. -- David Sent from my iPhone > #years > years > months<-gsub('[[:alpha:]]|[[:punct:]]|0','',x[grep("/M|/m",x)]) #months > months > > Convert the resulting character vectors into numeric vectors by > as.numeric(as.character(years)) , for example. > > HTH, > Daniel > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Extracting-numbers-from-a-character-variable-of-different-types-tp4482248p4482732.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-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] bias sampling
Thank you for your time, Thomas . In case the questioner is not aware of a few facts... Thomas Lumley is both a) the person who originally ported tThereau's "survival" package to R and was also its maintainer for many years , and b) the author of the "survey" package -- David Sent from my iPhone On Mar 18, 2012, at 5:51 PM, Thomas Lumley wrote: > On Mon, Mar 19, 2012 at 10:27 AM, David Winsemius > wrote: >> >> On Mar 18, 2012, at 3:54 PM, Thomas Lumley wrote: >> >>> On Mon, Mar 19, 2012 at 6:34 AM, David Winsemius >>> wrote: >>>> >>>> >>>> On Mar 16, 2012, at 1:09 PM, niloo javan wrote: >>>> >>>>> hi >>>>> i want to analyze Right Censore-Length bias data under cox model with >>>>> covariate. >>>>> what is the package ? >>>> >>>> >>>> >>>> I initially left this question alone because I thought there might be >>>> viewers for whom it all made perfect sense. After two days that >>>> probability >>>> seems to be declining. The problem I had was the meaning of "length bias >>>> data". Are you talking about a non-proportional effect in which the >>>> assumption of a constant hazard ratio over time is false and other >>>> methods >>>> are needed. If that is correct, then you should get a copy of Therneau >>>> and >>>> Grambsch's "Modeling Survival Data" and study the chapter on "Functional >>>> Form'. The package would be "survival". >>>> >>> >>> Length-biased sampling is what you get when you take a cross-sectional >>> sample of an ongoing process -- long intervals are over-represented. >> >> >> Thank you Thomas; >> >> For example people who have survived to age 75 might be systematically >> different with respect to both the distribution of cardiovascular risk >> factors and their impact on the event of interest (AMI. CV death, or >> all-cause mortality) than persons at age 45. And that would also not take >> into account the fact those risk factors might have changed over the >> interval from age 45 to age 75 in the survivors? >>> >>> >>> If the arrival time is known for everyone in the sample, the usual Cox >>> model facilities for left truncation apply. If the arrival times are >>> not known it would be much more difficult, and would probably need >>> parametric modelling. >> >> >> Am I correct in thinking that additional assumptions about the >> "length-bias" would need to be explicitly stated or modeled under a set of >> plausible scenarios before progress in any framework could be anticipated? >> It would seem that there could be many forms of such a "length-bias". >> > > Yes, as with any missing data problem things can go arbitrarily badly wrong. > > The classical 'length-biased sampling' problem is a cross-sectional > sample from a stationary population process, and that gives good > results. > > Obviously if you don't recruit anyone before time T, there is no > information about what happened before then, but there may still be > useful information afterwards. A good example is the research project > on after-effects of the nuclear bombings of Nagasaki and Hiroshima, > where recruitment started (IIRC) 5 years after the event. There's no > information on survival in the first five years, but very good > subsequent information. > >-thomas > > -- > Thomas Lumley > Professor of Biostatistics > University of Auckland __ 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] i dont know what function do i have to make for ("The number of lines in the body of the email")
i tried to make function about "The number of lines in the body of the email" and i have three values which are emailtestset1, emailtestset2, and emails. what i have to do? -- View this message in context: http://r.789695.n4.nabble.com/i-dont-know-what-function-do-i-have-to-make-for-The-number-of-lines-in-the-body-of-the-email-tp4491165p4491165.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] png misbehaving with levelplot when inside a loop
I want to use spplot inside a loop to itteratively produce png files. for (i in 1:5){ png(file=paste("myPlot",i,".png",sep=""),bg="white",height=500,width=500) library(lattice) trellis.par.set(sp.theme()) # sets bpy.colors() ramp data(meuse) coordinates(meuse) <- ~x+y l2 = list("SpatialPolygonsRescale", layout.north.arrow(), offset = c(181300,329800), scale = 400) l3 = list("SpatialPolygonsRescale", layout.scale.bar(), offset = c(180500,329800), scale = 500, fill=c("transparent","black")) l4 = list("sp.text", c(180500,329900), "0") l5 = list("sp.text", c(181000,329900), "500 m") spplot(meuse, c("ffreq"), sp.layout=list(l2,l3,l4,l5),col.regions="black",pch=c(1,2,3), key.space=list(x=0.1,y=.95,corner=c(0,1))) dev.off() } The above example fails to write the output to the file. When the loop is finished the file size of each file is 0Kb. If I perform the work of the loop manually, ie. setting "i <- 1", "i <- 2" etc before manually running the loop contents then there is no problem. There is also no problem if I replace all the spplot stuff with say "hist(rnorm(100))". The same behaviour is reproduced with levelplot too so is not sp specific. for (i in 1:5){ png(file=paste("sillyPlot",i,".png",sep=""),bg="white",height=500,width=500) x <- seq(pi/4, 5 * pi, length = 100) y <- seq(pi/4, 5 * pi, length = 100) r <- as.vector(sqrt(outer(x^2, y^2, "+"))) grid <- expand.grid(x=x, y=y) grid$z <- cos(r^2) * exp(-r/(pi^3)) levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="", ylab="", main="Weird Function", sub="with log scales", colorkey = FALSE, region = TRUE) dev.off() } How should I correctly write these loops to do as intended? cheers David -- David Pleydell Laboratoire de Biologie Environnementale USC INRA-EA 3184 Université de Franche-Comté Place Leclerc F 25030 Besançon France (0033) 0381665763 [EMAIL PROTECTED] __ 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] Frailty
Hi Which package(s) is R fit frailty models to univariate survival data, i.e. simple data with one survival time per person. David [[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] What exactly is an dgCMatrix-class. There are so many attributes.
> On Oct 20, 2017, at 11:11 AM, C W wrote: > > Dear R list, > > I came across dgCMatrix. I believe this class is associated with sparse > matrix. Yes. See: help('dgCMatrix-class', pack=Matrix) If Martin Maechler happens to respond to this you should listen to him rather than anything I write. Much of what the Matrix package does appears to be magical to one such as I. > > I see there are 8 attributes to train$data, I am confused why are there so > many, some are vectors, what do they do? > > Here's the R code: > > library(xgboost) > data(agaricus.train, package='xgboost') > data(agaricus.test, package='xgboost') > train <- agaricus.train > test <- agaricus.test > attributes(train$data) > I got a bit of an annoying surprise when I did something similar. It appearred to me that I did not need to load the xgboost library since all that was being asked was "where is the data" in an object that should be loaded from that library using the `data` function. The last command asking for the attributes filled up my console with a 100K length vector (actually 2 of such vectors). The `str` function returns a more useful result. > data(agaricus.train, package='xgboost') > train <- agaricus.train > names( attributes(train$data) ) [1] "i""p""Dim" "Dimnames" "x""factors" "class" > str(train$data) Formal class 'dgCMatrix' [package "Matrix"] with 6 slots ..@ i : int [1:143286] 2 6 8 11 18 20 21 24 28 32 ... ..@ p : int [1:127] 0 369 372 3306 5845 6489 6513 8380 8384 10991 ... ..@ Dim : int [1:2] 6513 126 ..@ Dimnames:List of 2 .. ..$ : NULL .. ..$ : chr [1:126] "cap-shape=bell" "cap-shape=conical" "cap-shape=convex" "cap-shape=flat" ... ..@ x : num [1:143286] 1 1 1 1 1 1 1 1 1 1 ... ..@ factors : list() > Where is the data, is it in $p, $i, or $x? So the "data" (meaning the values of the sparse matrix) are in the @x leaf. The values all appear to be the number 1. The @i leaf is the sequence of row locations for the values entries while the @p items are somehow connected with the columns (I think, since 127 and 126=number of columns from the @Dim leaf are only off by 1). Doing this > colSums(as.matrix(train$data)) cap-shape=bellcap-shape=conical 3693 cap-shape=convex cap-shape=flat 2934 2539 cap-shape=knobbed cap-shape=sunken 644 24 cap-surface=fibrous cap-surface=grooves 18674 cap-surface=scaly cap-surface=smooth 2607 2035 cap-color=brown cap-color=buff 1816 # now snipping the rest of that output. Now this makes me think that the @p vector gives you the cumulative sum of number of items per column: > all( cumsum( colSums(as.matrix(train$data)) ) == train$data@p[-1] ) [1] TRUE > > Thank you very much! > > [[alternative HTML version deleted]] Please read the Posting Guide. Your code was not mangled in this instance, but HTML code often arrives in an unreadable mess. > > ______ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] What exactly is an dgCMatrix-class. There are so many attributes.
> On Oct 21, 2017, at 7:50 AM, Martin Maechler > wrote: > >>>>>> C W >>>>>>on Fri, 20 Oct 2017 15:51:16 -0400 writes: > >> Thank you for your responses. I guess I don't feel >> alone. I don't find the documentation go into any detail. > >> I also find it surprising that, > >>> object.size(train$data) >> 1730904 bytes > >>> object.size(as.matrix(train$data)) >> 6575016 bytes > >> the dgCMatrix actually takes less memory, though it >> *looks* like the opposite. > > to whom? > > The whole idea of these sparse matrix classes in the 'Matrix' > package (and everywhere else in applied math, CS, ...) is that > 1. they need much less memory and > 2. matrix arithmetic with them can be much faster because it is based on > sophisticated sparse matrix linear algebra, notably the > sparse Cholesky decomposition for solve() etc. > > Of course the efficency only applies if most of the > matrix entries _are_ 0. > You can measure the "sparsity" or rather the "density", of a > matrix by > > nnzero(A) / length(A) > > where length(A) == nrow(A) * ncol(A) as for regular matrices > (but it does *not* integer overflow) > and nnzero(.) is a simple utility from Matrix > which -- very efficiently for sparseMatrix objects -- gives the > number of nonzero entries of the matrix. > > All of these classes are formally defined classes and have > therefore help pages. Here ?dgCMatrix-class which then points > to ?CsparseMatrix-class (and I forget if Rstudio really helps > you find these ..; in emacs ESS they are found nicely via the usual key) > > To get started, you may further look at ?Matrix _and_ ?sparseMatrix > (and possibly the Matrix package vignettes --- though they need > work -- I'm happy for collaborators there !) > > Bill Dunlap's comment applies indeed: > In principle all these matrices should work like regular numeric > matrices, just faster with less memory foot print if they are > really sparse (and not just formally of a sparseMatrix class) > ((and there are quite a few more niceties in the package)) > > Martin Maechler > (here, maintainer of 'Matrix') > > >> On Fri, Oct 20, 2017 at 3:22 PM, David Winsemius >> wrote: > >>>> On Oct 20, 2017, at 11:11 AM, C W wrote: >>>> >>>> Dear R list, >>>> >>>> I came across dgCMatrix. I believe this class is associated with sparse >>>> matrix. >>> >>> Yes. See: >>> >>> help('dgCMatrix-class', pack=Matrix) >>> >>> If Martin Maechler happens to respond to this you should listen to him >>> rather than anything I write. Much of what the Matrix package does appears >>> to be magical to one such as I. >>> >>>> >>>> I see there are 8 attributes to train$data, I am confused why are there >>> so >>>> many, some are vectors, what do they do? >>>> >>>> Here's the R code: >>>> >>>> library(xgboost) >>>> data(agaricus.train, package='xgboost') >>>> data(agaricus.test, package='xgboost') >>>> train <- agaricus.train >>>> test <- agaricus.test >>>> attributes(train$data) >>>> >>> >>> I got a bit of an annoying surprise when I did something similar. It >>> appearred to me that I did not need to load the xgboost library since all >>> that was being asked was "where is the data" in an object that should be >>> loaded from that library using the `data` function. The last command asking >>> for the attributes filled up my console with a 100K length vector (actually >>> 2 of such vectors). The `str` function returns a more useful result. >>> >>>> data(agaricus.train, package='xgboost') >>>> train <- agaricus.train >>>> names( attributes(train$data) ) >>> [1] "i""p""Dim" "Dimnames" "x""factors" >>> "class" >>>> str(train$data) >>> Formal class 'dgCMatrix' [package "Matrix"] with 6 slots >>> ..@ i : int [1:143286] 2 6 8 11 18 20 21 24 28 32 ... >>> ..@ p : int [1:127] 0 369 372 3306 5845 6489 6513 8380 8384 10991 >>> ... >>> ..@ Dim : int [1:2] 6513 126 >>> ..@ Dimnames:List of 2 >>> .. ..$ : NULL >>> .. ..$ : chr [1
Re: [R] Syntax for fit.contrast
> On Oct 22, 2017, at 6:04 AM, Sorkin, John wrote: > > I have a model (run with glm) that has a factor, type. Type has two levels, > "general" and "regional". I am trying to get estimates (and SEs) for the > model with type="general" and type ="regional" using fit.contrast ?fit.contrast No documentation for ‘fit.contrast’ in specified packages and libraries: you could try ‘??fit.contrast’ Perhaps the gmodels function of that name? > but I can't get the syntax of the coefficients to use in fit.contrast > correct. I hope someone can show me how to use fit.contrast, or some other > method to get estimate with SEs. (I know I can use the variance co-variance > matrix, but I would rather not have to code the linear contrast my self from > the coefficients of the matrix) > I'm having trouble understanding what you are trying to extract. There are only 2 levels so there is really only one interesting contrast ("general" vs "regional") , and it's magnitude would be reported by just typing `model`, and it's SE would show up in output of `summary(model)`. I'm thinking you should pick one of the examples in gmodels::fit.contrast that most resembles your real problem, post it, and and then explain what difficulties you are having with interpretation. -- David. > Thank you, > > John > > > My model: > > model=glm(events~type,family=poisson(link=log),offset=log(SS),data=data) > > > Model details: > >> summary(data$type) > > general regional > 16 16 > >> levels(data$type) > [1] "general" "regional" > >> contrasts(data$type) > regional > general 0 > regional1 > > > I have tried the following syntax for fit.contrast > > fit.contrast(model,type,c(1,0)) > and get an error: > Error in `[[<-`(`*tmp*`, varname, value = cmat) : > no such index at level 1 > > >> fit.contrast(model,type,c(0,1),showall=TRUE) > and get an error: > Error in `[[<-`(`*tmp*`, varname, value = cmat) : > no such index at level 1 > > > >> fit.contrast(model,type,c(1,-1),showall=TRUE) > and get an error: > Error in `[[<-`(`*tmp*`, varname, value = cmat) : > no such index at level 1 > > >> fit.contrast(model,type,c(0)) > and get an error: > Error in make.contrasts(coeff, ncol(coeff)) : > Too many contrasts specified. Must be less than the number of factor levels > (columns). > >> fit.contrast(model,type,c(1)) > Error in make.contrasts(coeff, ncol(coeff)) : > and get an error > Too many contrasts specified. Must be less than the number of factor levels > (columns). > > > > > > > > > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Syntax for fit.contrast (from package gmodels)
> On Oct 22, 2017, at 3:56 PM, Sorkin, John wrote: > > David, > Thank you for responding to my post. > > Please consider the following output (typeregional is a factor having two > levels, "regional" vs. "general"): > Call: > glm(formula = events ~ type, family = poisson(link = log), data = data, > offset = log(SS)) > > Deviance Residuals: > Min 1Q Median 3Q Max > -43.606 -17.295 -4.6514.204 38.421 > > Coefficients: > Estimate Std. Error z value Pr(>|z|) > (Intercept) -2.528300.01085 -233.13 <2e-16 *** > typeregional 0.337880.01641 20.59 <2e-16 *** > > Let's forget for a moment that the model is a Poisson regression and pretend > that the output is from a simple linear regression, e.g. from lm. > > To get the estimate for "general" one simply needs to use the value of the > intercept i.e. -2.5830. Similarly to get the 95% CI of general one simply > needs to compute -2.52830-(1.96*0.01085) and -2.52830+(1.96*0.01085). > > To get the estimate for "regional" one needs to compute intercept + > typeregional, i.e. -2.52830 + 0.33788. To get the 95% CI is somewhat more > difficult as one needs to use results from the variance-covariance matix, > specifically the variance of intercept, the variance of "regional", and the > covariance of (intercept,"regional") which involves: > var = var(intercept) + var(regional) +2*(covar(intercept,regional)), > and then get the SE of the variance > SE=sqrt(var) > 95% CI = intercept + regional - 1.95*SE and intercept + regional + 1.95*SE. > > I was hoping that a contrast statement could be written that would give me > the point estimate and SE for "general" and its SE and another contrast > statement could be written that would give me the point estimate and SE for > "general" and it SE without my having to work directly with the > variance-covariance matrix. I tried doing this using the fit.contrast > statements (from the gmodels package): I'm guessing that the second contrast you were hoping for was actually for "regional". Contrasts, hence the name, are for differences between two levels (or more accurately between the means on the scale specified by the link parameter. In the absence of another level the only other reference point would be a value of zero or perhaps the value you specified by your offset term. -- David > > fit.contrast(model,type,c(1,0),showall=TRUE) > fit.contrast(model,type,c(0,1),showall=TRUE) > > and received the error message, > Error in `[[<-`(`*tmp*`, varname, value = c(0, 1)) : > no such index at level 1 > > Perhaps fit.contrast is not the way to accomplish my goal. Perhaps my goal > can be accomplished without a contrast statement, but I don't know how. > > Thank you, > John > > > > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > > > From: David Winsemius > Sent: Sunday, October 22, 2017 1:20 PM > To: Sorkin, John > Cc: r-help@r-project.org > Subject: Re: [R] Syntax for fit.contrast > > > > On Oct 22, 2017, at 6:04 AM, Sorkin, John wrote: > > > > I have a model (run with glm) that has a factor, type. Type has two levels, > > "general" and "regional". I am trying to get estimates (and SEs) for the > > model with type="general" and type ="regional" using fit.contrast > > ?fit.contrast > No documentation for ‘fit.contrast’ in specified packages and libraries: > you could try ‘??fit.contrast’ > > Perhaps the gmodels function of that name? > > > but I can't get the syntax of the coefficients to use in fit.contrast > > correct. I hope someone can show me how to use fit.contrast, or some other > > method to get estimate with SEs. (I know I can use the variance co-variance > > matrix, but I would rather not have to code the linear contrast my self > > from the coefficients of the matrix) > > > > I'm having trouble understanding what you are trying to extract. There are > only 2 levels so there is really only one interesting contrast ("general" vs > "regional") , and it's magnitude would be reported by just typing `model`, > and it's SE would show up in
Re: [R] Syntax for fit.contrast (from package gmodels)
> On Oct 22, 2017, at 5:01 PM, Sorkin, John wrote: > > David, > Again you have my thanks!. > You are correct. What I want is not technically a contrast. What I want is > the estimate for "regional" and its SE. There needs to be a reference value for the contrast. Contrasts are differences. I gave you the choice of two references (treatment constrast or the offset value you specified). Pick one or suggest an alternate value. Typical alternate values are the global mean or zero. Read ?predict.glm "se.fit logical switch indicating if standard errors are required." > I don't mind if I get these on the log scale; I can get the anti-log. Can you > suggest how I can get the point estimate and its SE for "regional"? The > predict function will give the point estimate, but not (to my knowledge) the > SE. > Thank you, > John > > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > > > From: David Winsemius > Sent: Sunday, October 22, 2017 7:56 PM > To: Sorkin, John > Cc: r-help@r-project.org > Subject: Re: [R] Syntax for fit.contrast (from package gmodels) > > > > On Oct 22, 2017, at 3:56 PM, Sorkin, John wrote: > > > > David, > > Thank you for responding to my post. > > > > Please consider the following output (typeregional is a factor having two > > levels, "regional" vs. "general"): > > Call: > > glm(formula = events ~ type, family = poisson(link = log), data = data, > > offset = log(SS)) > > > > Deviance Residuals: > > Min 1Q Median 3Q Max > > -43.606 -17.295 -4.6514.204 38.421 > > > > Coefficients: > > Estimate Std. Error z value Pr(>|z|) > > (Intercept) -2.528300.01085 -233.13 <2e-16 *** > > typeregional 0.337880.01641 20.59 <2e-16 *** > > > > Let's forget for a moment that the model is a Poisson regression and > > pretend that the output is from a simple linear regression, e.g. from lm. > > > > To get the estimate for "general" one simply needs to use the value of the > > intercept i.e. -2.5830. Similarly to get the 95% CI of general one simply > > needs to compute -2.52830-(1.96*0.01085) and -2.52830+(1.96*0.01085). > > > > To get the estimate for "regional" one needs to compute intercept + > > typeregional, i.e. -2.52830 + 0.33788. To get the 95% CI is somewhat more > > difficult as one needs to use results from the variance-covariance matix, > > specifically the variance of intercept, the variance of "regional", and the > > covariance of (intercept,"regional") which involves: > > var = var(intercept) + var(regional) +2*(covar(intercept,regional)), > > and then get the SE of the variance > > SE=sqrt(var) > > 95% CI = intercept + regional - 1.95*SE and intercept + regional + 1.95*SE. > > > > I was hoping that a contrast statement could be written that would give me > > the point estimate and SE for "general" and its SE and another contrast > > statement could be written that would give me the point estimate and SE for > > "general" and it SE without my having to work directly with the > > variance-covariance matrix. I tried doing this using the fit.contrast > > statements (from the gmodels package): > > I'm guessing that the second contrast you were hoping for was actually for > "regional". > > Contrasts, hence the name, are for differences between two levels (or more > accurately between the means on the scale specified by the link parameter. In > the absence of another level the only other reference point would be a value > of zero or perhaps the value you specified by your offset term. > > -- > David > > > > > > fit.contrast(model,type,c(1,0),showall=TRUE) > > fit.contrast(model,type,c(0,1),showall=TRUE) > > > > and received the error message, > > Error in `[[<-`(`*tmp*`, varname, value = c(0, 1)) : > > no such index at level 1 > > > > Perhaps fit.contrast is not the way to accomplish my goal. Perhaps my goal > > can be accomplished without a contrast statement, but I don't know how. > > > > Thank you, > > John
Re: [R] Syntax for fit.contrast (from package gmodels)
> On Oct 22, 2017, at 5:26 PM, Sorkin, John wrote: > > David, > predict.glm and se.fit were exactly what I was looking for. The default 'se' delivered for a listed contrast is not for that particular level per se, but rather for the difference between that level and the non-listed factor level (its mean) which is "embedded" as it were in the Intercept. The se for the Intercept is for the mean of all the reference levels jointly being zero. Apologies for any mis-steps in this effort. I'm enjoying my fourth IPA. I usually do not drink and derive. -- David. > Many thanks! > John > > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > > > From: David Winsemius > Sent: Sunday, October 22, 2017 8:15 PM > To: Sorkin, John > Cc: r-help@r-project.org > Subject: Re: [R] Syntax for fit.contrast (from package gmodels) > > > > On Oct 22, 2017, at 5:01 PM, Sorkin, John wrote: > > > > David, > > Again you have my thanks!. > > You are correct. What I want is not technically a contrast. What I want is > > the estimate for "regional" and its SE. > > There needs to be a reference value for the contrast. Contrasts are > differences. I gave you the choice of two references (treatment constrast or > the offset value you specified). Pick one or suggest an alternate value. > Typical alternate values are the global mean or zero. > > Read ?predict.glm > > "se.fit logical switch indicating if standard errors are required." > > > > I don't mind if I get these on the log scale; I can get the anti-log. Can > > you suggest how I can get the point estimate and its SE for "regional"? > > The predict function will give the point estimate, but not (to my > > knowledge) the SE. > > > > Thank you, > > John > > > > John David Sorkin M.D., Ph.D. > > Professor of Medicine > > Chief, Biostatistics and Informatics > > University of Maryland School of Medicine Division of Gerontology and > > Geriatric Medicine > > Baltimore VA Medical Center > > 10 North Greene Street > > GRECC (BT/18/GR) > > Baltimore, MD 21201-1524 > > (Phone) 410-605-7119 > > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > > > > > > > From: David Winsemius > > Sent: Sunday, October 22, 2017 7:56 PM > > To: Sorkin, John > > Cc: r-help@r-project.org > > Subject: Re: [R] Syntax for fit.contrast (from package gmodels) > > > > > > > On Oct 22, 2017, at 3:56 PM, Sorkin, John > > > wrote: > > > > > > David, > > > Thank you for responding to my post. > > > > > > Please consider the following output (typeregional is a factor having two > > > levels, "regional" vs. "general"): > > > Call: > > > glm(formula = events ~ type, family = poisson(link = log), data = data, > > > offset = log(SS)) > > > > > > Deviance Residuals: > > > Min 1Q Median 3Q Max > > > -43.606 -17.295 -4.6514.204 38.421 > > > > > > Coefficients: > > > Estimate Std. Error z value Pr(>|z|) > > > (Intercept) -2.528300.01085 -233.13 <2e-16 *** > > > typeregional 0.337880.01641 20.59 <2e-16 *** > > > > > > Let's forget for a moment that the model is a Poisson regression and > > > pretend that the output is from a simple linear regression, e.g. from lm. > > > > > > To get the estimate for "general" one simply needs to use the value of > > > the intercept i.e. -2.5830. Similarly to get the 95% CI of general one > > > simply needs to compute -2.52830-(1.96*0.01085) and > > > -2.52830+(1.96*0.01085). > > > > > > To get the estimate for "regional" one needs to compute intercept + > > > typeregional, i.e. -2.52830 + 0.33788. To get the 95% CI is somewhat more > > > difficult as one needs to use results from the variance-covariance matix, > > > specifically the variance of intercept, the variance of "regional", and > > > the covariance of (intercept,"regional") which involves: &
Re: [R] Problem when trying to run Java in R:
> On Oct 21, 2017, at 4:35 AM, Morkus via R-help wrote: > > Hello All, > > Although running Java from R used to work, for some mysterious reason, it's > stopped. > > Today when I tried to load a basic JDBC driver (or the sample .jinit()) code, > I got: > > - JavaVM: requested Java version ((null)) not available. Using Java at "" > instead. > > - JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib > > - JavaVM FATAL: Failed to load the jvm library. > > I saw postings on StackOverflow about this issue, but none of the suggested > fixes helped. > > I'm on Mac OS 10.13. > > My JAVA_HOME is: > /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home > > java -version > java version "1.8.0_144" I am not sure why but I do notice that currently: Java Recommended Version 8 Update 151 AND this quoted warning is on the current download page .. macOS Sierra 10.12 users: A few issues have been reported on Sierra. See FAQ for more information. Others have reported success with this at the Terminal command line: sudo R CMD javareconf export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home" export LD_LIBRARY_PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/server #AND then at the R command line: install.packages('rJava', type='source') > Java(TM) SE Runtime Environment (build 1.8.0_144-b01) > Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) > > I'm using R: 3.3.3 > > Here is sample code that also throws this same error: > >library(rJava) >.jinit() # this starts the JVM >s <- .jnew("java/lang/String", "Hello World!") I don't get any error running: sessionInfo() R version 3.4.2 Patched (2017-10-04 r73465) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.6 Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grDevices utils datasets graphics stats methods base other attached packages: [1] rJava_0.9-8 dplyr_0.7.2 gmodels_2.16.2 Matrix_1.2-11 xgboost_0.6-4 [6] rms_5.1-1 SparseM_1.77Hmisc_4.0-3 ggplot2_2.2.1 Formula_1.2-1 [11] survival_2.41-3 sos_2.0-0 brew_1.0-6 lattice_0.20-35 loaded via a namespace (and not attached): [1] Rcpp_0.12.11mvtnorm_1.0-6 gtools_3.5.0 visNetwork_1.0.3 [5] zoo_1.8-0 assertthat_0.2.0digest_0.6.12 R6_2.2.2 [9] plyr_1.8.4 backports_1.1.0 acepack_1.4.1 MatrixModels_0.4-1 [13] rlang_0.1.2 lazyeval_0.2.0 mxnet_0.10.1multcomp_1.4-6 [17] gdata_2.17.0rstudioapi_0.6 data.table_1.10.4 rpart_4.1-11 [21] gamlss.data_5.0-0 checkmate_1.8.3 DiagrammeR_0.9.0splines_3.4.2 [25] stringr_1.2.0 foreign_0.8-69 htmlwidgets_0.8 igraph_1.0.1 [29] munsell_0.4.3 compiler_3.4.2 influenceR_0.1.0rgexf_0.15.3 [33] pkgconfig_2.0.1 gamlss_5.0-2base64enc_0.1-3 gamlss.dist_5.0-0 [37] htmltools_0.3.6 nnet_7.3-12 tibble_1.3.1 gridExtra_2.2.1 [41] htmlTable_1.9 codetools_0.2-15XML_3.98-1.7 viridisLite_0.2.0 [45] MASS_7.3-47 grid_3.4.2 nlme_3.1-131 polspline_1.1.12 [49] jsonlite_1.5gtable_0.2.0magrittr_1.5scales_0.4.1 [53] stringi_1.1.5 viridis_0.4.0 bindrcpp_0.2 latticeExtra_0.6-28 [57] sandwich_2.3-4 TH.data_1.0-8 RColorBrewer_1.1-2 tools_3.4.2 [61] glue_1.1.1 Rook_1.1-1 parallel_3.4.2 colorspace_1.3-2 [65] cluster_2.0.6 knitr_1.15.1bindr_0.1 quantreg_5.33 Running this produces: Sys.getenv()[grep("jre", Sys.getenv())] #DYLD_LIBRARY_PATH /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -- David. > > (this is the "hello world" equivalent from the rJava site) > > > > I also tried to use Java 7 (rev. 51), which used to work, but that still > fails. > > Also tried a fresh install of R/RStudio on another machine with the same > results (same Java version, etc., however). > > I suspect Java itself is working fine since JDBC code from Java programs has > no issues. > > Not sure why loading Java in R stopped working, but would appreciate any > suggestions. > > Thanks very much, > > Sent from [ProtonMail](https://pr
Re: [R] Problem Subsetting Rows that Have NA's
> On Oct 25, 2017, at 6:57 AM, BooBoo wrote: > > On 10/25/2017 4:38 AM, Ista Zahn wrote: >> On Tue, Oct 24, 2017 at 3:05 PM, BooBoo wrote: >>> This has every appearance of being a bug. If it is not a bug, can someone >>> tell me what I am asking for when I ask for "x[x[,2]==0,]". Thanks. >> You are asking for elements of x where the second column is equal to zero. >> >> help("==") >> >> and >> >> help("[") >> >> explain what happens when missing values are involved. I agree that >> the behavior is surprising, but your first instinct when you discover >> something surprising should be to read the documentation, not to post >> to this list. After having read the documentation you may post back >> here if anything remains unclear. >> >> Best, >> Ista >> >>>> #here is the toy dataset >>>> x <- rbind(c(1,1),c(2,2),c(3,3),c(4,0),c(5,0),c(6,NA), >>> + c(7,NA),c(8,NA),c(9,NA),c(10,NA) >>> + ) >>>> x >>> [,1] [,2] >>> [1,]11 >>> [2,]22 >>> [3,]33 >>> [4,]40 >>> [5,]50 >>> [6,]6 NA >>> [7,]7 NA >>> [8,]8 NA >>> [9,]9 NA >>> [10,] 10 NA >>>> #it contains rows that have NA's >>>> x[is.na(x[,2]),] >>> [,1] [,2] >>> [1,]6 NA >>> [2,]7 NA >>> [3,]8 NA >>> [4,]9 NA >>> [5,] 10 NA >>>> #seems like an unreasonable answer to a reasonable question >>>> x[x[,2]==0,] >>> [,1] [,2] >>> [1,]40 >>> [2,]50 >>> [3,] NA NA >>> [4,] NA NA >>> [5,] NA NA >>> [6,] NA NA >>> [7,] NA NA >>>> #this is more what I was expecting >>>> x[which(x[,2]==0),] >>> [,1] [,2] >>> [1,]40 >>> [2,]50 >>> __ >>> 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. > > I wanted to know if this was a bug so that I could report it if so. You say > it is not, so you answered my question. As far as me not reading the > documentation, I challenge anyone to read the cited help pages and predict > the observed behavior based on the information given in those pages. Some of us do share (or at least remember feeling) your pain. The ?Extract page is long and complex and there are several features that I find non-intuitive. But they are deemed desirable by others. I think I needed to read that page about ten times (with multiple different problems that needed explication) before it started to sink in. You are apparently on that same side of the split opinions on the feature of returning rows with logical NA's as I am. I've learned to use `which`, and I push back when the conoscienti says it's not needed. After you read it a few more times you may come to a different opinion. Many people come to R with preconceived notions of what words like "equals" or "list" or "vector" mean and then complain about the documentation. You would be better advised to spend more time studying the language. The help pages are precise but terse, and you need to spend time with the examples and with other tutorial material to recognize the gotcha's. Here's a couple of possibly helpful rules regarding "[[" and "[" and logical indexing: Nothing _equals_ NA. Selection operations with NA logical index item return NA. (Justified as a warning feature as I understand it.) "[" always returns a list. "[[" returns only one thing, but even that thing could be a list. Generally you want "[[" if you plan on testing for equality with a vector. The "R Inferno" by Burns is an effort to detail many more of the unexpected or irregular aspects of R (mostly inherited from S). -- Best of luck in your studies. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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 Subsetting Rows that Have NA's
> On Oct 25, 2017, at 11:17 AM, David Winsemius wrote: > > >> On Oct 25, 2017, at 6:57 AM, BooBoo wrote: >> >> On 10/25/2017 4:38 AM, Ista Zahn wrote: >>> On Tue, Oct 24, 2017 at 3:05 PM, BooBoo wrote: >>>> This has every appearance of being a bug. If it is not a bug, can someone >>>> tell me what I am asking for when I ask for "x[x[,2]==0,]". Thanks. >>> You are asking for elements of x where the second column is equal to zero. >>> >>> help("==") >>> >>> and >>> >>> help("[") >>> >>> explain what happens when missing values are involved. I agree that >>> the behavior is surprising, but your first instinct when you discover >>> something surprising should be to read the documentation, not to post >>> to this list. After having read the documentation you may post back >>> here if anything remains unclear. >>> >>> Best, >>> Ista >>> >>>>> #here is the toy dataset >>>>> x <- rbind(c(1,1),c(2,2),c(3,3),c(4,0),c(5,0),c(6,NA), >>>> + c(7,NA),c(8,NA),c(9,NA),c(10,NA) >>>> + ) >>>>> x >>>> [,1] [,2] >>>> [1,]11 >>>> [2,]22 >>>> [3,]33 >>>> [4,]40 >>>> [5,]50 >>>> [6,]6 NA >>>> [7,]7 NA >>>> [8,]8 NA >>>> [9,]9 NA >>>> [10,] 10 NA >>>>> #it contains rows that have NA's >>>>> x[is.na(x[,2]),] >>>> [,1] [,2] >>>> [1,]6 NA >>>> [2,]7 NA >>>> [3,]8 NA >>>> [4,]9 NA >>>> [5,] 10 NA >>>>> #seems like an unreasonable answer to a reasonable question >>>>> x[x[,2]==0,] >>>> [,1] [,2] >>>> [1,]40 >>>> [2,]50 >>>> [3,] NA NA >>>> [4,] NA NA >>>> [5,] NA NA >>>> [6,] NA NA >>>> [7,] NA NA >>>>> #this is more what I was expecting >>>>> x[which(x[,2]==0),] >>>> [,1] [,2] >>>> [1,]40 >>>> [2,]50 >>>> __ >>>> 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. >> >> I wanted to know if this was a bug so that I could report it if so. You say >> it is not, so you answered my question. As far as me not reading the >> documentation, I challenge anyone to read the cited help pages and predict >> the observed behavior based on the information given in those pages. > > Some of us do share (or at least remember feeling) your pain. The ?Extract > page is long and complex and there are several features that I find > non-intuitive. But they are deemed desirable by others. I think I needed to > read that page about ten times (with multiple different problems that needed > explication) before it started to sink in. You are apparently on that same > side of the split opinions on the feature of returning rows with logical NA's > as I am. I've learned to use `which`, and I push back when the conoscienti > says it's not needed. horrible misspelling of cognoscenti > After you read it a few more times you may come to a different opinion. Many > people come to R with preconceived notions of what words like "equals" or > "list" or "vector" mean and then complain about the documentation. You would > be better advised to spend more time studying the language. The help pages > are precise but terse, and you need to spend time with the examples and with > other tutorial material to recognize the gotcha's. > > Here's a couple of possibly helpful rules regarding "[[" and "[" and logical > indexing: > > Nothing _equals_ NA. > Selection operations with NA logical index item return NA. (Justified as a > warning feature as I understand it.) > "[" always returns a list. That's not true or even half true. "[" always returns a list if it's first argument is a list and it only has two arguments. If X is a list and you ask for X[vector] you get a list If you ask for X[vector, ] you may get a l
Re: [R] R encountered a fatal error. The session was terminated. + *** caught illegal operation ***
I've seen similar issues reported on the RStudio community site: https://community.rstudio.com/. You might want to check in there, as I think this may well be an RStudio issue rather than a problem with R itself. Dave On 26 October 2017 at 12:11, Eric Berger wrote: > How about going back to earlier versions if you don't need the latest ones? > > > On Thu, Oct 26, 2017 at 12:59 PM, Klaus Michael Keller < > klaus.kel...@graduateinstitute.ch> wrote: > > > Dear all, > > > > I just installed the "Short Summer" R update last week. Now, my R Studio > > doesn't open anymore! > > > > --> R encountered a fatal error. The session was terminated. > > > > and my R terminal doesn't close properly > > > > --> *** caught illegal operation *** > > > > I restarted my Mac OS Sierra 10.12.6 and reinstalled both R 3.4.2 and the > > latest R studio but the problem persists. > > > > How can that issue be solved? > > > > Thanks in advance for your a precious help! > > > > All the best from Switzerland, > > > > Klaus > > [[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. > [[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] nomogram function error
> On Oct 26, 2017, at 9:42 AM, Annalisa VanderWyden via R-help > wrote: > > > Hi R-help, > > > > I have fit a cox ph model to my data, but have beenreceiving an error when > trying to fit a model to the nomogram. Here is the codeand corresponding > error: > > > > > >> nomogramCF = nomogram(cph_age6_40avp4, The only package that I know of having a function named `nomogram` is rms. > > +lp.at= seq(-10,10,by =0.5),lp = TRUE, > > + > > + funlabel="5year survival", > > + fun=surv5.CFdata5, That should be a function name being passed. But you haven't shown us any function definiton. > fun.at= c(0.01,seq(0.1,0.9,by=0.2),0.99)) > > Error inapprox(fu[s], xseq[s], fat, ties = mean) : > > needat least two non-NA values to interpolate > > > > > > I have fit similar nomograms based on cox ph models usingsimilar code, so I’m > not sure what I’m doing wrong this time. We are at least as unsure as you and most probably more so. You have not offered a reproducible problem. > I heard there might be some an issue because of a softwareupdate? There's often a NEWS for packages. Type: help(pac=rms) > > > > Thanks, > > Annie > > > [[alternative HTML version deleted]] Please read the Posting Guide linked to in every rhelp posting. -- David. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] 3D Plot with Date Axis?
> On Oct 27, 2017, at 12:22 PM, Alex Restrepo wrote: > > Hello, > > I would like to format the X axis of the plot created via the scatterplot3d > function or any other function which will work. > > Here is an example of what I am trying to do: > > library("scatterplot3d") > > mydf=data.frame(rate=c(1,1,4,4), age=c(2,2,5,5), market_date=c('2017-01-01', > '2017-02-02', '2017-03-03', '2017-04-04')) > > scatterplot3d(mydf$market_date, mydf$rate, mydf$age, xaxt="n") > > axis.Date(1, mydf$market_date, format="%Y-%m-%d") > > I tried to hide the x axis, but it looks like xaxt is not working for the > scatterplot3d function. Please read the "?scatterplot3d page more carefully. I think you should be looking for the x.ticklabs parameter. -- David. > > Using the above example, could someone please provide me with some guidance > and help? > > Many Thanks, > > Alex > > > [[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] Scatterplot3d :: Rotating x tick labels by x degrees
> On Oct 31, 2017, at 8:55 AM, Olivier Crouzet > wrote: > > Hi Alex, > > this should be related to the "las" argument of "par()" but > actually it does not seem to be parametered in scatterplot3d. > Searching the net for "scatterplot3d las" provides a link to: > > https://stackoverflow.com/questions/25458652/specifying-the-orientation-of-the-axes-labels-in-scatterplot3d > > You may try the solution that is provided in this link or consider using > alternate packages (like rgl or the plotly packages which one may be > more powerfull as far as I can judge). However I can't help more. It > seems ggplot does not produce 3d plots (but it looks like it can > interact with plotly when using 3d plots). Olivier; The cited SO solutions (mine being the first one) were addressing the request for rotated "axis"-labels rather than rotated "axtick"-labels, although the general strategy of looking at the code and using the `text`-function with xpd=TRUE (rather than the `mtext`-function where needed in the definitions of mytext and mytext2) should apply. Alex; I'd encourage you to demonstrate more initiative rather than expecting us to be on-call code servants. I've decided to limit my gratis coding time to 15 minutes daily. I think this might take me an hour or more. I'm still available for on-list code review on this effort. As a start, I'd suggest downloading the scatterplot3d package code and then open up scatterplot3d.R. Find the comment ## label tick marks ... and perhaps decide whether you need to use `text` rather than `mtext`. (`text` can rotate by any amount, but may need "xpd" to be set TRUE. `mtext` is limited to 90 degree increments.) I've used up my time, so the next move is yours. -- David. > > Olivier. > > On Mon, 30 Oct 2017 > 23:56:02 + Alex Restrepo wrote: > >> Hi, >> >> I would like to rotate the x axis tick labels by 45 degrees. Using >> the code below, could someone please provide an example? Many >> Thanks In Advance, Alex >> >> library("scatterplot3d") >> mydf=data.frame(rate=seq(158, 314) >>,age=seq(1, 157) >>,market_date=seq(as.Date("2000/1/1"), as.Date >> ("2003/1/1"), by="7 days")) >> >> mydf$market_date=as.Date(mydf$market_date, format="%Y-%m-%d") >> >> scatterplot3d(mydf$market_date >> ,mydf$rate >> ,mydf$age >> ,x.ticklabs = seq(as.Date("2000/1/1"), as.Date >> ("2003/1/1"), by="330 days")) >> >> >> [[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. > > > -- > Olivier Crouzet, PhD > /Assistant Professor/ > @LLING - Laboratoire de Linguistique de Nantes >UMR6310 CNRS / Université de Nantes > /Guest Researcher/ > @UMCG (University Medical Center Groningen) >ENT department >Rijksuniversiteit Groningen > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] beta binomial distribution installation
> On Nov 1, 2017, at 9:09 AM, Amany Abdel-Karim wrote: > > Hello, > > Thank you for your response. I need to install RankTail package since it > contains the beta binomial distribution, CDF and inverse CDF in the usual > form which I need to use. However rmutil package contain unusual forms for > these functions. So it is easier for me to deal with the forms are contained > in RankTail. > > I tried to install bioconductor package, using the following commands but I > still got the following errors: > > > (1) I tried biocLite() and then library ("TailRank"), I got the following > errors. It appears you failed to follow the full instructions which were to execute: source("https://bioconductor.org/biocLite.R";) biocLite() The first line creates the biocLite function within your workspace. -- David. > >> biocLite() > Error in biocLite() : could not find function "biocLite" >> library("TailRank") > Loading required package: oompaBase > Error: package or namespace load failed for �TailRank� in loadNamespace(i, > c(lib.loc, .libPaths()), versionCheck = vI[[i]]): > there is no package called �Biobase� > In addition: Warning messages: > 1: package �TailRank� was built under R version 3.4.2 > 2: package �oompaBase� was built under R version 3.4.2 > > > > (2) I tried to write the command biocLite(), then biocLite("TailRank"), I got > the following errors: > >> biocLite() > Error in biocLite() : could not find function "biocLite" >> biocLite("ilRank") > Error in biocLite("ilRank") : could not find function "biocLite" >> biocLite() > Error in biocLite() : could not find function "biocLite" >> biocLite("TailRank") > Error in biocLite("TailRank") : could not find function "biocLite" > > > > >> > > > > > Also, I checked under packages on the right side of the R window and I found > TailRank , Description is Tail-Rank statistic, and version is 3.1.3. So, I > tried to write the following code in the console window to check if the > package works: > >> N<-20 >> u<-3 >> v<-10 >> p<-u/u+v >> x<-0:N > >> yy<-dbb(x,N,u,v) > > > I got the following error: > Error in dbb(x, N, u, v) : could not find function "dbb" > > > > >> > > > > I am confused because if the package TailRank is already there, why the > pervious code does not work to calculate dbb (x,N,u,v) and I got error? If I > do not have the package, would you please let me know the right commands I > should write in the script window to install TaiRank because the commands I > used (which I mentioned at the beginning of the email did not work and gave > errors). I appreciate your help since I am a new user of R. > > > Amany > > > > > > From: Eric Berger > Sent: Wednesday, November 1, 2017 2:42 AM > To: MCGUIRE, Rhydwyn > Cc: Amany Abdel-Karim; r-h...@stat.math.ethz.ch > Subject: Re: [R] beta binomial distribution installation > > Hi, > I did a quick search for other packages that provide the beta binomial > distribution and found "rmutil". > >> install.packages("rmutil") > > The package has the CDF (pbetabinom) and inverse CDF (qbetabinom) among other > functions. > > HTH, > Eric > > > > On Wed, Nov 1, 2017 at 7:50 AM, MCGUIRE, Rhydwyn > mailto:rm...@doh.health.nsw.gov.au>> wrote: > Hi there, > > It looks like you also need the bioconductor package biobase, I found > instructions for downloading that package here: > www.bioconductor.org/install<http://www.bioconductor.org/install> > > Good luck. > > Cheers, > Rhydwyn > > -Original Message- > From: R-help > [mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>] On > Behalf Of Amany Abdel-Karim > Sent: Wednesday, 1 November 2017 2:13 PM > To: r-h...@stat.math.ethz.ch<mailto:r-h...@stat.math.ethz.ch> > Subject: [R] beta binomial distribution installation > > Hello, > > I tried to install package TailRank using the command install.packages > (RankTail) and library (TailRank) but I got the following errors. So, how can > I install TaiRank in Rstudio to have se beta-binomial distribution, CDF and > inverse CDG of beta-binomal? > > The commands I used are: > >> install.packages("TailRank") > > Installing package into C:/Users/stator-guest/Documents/R/win-library/3.4 > > (as lib is unspecified) >
Re: [R] "prob" package alternative
> On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz wrote: > > The prob package has been archived because it depends upon some other > packages which have issues. > > However, such projects as Introduction to Probability and Statistics in R > depend upon it for learning. There are a few other resources that also use > it. > > Does anyone know of any workarounds? > > Someone at stack exchange mentioned using R 2.9. I'm not sure I would trust that person. They seem a bit uninformed. > However, that broke my > RStudio (WSOD) and the dependent packages still wouldn't install, anyway. The latest version of pkg-prob at the Archive directory of CRAN indicates that it was last updated within this year. The DESCRIPTION file indicates that it does not need compilation, but: Depends: combinat, fAsianOptions So there should be code in text files in its ../R directory which can be sourced from that directory. ~myuser_name$ ls /Users/../Downloads/prob/R characteristicfunctions.r simulation.rutils-spaces.r genData.R spaces-examples.r utils-subsets.r misc.r spaces-prob.r prob.r utils-events.r Or you can install from source after downloading: install.packages("~/Downloads/prob", repo=NULL,type="source") # Success > library(prob) # So does require having several other packages Loading required package: combinat Attaching package: ‘combinat’ The following object is masked from ‘package:utils’: combn Loading required package: fAsianOptions Loading required package: timeDate Attaching package: ‘timeDate’ The following object is masked from ‘package:cairoDevice’: Cairo The following objects are masked from ‘package:PerformanceAnalytics’: kurtosis, skewness Loading required package: timeSeries Attaching package: ‘timeSeries’ The following object is masked from ‘package:zoo’: time<- Loading required package: fBasics Rmetrics Package fBasics Analysing Markets and calculating Basic Statistics Copyright (C) 2005-2014 Rmetrics Association Zurich Educational Software for Financial Engineering and Computational Science Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY. https://www.rmetrics.org --- Mail to: i...@rmetrics.org Loading required package: fOptions Rmetrics Package fOptions Pricing and Evaluating Basic Options Copyright (C) 2005-2014 Rmetrics Association Zurich Educational Software for Financial Engineering and Computational Science Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY. https://www.rmetrics.org --- Mail to: i...@rmetrics.org Attaching package: ‘prob’ The following objects are masked from ‘package:dplyr’: intersect, setdiff, union The following objects are masked from ‘package:base’: intersect, setdiff, union > > > > Tiby > > [[alternative HTML version deleted]] A specific suggestion would be that you read the listinfo and the Posting Guide and learn to post in plain text. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] ggplot inside function doesn't plot
> On Nov 2, 2017, at 9:27 AM, Ed Siefker wrote: > > I have a function: > > myplot <- function (X) { >d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE) >png(paste("img/", X, ".png", sep="")) >ggplot(d, aes(x=condition, y=count, color=condition)) + >geom_point(position=position_jitter(w=0.1,h=0)) + >scale_y_log10(breaks=c(25,100,400)) + >ggtitle(X) + >theme(plot.title = element_text(hjust = 0.5)) > >dev.off() >} > > 'd' is a dataframe > > count condition > E11.5 F20HET BA40_quant 955.9788 E11.5 F20HET > E11.5 F20HET BA45_quant 796.2863 E11.5 F20HET > E11.5 F20HET BB84_quant 745.0340 E11.5 F20HET > E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO > E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO > E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO > > If I set X="Etv5" and paste the contents of the function into R, I get > 'img/Etv5.png' > If I run myplot(X), I get nothing. > > >> X > [1] "Etv5" >> list.files("img") > character(0) >> myplot(X) > null device > 1 >> list.files("img") > character(0) >> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE) >> png(paste("img/", X, ".png", sep="")) >> ggplot(d, aes(x=condition, y=count, color=condition)) + > + geom_point(position=position_jitter(w=0.1,h=0)) + > + scale_y_log10(breaks=c(25,100,400)) + > + ggtitle(X) + > + theme(plot.title = element_text(hjust = 0.5)) >> dev.off() > null device > 1 >> list.files("img") > [1] "Etv5.png" > > Why doesn't my function work? `ggplot` creates an object. You need to print it when used inside a function. Inside a function (in a more restricted environment) there is no parse-eval-print-loop. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] ggplot inside function doesn't plot
> On Nov 2, 2017, at 10:03 AM, Ed Siefker wrote: > > I don't really understand. I mean, I understand the solution is > print(ggplot(...)). But why is that required in a function and not at > the console? The REPL design of the interactive console is offered the user as a convenience, but I agree it's somewhat at odds with pure functional principles. > > Shouldn't I be able to rely on what I do at the console working in a > script? Is this inconsistent behavior by design? By design? Yes. Completely by design. Functions are a method of encapsulating intermediate results in a manner that does not interact with the objects that exist outside the function. There are three plotting paradigms: base-graphics, lattice, and ggplot. The latter two are built with grid graphics and a both more functional and object oriented (loosely spoken since they return objects) than base graphics. Base graphics behaves the way you expect. Execution of `lines` or `points` will give you "pen-on-ink" output, actually pixel on device output. > > > > On Thu, Nov 2, 2017 at 11:54 AM, David Winsemius > wrote: >> >>> On Nov 2, 2017, at 9:27 AM, Ed Siefker wrote: >>> >>> I have a function: >>> >>> myplot <- function (X) { >>> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE) >>> png(paste("img/", X, ".png", sep="")) >>> ggplot(d, aes(x=condition, y=count, color=condition)) + >>> geom_point(position=position_jitter(w=0.1,h=0)) + >>> scale_y_log10(breaks=c(25,100,400)) + >>> ggtitle(X) + >>> theme(plot.title = element_text(hjust = 0.5)) >>> >>> dev.off() >>> } >>> >>> 'd' is a dataframe >>> >>>count condition >>> E11.5 F20HET BA40_quant 955.9788 E11.5 F20HET >>> E11.5 F20HET BA45_quant 796.2863 E11.5 F20HET >>> E11.5 F20HET BB84_quant 745.0340 E11.5 F20HET >>> E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO >>> E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO >>> E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO >>> >>> If I set X="Etv5" and paste the contents of the function into R, I get >>> 'img/Etv5.png' >>> If I run myplot(X), I get nothing. >>> >>> >>>> X >>> [1] "Etv5" >>>> list.files("img") >>> character(0) >>>> myplot(X) >>> null device >>> 1 >>>> list.files("img") >>> character(0) >>>> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE) >>>> png(paste("img/", X, ".png", sep="")) >>>> ggplot(d, aes(x=condition, y=count, color=condition)) + >>> + geom_point(position=position_jitter(w=0.1,h=0)) + >>> + scale_y_log10(breaks=c(25,100,400)) + >>> + ggtitle(X) + >>> + theme(plot.title = element_text(hjust = 0.5)) >>>> dev.off() >>> null device >>> 1 >>>> list.files("img") >>> [1] "Etv5.png" >>> >>> Why doesn't my function work? >> >> `ggplot` creates an object. You need to print it when used inside a >> function. Inside a function (in a more restricted environment) there is no >> parse-eval-print-loop. >> >> >>> >>> ______ >>> 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 >> >> 'Any technology distinguishable from magic is insufficiently advanced.' >> -Gehm's Corollary to Clarke's Third Law >> >> >> >> >> > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] "prob" package alternative
> On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz wrote: > > The issue is fAsianOptions. Is there a version that works with the latest > version of R? If not, which version of it works with which version of R and > where can it be found? I tried several at the archive already. sessionInfo() R version 3.4.2 Patched (2017-10-04 r73465) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.6 > packageDescription("fAsianOptions") Package: fAsianOptions Version: 3010.79 Revision: 5522 Date: 2013-06-23 Title: EBM and Asian Option Valuation Author: Diethelm Wuertz and many others, see the SOURCE file Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions Suggests: RUnit Maintainer: Yohan Chalabi Description: Environment for teaching "Financial Engineering and Computational Finance" Note: Several parts are still preliminary and may be changed in the future. this typically includes function and argument names, as well as defaults for arguments and return values. LazyData: yes License: GPL (>= 2) URL: http://www.rmetrics.org Packaged: 2013-06-23 18:22:14 UTC; yohan NeedsCompilation: yes Repository: CRAN Date/Publication: 2013-06-24 01:53:27 Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix > Alternatively, is there another package that behaves similarly to prob? > > > > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius > wrote: > > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz wrote: > > > > The prob package has been archived because it depends upon some other > > packages which have issues. > > > > However, such projects as Introduction to Probability and Statistics in R > > depend upon it for learning. There are a few other resources that also use > > it. > > > > Does anyone know of any workarounds? > > > > Someone at stack exchange mentioned using R 2.9. > > I'm not sure I would trust that person. They seem a bit uninformed. > > > However, that broke my > > RStudio (WSOD) and the dependent packages still wouldn't install, anyway. > > The latest version of pkg-prob at the Archive directory of CRAN indicates > that it was last updated within this year. The DESCRIPTION file indicates > that it does not need compilation, but: > > Depends: combinat, fAsianOptions > > So there should be code in text files in its ../R directory which can be > sourced from that directory. > > ~myuser_name$ ls /Users/../Downloads/prob/R > characteristicfunctions.r simulation.rutils-spaces.r > genData.R spaces-examples.r > utils-subsets.r > misc.r spaces-prob.r > prob.r utils-events.r > > > Or you can install from source after downloading: > > install.packages("~/Downloads/prob", repo=NULL,type="source") > > # Success > > > > library(prob) # So does require having several other packages > Loading required package: combinat > > Attaching package: ‘combinat’ > > The following object is masked from ‘package:utils’: > > combn > > Loading required package: fAsianOptions > Loading required package: timeDate > > Attaching package: ‘timeDate’ > > The following object is masked from ‘package:cairoDevice’: > > Cairo > > The following objects are masked from ‘package:PerformanceAnalytics’: > > kurtosis, skewness > > Loading required package: timeSeries > > Attaching package: ‘timeSeries’ > > The following object is masked from ‘package:zoo’: > > time<- > > Loading required package: fBasics > > > Rmetrics Package fBasics > Analysing Markets and calculating Basic Statistics > Copyright (C) 2005-2014 Rmetrics Association Zurich > Educational Software for Financial Engineering and Computational Science > Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY. > https://www.rmetrics.org --- Mail to: i...@rmetrics.org > Loading required package: fOptions > > > Rmetrics Package fOptions > Pricing and Evaluating Basic Options > Copyright (C) 2005-2014 Rmetrics Association Zurich > Educational Software for Financial Engineering and Computational Science > Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY. > https://www.rmetrics.org --- Mail to: i...@rmetrics.org > > Attaching package: ‘prob’ > > The following objects are masked from ‘package:dplyr’: > > intersect, setdiff, union > > The following objects are masked from ‘package:base’: > > intersect, setdiff, union > > > > > > > > > Tiby > &g
Re: [R] "prob" package alternative
> On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz wrote: > > Yes. That's the version I've been discussing that has non-zero exit status. > That situation is why CRAN retired the prob package. It's possible you > installed that library earlier in development and it's been "carried" along. > It no longer installs, now. > > The problems with all of this seem to have started this month according to > the conversations. However, no one has mentioned any solutions or workarounds > except the one mentioned in passing (2.9). Not true. Not even close to being true. I explained it all on the SO question page that you posted 2 days ago. -- David. > > Is there some other package that does something similar to prob that can be > used instead? > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius > wrote: > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz wrote: > > > > The issue is fAsianOptions. Is there a version that works with the latest > > version of R? If not, which version of it works with which version of R and > > where can it be found? I tried several at the archive already. > > sessionInfo() > R version 3.4.2 Patched (2017-10-04 r73465) > Platform: x86_64-apple-darwin15.6.0 (64-bit) > Running under: OS X El Capitan 10.11.6 > > > > > > packageDescription("fAsianOptions") > Package: fAsianOptions > Version: 3010.79 > Revision: 5522 > Date: 2013-06-23 > Title: EBM and Asian Option Valuation > Author: Diethelm Wuertz and many others, see the SOURCE file > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions > Suggests: RUnit > Maintainer: Yohan Chalabi > Description: Environment for teaching "Financial Engineering and > Computational Finance" > Note: Several parts are still preliminary and may be changed in the future. > this > typically includes function and argument names, as well as defaults > for > arguments and return values. > LazyData: yes > License: GPL (>= 2) > URL: http://www.rmetrics.org > Packaged: 2013-06-23 18:22:14 UTC; yohan > NeedsCompilation: yes > Repository: CRAN > Date/Publication: 2013-06-24 01:53:27 > Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix > > > > > Alternatively, is there another package that behaves similarly to prob? > > > > > > > > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius > > wrote: > > > > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz wrote: > > > > > > The prob package has been archived because it depends upon some other > > > packages which have issues. > > > > > > However, such projects as Introduction to Probability and Statistics in R > > > depend upon it for learning. There are a few other resources that also use > > > it. > > > > > > Does anyone know of any workarounds? > > > > > > Someone at stack exchange mentioned using R 2.9. > > > > I'm not sure I would trust that person. They seem a bit uninformed. > > > > > However, that broke my > > > RStudio (WSOD) and the dependent packages still wouldn't install, anyway. > > > > The latest version of pkg-prob at the Archive directory of CRAN indicates > > that it was last updated within this year. The DESCRIPTION file indicates > > that it does not need compilation, but: > > > > Depends: combinat, fAsianOptions > > > > So there should be code in text files in its ../R directory which can be > > sourced from that directory. > > > > ~myuser_name$ ls /Users/../Downloads/prob/R > > characteristicfunctions.r simulation.r > > utils-spaces.r > > genData.R spaces-examples.r > > utils-subsets.r > > misc.r spaces-prob.r > > prob.r utils-events.r > > > > > > Or you can install from source after downloading: > > > > install.packages("~/Downloads/prob", repo=NULL,type="source") > > > > # Success > > > > > > > library(prob) # So does require having several other packages > > Loading required package: combinat > > > > Attaching package: ‘combinat’ > > > > The following object is masked from ‘package:utils’: > > > > combn > > > > Loading required package: fAsianOptions > > Loading required package: timeDate > > > > Attaching package: ‘timeDate’ > > > > The following object is masked from ‘package:cairoDevice’: > >
Re: [R] "prob" package alternative
> On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz wrote: > > Yes, that is exactly what I was doing two days ago. > > Warning in install.packages : > installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero exit > status > > Which is what a reading of the explanation for why "prob" was retired leads > one to expect. Do you have some other suggestion about how to get it to work? > I notice you're not using Windows which might have a relationship to why it > is working for you. I explained what you needed to do if you were on Windows. You do need to read the explanation more closely, identify the parts you don't understand (in all likelihood the point I made about needing the proper development tools for Windows) _and_ read: https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-packages If you have trouble understanding or getting success after thoroughly reading these directions, you need to explain what you have done (preserving the order of all operations) and post a complete transcript of all commands and complete error messages. -- David. > Otherwise, do you know of some other package that could be used instead of > prob? > > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius > wrote: > > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz wrote: > > > > Yes. That's the version I've been discussing that has non-zero exit status. > > That situation is why CRAN retired the prob package. It's possible you > > installed that library earlier in development and it's been "carried" > > along. It no longer installs, now. > > > > The problems with all of this seem to have started this month according to > > the conversations. However, no one has mentioned any solutions or > > workarounds except the one mentioned in passing (2.9). > > Not true. Not even close to being true. I explained it all on the SO question > page that you posted 2 days ago. > > -- > > David. > > > > Is there some other package that does something similar to prob that can be > > used instead? > > > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius > > wrote: > > > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz wrote: > > > > > > The issue is fAsianOptions. Is there a version that works with the latest > > > version of R? If not, which version of it works with which version of R > > > and where can it be found? I tried several at the archive already. > > > > sessionInfo() > > R version 3.4.2 Patched (2017-10-04 r73465) > > Platform: x86_64-apple-darwin15.6.0 (64-bit) > > Running under: OS X El Capitan 10.11.6 > > > > > > > > > > > packageDescription("fAsianOptions") > > Package: fAsianOptions > > Version: 3010.79 > > Revision: 5522 > > Date: 2013-06-23 > > Title: EBM and Asian Option Valuation > > Author: Diethelm Wuertz and many others, see the SOURCE file > > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions > > Suggests: RUnit > > Maintainer: Yohan Chalabi > > Description: Environment for teaching "Financial Engineering and > > Computational Finance" > > Note: Several parts are still preliminary and may be changed in the future. > > this > > typically includes function and argument names, as well as > > defaults for > > arguments and return values. > > LazyData: yes > > License: GPL (>= 2) > > URL: http://www.rmetrics.org > > Packaged: 2013-06-23 18:22:14 UTC; yohan > > NeedsCompilation: yes > > Repository: CRAN > > Date/Publication: 2013-06-24 01:53:27 > > Built: R 3.4.2; x86_64-apple-darwin15.6.0; 2017-11-01 22:45:02 UTC; unix > > > > > > > > > Alternatively, is there another package that behaves similarly to prob? > > > > > > > > > > > > On Wed, Nov 1, 2017 at 6:17 PM, David Winsemius > > > wrote: > > > > > > > On Nov 1, 2017, at 12:51 PM, Tiby Kantrowitz wrote: > > > > > > > > The prob package has been archived because it depends upon some other > > > > packages which have issues. > > > > > > > > However, such projects as Introduction to Probability and Statistics in > > > > R > > > > depend upon it for learning. There are a few other resources that also > > > > use > > > > it. > > > > > > > > Does anyone know of any workarounds? > > > > > > > > Someone at stack exchange mentioned using R 2.
Re: [R] "prob" package alternative
> On Nov 2, 2017, at 2:14 PM, Tiby Kantrowitz wrote: > > Rtools is not available for the current version of R. Really? If true, I'm surprised and not able to help. I do see an Rtools34.exe at https://cran.r-project.org/bin/windows/Rtools/ -- David. > > What I'm looking for is an alternative package or how others have managed to > create workarounds. > > On Thu, Nov 2, 2017 at 4:25 PM, David Winsemius > wrote: > > > On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz wrote: > > > > Yes, that is exactly what I was doing two days ago. > > > > Warning in install.packages : > > installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero exit > > status > > > > Which is what a reading of the explanation for why "prob" was retired leads > > one to expect. Do you have some other suggestion about how to get it to > > work? I notice you're not using Windows which might have a relationship to > > why it is working for you. > > > I explained what you needed to do if you were on Windows. You do need to read > the explanation more closely, identify the parts you don't understand (in all > likelihood the point I made about needing the proper development tools for > Windows) _and_ read: > > https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-packages > > If you have trouble understanding or getting success after thoroughly reading > these directions, you need to explain what you have done (preserving the > order of all operations) and post a complete transcript of all commands and > complete error messages. > > > > -- > David. > > Otherwise, do you know of some other package that could be used instead of > > prob? > > > > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius > > wrote: > > > > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz wrote: > > > > > > Yes. That's the version I've been discussing that has non-zero exit > > > status. That situation is why CRAN retired the prob package. It's > > > possible you installed that library earlier in development and it's been > > > "carried" along. It no longer installs, now. > > > > > > The problems with all of this seem to have started this month according > > > to the conversations. However, no one has mentioned any solutions or > > > workarounds except the one mentioned in passing (2.9). > > > > Not true. Not even close to being true. I explained it all on the SO > > question page that you posted 2 days ago. > > > > -- > > > > David. > > > > > > Is there some other package that does something similar to prob that can > > > be used instead? > > > > > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius > > > wrote: > > > > > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz wrote: > > > > > > > > The issue is fAsianOptions. Is there a version that works with the > > > > latest version of R? If not, which version of it works with which > > > > version of R and where can it be found? I tried several at the archive > > > > already. > > > > > > sessionInfo() > > > R version 3.4.2 Patched (2017-10-04 r73465) > > > Platform: x86_64-apple-darwin15.6.0 (64-bit) > > > Running under: OS X El Capitan 10.11.6 > > > > > > > > > > > > > > > > packageDescription("fAsianOptions") > > > Package: fAsianOptions > > > Version: 3010.79 > > > Revision: 5522 > > > Date: 2013-06-23 > > > Title: EBM and Asian Option Valuation > > > Author: Diethelm Wuertz and many others, see the SOURCE file > > > Depends: R (>= 2.4.0), timeDate, timeSeries, fBasics, fOptions > > > Suggests: RUnit > > > Maintainer: Yohan Chalabi > > > Description: Environment for teaching "Financial Engineering and > > > Computational Finance" > > > Note: Several parts are still preliminary and may be changed in the > > > future. this > > > typically includes function and argument names, as well as > > > defaults for > > > arguments and return values. > > > LazyData: yes > > > License: GPL (>= 2) > > > URL: http://www.rmetrics.org > > > Packaged: 2013-06-23 18:22:14 UTC; yohan > > > NeedsCompilation: yes > > > Repository: CRAN > > > Date/Publication: 2013-06-24 01:53:27 > > > Built: R 3.4.2; x86_64-apple-dar
Re: [R] "prob" package alternative
> On Nov 2, 2017, at 3:46 PM, Tiby Kantrowitz wrote: > > Thanks. I found that, and installed it and got the same message. Here: > > RTools version 3.4 > > install.packages("fAsianOptions_3010.tar.gz", I don't see a path to that file's location. The expansion from pkg_version.tar.gz might be automatic, but I do generally expand such file into its own directory and then drag that directory icon into the console so my command would look like: install.packages("~/Downloads/fAsianOptions", dependencies=TRUE, repos=NULL, type = "source") I suggest you learn to post in plain text since your HTML postings are loosing their carriage returns. -- David > dependencies=TRUE, repos=NULL, type = "source") > Installing package into ‘C:/Users/Tlk7/Documents/R/win-library/3.4’ (as ‘lib’ > is unspecified) Warning: invalid package 'fAsianOptions_3010.tar.gz' Error: > ERROR: no packages specified Warning in install.packages : running command > '"C:/PROGRA~1/R/R-34~1.2/bin/x64/R" CMD INSTALL -l > "C:\Users\Tlk7\Documents\R\win-library\3.4" "fAsianOptions_3010.tar.gz"' had > status 1 Warning in install.packages : installation of package > ‘fAsianOptions_3010.tar.gz’ had non-zero exit status > > On Thu, Nov 2, 2017 at 6:06 PM, David Winsemius > wrote: > > > On Nov 2, 2017, at 2:14 PM, Tiby Kantrowitz wrote: > > > > Rtools is not available for the current version of R. > > Really? If true, I'm surprised and not able to help. I do see an Rtools34.exe > at https://cran.r-project.org/bin/windows/Rtools/ > -- > David. > > > > > What I'm looking for is an alternative package or how others have managed > > to create workarounds. > > > > On Thu, Nov 2, 2017 at 4:25 PM, David Winsemius > > wrote: > > > > > On Nov 2, 2017, at 1:09 PM, Tiby Kantrowitz wrote: > > > > > > Yes, that is exactly what I was doing two days ago. > > > > > > Warning in install.packages : > > > installation of package ‘fAsianOptions_3010.79.tar.gz’ had non-zero > > > exit status > > > > > > Which is what a reading of the explanation for why "prob" was retired > > > leads one to expect. Do you have some other suggestion about how to get > > > it to work? I notice you're not using Windows which might have a > > > relationship to why it is working for you. > > > > > > I explained what you needed to do if you were on Windows. You do need to > > read the explanation more closely, identify the parts you don't understand > > (in all likelihood the point I made about needing the proper development > > tools for Windows) _and_ read: > > > > https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-packages > > > > If you have trouble understanding or getting success after thoroughly > > reading these directions, you need to explain what you have done > > (preserving the order of all operations) and post a complete transcript of > > all commands and complete error messages. > > > > > > > > -- > > David. > > > Otherwise, do you know of some other package that could be used instead > > > of prob? > > > > > > On Thu, Nov 2, 2017 at 3:44 PM, David Winsemius > > > wrote: > > > > > > > On Nov 2, 2017, at 12:07 PM, Tiby Kantrowitz wrote: > > > > > > > > Yes. That's the version I've been discussing that has non-zero exit > > > > status. That situation is why CRAN retired the prob package. It's > > > > possible you installed that library earlier in development and it's > > > > been "carried" along. It no longer installs, now. > > > > > > > > The problems with all of this seem to have started this month according > > > > to the conversations. However, no one has mentioned any solutions or > > > > workarounds except the one mentioned in passing (2.9). > > > > > > Not true. Not even close to being true. I explained it all on the SO > > > question page that you posted 2 days ago. > > > > > > -- > > > > > > David. > > > > > > > > Is there some other package that does something similar to prob that > > > > can be used instead? > > > > > > > > On Thu, Nov 2, 2017 at 2:29 PM, David Winsemius > > > > wrote: > > > > > > > > > On Nov 2, 2017, at 11:15 AM, Tiby Kantrowitz > >
Re: [R] Problem with r project in ubuntu xenial
> On Nov 3, 2017, at 5:09 PM, peter dalgaard wrote: > > >> On 3 Nov 2017, at 23:39 , George Balas wrote: >> >> I have a problem with R in Ubuntu 16.04. I do not know if it is mine pc or >> general problem but I was not able to find solution on Internet. >> First of all I can not change locale to greek by getting this message: >> "In Sys.setlocale("LC_CTYPE", "Greek") : >> OS reports request to set locale to "Greek" cannot be honored" > > The Greek locale is likely not called "Greek" outside of Windows. More likely > "el_GR.UTF-8" or thereabouts (check your locale database, I'm on a Mac). > These things are not standardized across platforms. > Also >From help(locales): Attempts to change the character set by >Sys.setlocale("LC_CTYPE") that implies a different character set during a >session may not work and are likely to lead to some confusion because it may >not affect the native encoding. >> Second and more serious is that I can not use some functions like >> graph_from_adjacency_matrix or print_all I get these messeges: >> "could not find function "graph_from_adjacency_matrix"" >> "could not find function "print_all"". > > Missing library(igraph)? > > -pd > >> I am using R version 3.4.2 (2017-09-28) -- "Short Summer" either on rstudio >> or ubuntu terminal. >> On my pc I also run win 10 with the same installs and I do not have the >> above problems, but I work on ubuntu and can not change Os all the time. >> Please help me. >> >> Thank you for your time, >> George >> gbala...@gmail.com >> >> [[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. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd@cbs.dk Priv: pda...@gmail.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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Change colour of line in logi.hist.plot
> On Nov 5, 2017, at 6:03 AM, Göran Bergqvist > wrote: > > I am using the function logi.hist.plot in package popbio. I want to change > the colour of the probability line from the default red to black. I have not > been able to find out how to do that. If you look at the code for that function you see this line: logi.curve <- function(independ, depend, mod = logi.mod, col.cur = "red", lwd.cur = 4) { Since it's the only occurence of "red" that's probably where "the money lies". You can either do a "hard hack" where you alter the value of the parameters to that inner function, ... or you can add a named parameter after the dots in the outer parameter list such as: function (independ, depend, logi.mod = 1, type = "dit", boxp = TRUE, rug = FALSE, ylabel = "Probability", ylabel2 = "Frequency", xlabel = "", mainlabel = "", las.h = 1, counts = FALSE, ..., col.cur = "red") ... and modify the inner function to read: logi.curve <- function(independ, depend, mod = logi.mod, col.cur = col.cur, lwd.cur = 4) { > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Help in R
> On Nov 5, 2017, at 9:28 AM, Ahsan Zahir via R-help > wrote: > > > Hey, > > I am a beginner in R. > > How do I read last 10 values from column- Movie, from a dataset? Some questions are so simple that they strongly suggest no prior effort at self-leanrning. In such cases the usual recommendation given at Rhelp is that you read an introductory text. Many of us used the "Introduction to R" that is shipped with every copy of R: https://cran.r-project.org/doc/manuals/r-release/R-intro.pdf > > Pls help. > > Sent from my iPhone > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Survival model error
You should stop trying to use matrices on the RHS and using separate vectors to Surv. Instead use a data argument and have the names in your formula refer to column names. — David Sent from my iPhone > On Nov 5, 2017, at 7:21 PM, Meghna Govil via R-help > wrote: > > > Hi - Below is my code and then the error when I run the last line. > > time_np <- train1_na$tte > event_np <- train1_na$censored > > > X_np <- cbind( > train1_na$AMT, > train1_na$DISCOUNT_AMT, > train1_na$high_price_pcnt, > train1_na$EM_RECEIVED, > train1_na$DM_RECEIVED, > train1_na$TXN_WITH_RINGCODE, > train1_na$WEB, > train1_na$clearance_pcnt, > train1_na$bts_pcnt, > train1_na$sales_pcnt, > train1_na$holiday_pcnt, > train1_na$TXN, > train1_na$REDEEMED_REWARDS > > ) > > # Kaplan-Meier non-parametric analysis > > kmsurvival_np <- survfit(Surv(time_np,event_np) ~ X_np) > > Error in `[.default`(y, who, 1) : (subscript) logical subscript too long > > Any ideas? > I have tried several things and still get this error. > > > Thanks, > Meghna > > __ > 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] Survival model error
> On Nov 6, 2017, at 5:45 AM, Meghna Govil wrote: > > Thanks David. Could you show me how to do that in my example ? Possibly: kmsurvival_np <- survfit(Surv( tte, censored) ~ . , data=train1_na) I say "possibly" because I don't know whether all the columns of `train1_na` were included in the matrix you constructed. If they weren't then you would need to do something like: kmsurvival_np <- survfit(Surv( tte, censored) ~ , data=train1_na) The formalism of `reg_func( Y , Xm)` Where Xm is a matrix is typical for various machine-learning types of procedures, but breaks the "process-names-in-an-environment model of typical R regression functions. R regression functions often omit "step-down" options so loved by beginning SAS users. > > Thanks, > Meghna > >> On Nov 6, 2017, at 12:58 AM, David Winsemius wrote: >> >> You should stop trying to use matrices on the RHS and using separate vectors >> to Surv. Instead use a data argument and have the names in your formula >> refer to column names. >> >> — >> David >> >> Sent from my iPhone >> >>> On Nov 5, 2017, at 7:21 PM, Meghna Govil via R-help >>> wrote: >>> >>> >>> Hi - Below is my code and then the error when I run the last line. >>> >>> time_np <- train1_na$tte >>> event_np <- train1_na$censored >>> >>> >>> X_np <- cbind( >>> train1_na$AMT, >>> train1_na$DISCOUNT_AMT, >>> train1_na$high_price_pcnt, >>> train1_na$EM_RECEIVED, >>> train1_na$DM_RECEIVED, >>> train1_na$TXN_WITH_RINGCODE, >>> train1_na$WEB, >>> train1_na$clearance_pcnt, >>> train1_na$bts_pcnt, >>> train1_na$sales_pcnt, >>> train1_na$holiday_pcnt, >>> train1_na$TXN, >>> train1_na$REDEEMED_REWARDS >>> >>> ) >>> >>> # Kaplan-Meier non-parametric analysis >>> >>> kmsurvival_np <- survfit(Surv(time_np,event_np) ~ X_np) >>> >>> Error in `[.default`(y, who, 1) : (subscript) logical subscript too long >>> >>> Any ideas? >>> I have tried several things and still get this error. >>> >>> >>> Thanks, >>> Meghna >>> >>> __ >>> 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Fitdistrplus and Custom Probability Density
> On Nov 7, 2017, at 6:58 AM, Eric Berger wrote: > > Why not define your own functions based on d? > e.g. > myCumDist <- function(x) { integrate(d, lower=-Inf, upper=x)$value } > myQuantile <- function(x) { uniroot(f=function(y) { h(y) - x }, > interval=c(-5,5)) } # limits -5,5 should be replaced by your own which > might require some fiddling My test gave an error regarding a missing `h` function. Perhaps you meant something like: myQuantile <- function(x) { uniroot(f=function(y) { myCumDist(y)-x }, interval=c(-5,5))$root } I added the $root extraction so it now returns a numeric value instead of a list. I wondered if that might be somewhat slow, and considered the possibility of building a close aproximation that didn't require a combined integration and rootfinding operation for every value using approxfun() on a suitable range of p-values in the range [0,1] -- David. > > e.g. > d <- function(x) { exp(-x^2/2)/(sqrt(2*pi)) } # just an example for you to > test with; use your own density d(x) in your case > > Then define myCumDist, myQuantile as above and compare with pnorm, qnorm. > > HTH, > Eric > > > > > On Tue, Nov 7, 2017 at 4:22 PM, Lorenzo Isella > wrote: > >> Dear All, >> Apologies for not providing a reproducible example, but if I could, then I >> would be able to answer myself my question. >> Essentially, I am trying to fit a very complicated custom probability >> distribution to some data. >> Fitdistrplus does in principle everything which I need, but if require me >> to specify not only the density function d, but also the cumulative p and >> and inverse cumulative function q (see for instance >> >> http://www.stat.umn.edu/geyer/old/5101/rlook.html >> >> to understand what these quantities are in the case of a normal >> distribution). >> >> The analytical calculation of p and q is a big task in my case, so my >> question is if there is a workaround for this, i.e. a way to fit the >> unknown parameters of my probability distribution without specifying (at >> least analytically) p and q, but only the density d. >> Many thanks >> >> Lorenzo >> >>[[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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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 r project in ubuntu xenial
> On Nov 7, 2017, at 3:46 PM, George Balas wrote: > > For anyone who sees this conversation. > > There is a bug in installation of igraph in R language in Ubuntu. There is > a solution in stackoverflow. We have to use the devtools. Write this code: > install.packages("devtools") > library(devtools) > install_github("igraph/rigraph") If there is a bug in the development version of igraph (which is not really part of R but rather a contributed package) then the correct place to send a message would have been, not to rhelp, but rather to the maintainer. It would of course be necessary to say what the bug appears to be. I don't see any error message or description of a bug in this message. The package DESCRIPTION files says: BugReports: https://github.com/igraph/igraph/issues The github page says the proper installation sequence for the development version is: devtools::install_github("gaborcsardi/pkgconfig") devtools::install_github("igraph/rigraph") Rhelp is not the correct place for pre-release bug discussion of contributed packages. Again, the github pages suggests that you send issues to the correct mailing list: igraph-help mailing list https://lists.nongnu.org/mailman/listinfo/igraph-help -- David. > > If there are errors installing devtools just install any package that > comments. > > On Nov 5, 2017 00:07, "George Balas" wrote: > >> -Well it seems that it is getting "el_GR.UTF-8" but still I am not able >> to read files written in greek, there are only "" instead of letters. >> -Also, I forgot to mention that I do load igraph library when I try >> "graph_from_adjacency_matrix". >> When I check igraph in packages dialog I can not see functions with >> underscores between words, only dots. >> >> 2017-11-04 2:22 GMT+02:00 David Winsemius : >> >>> >>>> On Nov 3, 2017, at 5:09 PM, peter dalgaard wrote: >>>> >>>> >>>>> On 3 Nov 2017, at 23:39 , George Balas wrote: >>>>> >>>>> I have a problem with R in Ubuntu 16.04. I do not know if it is mine >>> pc or >>>>> general problem but I was not able to find solution on Internet. >>>>> First of all I can not change locale to greek by getting this message: >>>>> "In Sys.setlocale("LC_CTYPE", "Greek") : >>>>> OS reports request to set locale to "Greek" cannot be honored" >>>> >>>> The Greek locale is likely not called "Greek" outside of Windows. More >>> likely "el_GR.UTF-8" or thereabouts (check your locale database, I'm on a >>> Mac). These things are not standardized across platforms. >>>> >>> >>> Also >>> >>> From help(locales): Attempts to change the character set by >>> Sys.setlocale("LC_CTYPE") that implies a different character set during a >>> session may not work and are likely to lead to some confusion because it >>> may not affect the native encoding. >>> >>> >>>>> Second and more serious is that I can not use some functions like >>>>> graph_from_adjacency_matrix or print_all I get these messeges: >>>>> "could not find function "graph_from_adjacency_matrix"" >>>>> "could not find function "print_all"". >>>> >>>> Missing library(igraph)? >>>> >>>> -pd >>>> >>>>> I am using R version 3.4.2 (2017-09-28) -- "Short Summer" either on >>> rstudio >>>>> or ubuntu terminal. >>>>> On my pc I also run win 10 with the same installs and I do not have the >>>>> above problems, but I work on ubuntu and can not change Os all the >>> time. >>>>> Please help me. >>>>> >>>>> Thank you for your time, >>>>> George >>>>> gbala...@gmail.com >>>>> >>>>> [[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/posti >>> ng-guide.html >>>>> and provide commented, minimal, self-contained, reproducible code. >>>> >>>> -- >>>> Peter Dalgaard, Professor, >>>> Center for St
Re: [R] Primer for working with survey data in R
> On Nov 11, 2017, at 11:56 AM, Kevin Taylor wrote: > > I am taking a behavioral stats graduate class and the instructor is using > SPSS. I'm trying to follow along in R. > > Recently in class we started working with scales and survey data, computing > Cronbach's Alpha, reversing values for reverse coded items, etc. > > Also, SPSS has some built in functionality for entering the meta-data for > your survey, e.g. the possible values for items, the text of the question, > etc. > > I haven't been able to find any survey guidance for R other than how to run > the actual calculations (Cronbach's, reversing values). > > Are there tutorials, books, or other primers, that would guide a newbie > step by step through using R for working with survey data? It would be > helpful to see how others are doing these things. (Not just how to run the > mathematical operations but how to work with and manage the data.) Possibly > this would be in conjunction with some packages such as Likert or Scales. Try looking at: http://personality-project.org/r/psych/ -- David. > > TIA. > > --Kevin > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Primer for working with survey data in R
> On Nov 11, 2017, at 2:36 PM, Fox, John wrote: > > Dear Kevin, > > In addition to the advice you've received, take a look at the survey package. > It's not quite what you're asking for, but in fact it's probably more useful, > in that it provides correct statistical inference for data collected in > complex surveys. The package is described in an article, T. Lumley (2004), > Analysis of complex survey samples, Journal of Statistical Software 9(1): > 1-19, and a book, T. Lumley, Complex Surveys: A Guide to Analysis Using R, > Wiley, 2010, both by the package author. Although the same thought occurred to me after reading the initial question, I decided against suggesting the survey package. I consulted the recommended book above and it has none of the requested statistics. It is designed for surveys that use complex sampling designs requiring weighting the observations. I also consulted the Social Sciences Task View and it seemed unhelpful for the specific requests. It seemed likely to me that even a graduate course in behavioral statistics would be focussed on the sorts of questions that the psych package delivers. The website maintained by Revelle has several tutorials that include developed examples using R to deliver the requested measure. Obviously "reversing values" is something that would require learning basic R manipulation of factor variables. -- David. > > I hope that this helps, > John > >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kevin Taylor >> Sent: Saturday, November 11, 2017 2:57 PM >> To: r-help@r-project.org >> Subject: [R] Primer for working with survey data in R >> >> I am taking a behavioral stats graduate class and the instructor is using >> SPSS. >> I'm trying to follow along in R. >> >> Recently in class we started working with scales and survey data, computing >> Cronbach's Alpha, reversing values for reverse coded items, etc. >> >> Also, SPSS has some built in functionality for entering the meta-data for >> your >> survey, e.g. the possible values for items, the text of the question, etc. >> >> I haven't been able to find any survey guidance for R other than how to run >> the >> actual calculations (Cronbach's, reversing values). >> >> Are there tutorials, books, or other primers, that would guide a newbie step >> by >> step through using R for working with survey data? It would be helpful to see >> how others are doing these things. (Not just how to run the mathematical >> operations but how to work with and manage the data.) Possibly this would be >> in conjunction with some packages such as Likert or Scales. >> >> TIA. >> >> --Kevin >> >> [[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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Bootstrap analysis from a conditional logistic regression
> On Nov 13, 2017, at 2:01 PM, Nelly Reduan wrote: > > Nelly Reduan a partag� un fichier OneDrive avec vous. Pour l�afficher, > cliquez sur le lien ci-dessous. > > > <https://1drv.ms/u/s!Apkg2VlgfYyDgRAeVIM0nEajx0Fb> > [https://r1.res.office365.com/owa/prem/images/dc-png_20.png]<https://1drv.ms/u/s!Apkg2VlgfYyDgRAeVIM0nEajx0Fb> > > Screenshot 2017-11-12 > 18.49.43.png<https://1drv.ms/u/s!Apkg2VlgfYyDgRAeVIM0nEajx0Fb> > > > > > Hello > > How can I perform a bootstrap analysis from a conditional logistic > regression? The model has been built using the `clogit` function (`survival` > package)? The model has the following structure: > >mod <- clogit(event ~ forest + log_area +forest:log_time + > cluster(ID_individual) + strata(ID_strata), method = "efron", data = data > , x=T, y=T) > > Using bootstrapping, I would like to have a measure of uncertainty around the > estimates of beta coefficients. > > I am using the following code but I don't know how to consider strata and > cluster arguments. > >library(boot) >boot.clogit <- function(data, indices){ > new_data <- data[indices,] > mod <- clogit(event ~ forest + log_area + forest:log_time + > cluster(ID_individual) + strata(ID_strata), >method = "efron", data = new_data, x=T, y=T) > coefficients(mod) >} > >boot_data <- boot(data=data, statistic=boot.clogit, R=5000) > > I have attached an overview of my data set. You probably tried to attach something but you failed to note the section in the listinfo or posting guide where the list owners describe the rules for attachments. I think you would need to describe the sampling design more thoroughly. A simple description of the data layout may not be sufficient. The fact that you are clustering on individuals suggests you have some sort of repeated measures design and that you have somehow matched the individual to controls in some unstated ratio (handled by the strata. (Admittedly all guesswork and the more knowledgeable respondents (among which I'm not likely to reside) are often hesitant to contribute substantive commentary unless they can narrow down range of possible design issues. I read Davison and Hinkley as suggesting that sampling by group but then keeping sampled groups undisturbed may have better chance of resulting in estimates of variances that match the superpopulation. See pages 100-102 of their book. If my reading of that section is correct then I should think you would arrange you data so groups are in the long direction and single groups occupy a line of data with a single index. Then you would probably rearrange the data within the boot.clogit function so that the "inner" clogit call can handle it correctly. -- David. > > Thank you very much for your time. > Best regards, > Nell > > > > > > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] error message for function: lmer (from lme4 package)
> On Nov 14, 2017, at 5:13 AM, Fix Ace via R-help wrote: > > Dear R Community, > My data have 3 conditions and each condition has 6 replicates. I am trying to > fit my data for a linear mixed model using the lmer function from lme4 > package to find the random effects of the replicates; Better venue for this question might be SIG-mixed-models. See the link avaialble at the bottom of every posting from rhelp: https://stat.ethz.ch/mailman/listinfo/r-help: > however, I got the error message. Here are the example codes: >> example.3=data.frame(levels=as.numeric(XXX[,c(4)]),replicate=rep(c("0","1","2","3","4","5"),3),conditions=c(rep("11",6),rep("12",6),rep("13",6)))> >> example.3levels replicate conditions1 43. 0 112 >> 42.0942 1 113 57.8131 2 114 57.1726 >> 3 115 77.8678 4 116 44.7578 5 117 >> 69.5078 0 128 52.0581 1 129 40.0602 >> 2 1210 45.5487 3 1211 43.6201 4 >> 1212 60.4939 5 1213 64.1932 0 1314 53.4055 >> 1 1315 59.6701 2 1316 52.6922 3 >> 1317 53.8712 4 1318 60.2770 5 13> >> m.example.3=lmer(as.numeric(levels)~conditions+(conditions|replicate),data=example.3)Error: >> number of observations (=18) <= number of random effects (=18) for term >> (conditions | replicate); the random-effects parameters and the residual >> variance (o r scale parameter) are probably unidentifiable> > Could anyone help me figure out how to fix the issue? > Thank you very much for any inputs! > Ace > > [[alternative HTML version deleted]] Complete mess. If you haven't yet been advised to posting in plain text, then this should be your wakeup call. If you have, then why are you ignoring sensible advice? > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] error message for function: lmer (from lme4 package)
> On Nov 14, 2017, at 12:49 PM, Fix Ace wrote: > > Hi, David, > > Thank you very much for getting back to me! Sorry about the messy code > example. I am re-posting here (including the error message): > > > example.3=data.frame(levels=as.numeric(XXX[,c(4)]),replicate=rep(c("0","1","2","3","4","5"),3),conditions=c(rep("11",6),rep("12",6),rep("13",6))) > > example.3 > levels replicate conditions > 1 43. 0 11 > 2 42.0942 1 11 > 3 57.8131 2 11 > 4 57.1726 3 11 > 5 77.8678 4 11 > 6 44.7578 5 11 > 7 69.5078 0 12 > 8 52.0581 1 12 > 9 40.0602 2 12 > 10 45.5487 3 12 > 11 43.6201 4 12 > 12 60.4939 5 12 > 13 64.1932 0 13 > 14 53.4055 1 13 > 15 59.6701 2 13 > 16 52.6922 3 13 > 17 53.8712 4 13 > 18 60.2770 5 13 > > m.example.3=lmer(as.numeric(levels)~conditions+(conditions|replicate),data=example.3) > Error: number of observations (=18) <= number of random effects (=18) for > term (conditions | replicate); the random-effects parameters and the residual > variance (or scale parameter) are probably unidentifiable The error message seems fairly clear. The formula you have provided is asking for estimation of too many parameters. I think you probably want: m.example.3=lmer(levels~conditions+(1|replicate),data=example.3) ... although your description of the hypothesis under test is ... non-existent. -- David. > > > > Please let me know if it is readable this time. > > Again, many thanks for your time and please help me fix the issue. > > Kind regards, > > Ace > > > On Tuesday, November 14, 2017 12:19 PM, David Winsemius > wrote: > > > > > On Nov 14, 2017, at 5:13 AM, Fix Ace via R-help > > wrote: > > > > Dear R Community, > > My data have 3 conditions and each condition has 6 replicates. I am trying > > to fit my data for a linear mixed model using the lmer function from lme4 > > package to find the random effects of the replicates; > > Better venue for this question might be SIG-mixed-models. See the link > avaialble at the bottom of every posting from rhelp: > > https://stat.ethz.ch/mailman/listinfo/r-help: > > > > > > however, I got the error message. Here are the example codes: > >> example.3=data.frame(levels=as.numeric(XXX[,c(4)]),replicate=rep(c("0","1","2","3","4","5"),3),conditions=c(rep("11",6),rep("12",6),rep("13",6)))> > >> example.3levels replicate conditions1 43.0 112 > >> 42.09421113 57.81312114 57.17263 > >>115 77.86784116 44.75785117 > >> 69.50780128 52.05811129 40.06022 > >>1210 45.548731211 43.620141212 > >> 60.493951213 64.193201314 53.40551 > >>1315 59.670121316 52.692231317 > >> 53.871241318 60.2770513> > >> m.example.3=lmer(as.numeric(levels)~conditions+(conditions|replicate),data=example.3)Error: > >> number of observations (=18) <= number of random effects (=18) for term > >> (conditions | replicate); the random-effects parameters and the residual > >> variance (or scale parameter) are probably u nidentifiable> > > Could anyone help me figure out how to fix the issue? > > Thank you very much for any inputs! > > Ace > > > > > [[alternative HTML version deleted]] > > Complete mess. If you haven't yet been advised to posting in plain text, then > this should be your wakeup call. If you have, then why are you ignoring > sensible advice? > > > > > > __ > > 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 > > 'Any technology distinguishable from magic is insufficiently advanced.' > -Gehm's Corollary to Clarke's Third Law > > > > > > > David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Problems installing mice package
> On Nov 15, 2017, at 1:08 AM, Jeremie Juste wrote: > > > > Hello, > > I tried intalling mice package and got the following error: > > * installing *source* package ‘mice’ ... > ** package ‘mice’ successfully unpacked and MD5 sums checked > ** libs > g++ -I/usr/local/lib/R/include -DNDEBUG > -I"/home/djj/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" > -I/usr/local/include -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o > g++ -I/usr/local/lib/R/include -DNDEBUG > -I"/home/djj/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" > -I/usr/local/include -fpic -g -O2 -c match.cpp -o match.o > g++ -shared -L/usr/local/lib -o mice.so RcppExports.o match.o Welcome to R! > Goodbye! Somehow you have sent an R "welcome message" to the installer script. What was the action that started all this? Were you in an R session or was this something done from a bash console? > g++: error: Welcome: No such file or directory > g++: error: to: No such file or directory > g++: error: R!: No such file or directory > g++: error: Goodbye!: No such file or directory > /usr/local/lib/R/share/make/shlib.mk:6: recipe for target 'mice.so' failed > make: *** [mice.so] Error 1 > ERROR: compilation failed for package ‘mice’ > * removing ‘/home/djj/R/x86_64-pc-linux-gnu-library/3.4/mice’ > > The downloaded source packages are in > ‘/tmp/Rtmpgam70t/downloaded_packages’ > Error in library(mice) : there is no package called ‘mice’ > In addition: Warning message: > In : That's a rather strange method for invoking install.packages. Usually it would be just: install.packages("mice", repos = "http://cran.us.r-project.org";) Your best venue for linux installation questions is probably: https://stat.ethz.ch/mailman/listinfo/r-sig-db > installation of package ‘mice’ had non-zero exit status > > I'm unable to resolve it. Any help please? > > Best regards, > > Jeremie > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Autologistic regression in R
> On Nov 14, 2017, at 4:39 PM, Mingke Li wrote: > > Hi, > > I am new to autologistic regression and R. I do have questions when starting > a project in which I believe autologistic regression is needed. > > I have a point layer whose attribute table stores the values of the dependent > variable and all the independent variables. I hope to to fit an autologistic > model to analyze which factors or combinations of factors have effects on the > presence/absence of the dependent variable (1 or 0). > > I found other papers which applied autologistic regression in their study > almost used a grid system and defined their window sizes. So, my question is > do I have to convert my point layer to a grid system if I want to do this > analysis with R? > > Also, what should I consider when I generate the grid system? How to > determine a proper size of cells? How about the searching window sizes? Have you read the Posting Guide? -- David. > > Many Thanks. > > Erin > > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] 'fractal' package
https://rdrr.io/rforge/fractal/ https://cran.r-project.org/web/packages/fractal/fractal.pdf Hi, I am trying to learn about nonlinear time series, and fractal time series analysis in particular. I am interested in becoming proficient with the 'fractal' package. I have two specific questions: 1. I have a basic understanding of ARMA and ARIMA models. Can someone recommend a good introductory text on nonlinear time series that emphasizes practical application? I am definitely not looking for a theoretical text on stochastic process. 2. Can someone point me in the direction of case studies where the 'fractal' package has been used to analyze the stock market? My main interests are in the DOW Transportation Index and the S&P500, but in the absence of these kinds of case studies I will happily study any practical case studies that utilize the 'fractal' package. Many Thanks in Advance, David Paul [[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] error message for function: lmer (from lme4 package)
> snipped > > Hi, Bert, > Sorry about that! David seemed to be able to read the post since he replied. The only reason it appear readable was that you copied me as well as the list. Then HTML was still the basic format although it did npt appear that way to me since my reader could handle it without difficulty. Everybody else saw a "complete mess" as Bert accurately put it. Again, learn to post in plain text. Learn to post data objects with dput. -- David. > Here I just email you the sample code and error message: >> example.3=data.frame(levels= as.numeric(XXX[,c(4)]), >> replicate=rep(c("0","1","2"," 3","4","5"),3),conditions=c( >> rep("11",6),rep("12",6),rep(> example.3levels replicate conditions1 >> 43. 0 112 42.0942 1 113 57.8131 >> 2 114 57.1726 3 115 77.8678 4 116 >> 44.7578 5 117 69.5078 0 128 52.0581 >> 1 129 40.0602 2 1210 45.5487 3 >> 1211 43.6201 4 1212 60.4939 5 1213 64.1932 >> 0 1314 53.4055 1 1315 59.6701 2 >> 1316 52.6922 3 1317 53.8712 4 1318 60.2770 >>5 13> m.example.3=lmer(as.numeric( levels)~conditions+( >> conditions|replicate),data= example.3)Error in lmer(as.numeric(levels) ~ >> conditions + (conditions | replicate), : could not find function "lmer"> > Hopefully you could read it and provide some comments! > Thank you very much for your time. > Kind regards, > Ace snipped > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] family
> On Nov 17, 2017, at 4:28 PM, Val wrote: > > Hi all, > I am reading a huge data set(12M rows) that contains family information, > Offspring, Parent1 and Parent2 > > Parent1 and parent2 should be in the first column as an offspring > before their offspring information. Their parent information (parent1 > and parent2) should be set to zero, if unknown. Also the first > column should be unique. > > > Here is my sample data set and desired output. > > > fam <- read.table(textConnection(" offspring Parent1 Parent2 > Smith Alex1 Alexa > Carla Alex1 0 > Jacky Smith Abbot > Jack 0 Jacky > Almo JackCarla > "),header = TRUE) > > > > desired output. > Offspring Parent1 Parent2 > Alex1 00 > Alexa 00 > Abbot 00 > SmithAlex1 Alexa > CarlaAlex1 0 > JackySmith Abbot > Jack 0 Jacky > Almo JackCarla You might get useful ideas by looking at ?'%in%" and ?union (set operations) > fam$Parent1[!fam$Parent1 %in% fam$offspring] [1] "Alex1" "Alex1" "0" > fam$Parent2[!fam$Parent1 %in% fam$offspring] [1] "Alexa" "0" "Jacky" David. > > 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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Complicated analysis for huge databases
> On Nov 18, 2017, at 1:52 AM, Allaisone 1 wrote: > > Although the loop seems to be formulated correctly I wonder why > it gives me these errors : > > -object 'i' not found > - unexpected '}' in "}" You probably did not copy the entire code offered. But we cannot know since you did not "show your code", not=r did you post complete error messages. Both of these practices are strongly recommended by the Posting Guide. Please read it (again?). -- David. > > > the desired output is expected to be very large as for each dataframe in the > list of dataframes I expect to see maf value for each of the 600 columns! and > this is only for > > for one dataframe in the list .. I have around 150-200 dataframes.. not sure > how R will store these results.. but first I need the analysis to be done > correctly. The final output has to be something like this :- > > >> mafsforeachcolumns(I,II,...600)foreachcombination > > MealsCombinationsCust.ID I IIIII > IV .. 600 > 1 33-55 1 0.124 0.10 > 0.65 0.467 > 3 > 5 > > 2 44-667 0.134 0.43 > 0.64 0.479 > 4 > 9 > > . > > . > > ~180 dataframes > > > > From: Boris Steipe > Sent: 18 November 2017 00:35:16 > To: Allaisone 1; R-help > Subject: Re: [R] Complicated analysis for huge databases > > Something like the following? > > AllMAFs <- list() > > for (i in length(SeparatedGroupsofmealsCombs) { > AllMAFs[[i]] <- apply( SeparatedGroupsofmealsCombs[[i]], 2, function(x)maf( > tabulate( x+1) )) > } > > > (untested, of course) > Also the solution is a bit generic since I don't know what the output of > maf() looks like in your case, and I don't understand why you use tabulate > because I would have assumed that's what maf() does - but that's not for me > to worry about :-) > > > > B. > > > >> On Nov 17, 2017, at 7:15 PM, Allaisone 1 wrote: >> >> >> Thanks Boris , this was very helpful but I'm struggling with the last part. >> >> 1) I combined the first 2 columns :- >> >> >> library(tidyr) >> SingleMealsCode <-unite(MyData, MealsCombinations, c(MealA, MealB), >> remove=FALSE) >> SingleMealsCode <- SingleMealsCode[,-2] >> >> 2) I separated this dataframe into different dataframes based on >> "MealsCombination" >> column so R will recognize each meal combination separately : >> >> SeparatedGroupsofmealsCombs <- >> split(SingleMealCode,SingleMealCode$MealsCombinations) >> >> after investigating the structure of "SeparatedGroupsofmealsCombs" , I can >> see >> a list of different databases, each of which represents a different Meal >> combinations which is great. >> >> No, I'm struggling with the last part, how can I run the maf code for all >> dataframes? >> >> when I run this code as before :- >> >> maf <- apply(SeparatedGroupsofmealsCombs, 2, function(x)maf(tabulate(x+1))) >> >> an error message says : dim(X) must have a positive length . I'm not sure >> which length >> I need to specify.. any suggestions to correct this syntax ? >> >> Regards >> Allaisone >> From: Boris Steipe >> Sent: 17 November 2017 21:12:06 >> To: Allaisone 1 >> Cc: R-help >> Subject: Re: [R] Complicated analysis for huge databases >> >> Combine columns 1 and 2 into a column with a single ID like "33.55", "44.66" >> and use split() on these IDs to break up your dataset. Iterate over the list >> of data frames split() returns. >> >> >> B. >> >>> On Nov 17, 2017, at 12:59 PM, Allaisone 1 wrote: >>> >>> >>> Hi all .., >>> >>> >>> I have a large dataset of around 600,000 rows and 600 columns. The first >>> col is codes for Meal A, the second columns is codes for Meal B. The third >>> column is customers IDs where each customer had a combination of meals. >>> Each column of the rest columns contains values 0,1,or 2. The dataset is >>> organised in a way so that the first group of customers had similar meal
Re: [R] help
> On Nov 21, 2017, at 8:15 AM, yadav neog wrote: > > thank you for your valuable reply. I have attached my commands, results, and > data with this mail..maybe it will be beneficial for you to feedback. If you had read the Posting Guide (and lsitinfo), you should have noted the special requirements regarding attachments. The only person who received your attachments was Jeff. So you are essentially at his mercy regarding how he handles private communications. -- David. > > On Tue, Nov 21, 2017 at 9:13 PM, Jeff Newmiller > wrote: > >> Your example is incomplete... as the bottom of this and every post says, >> we need to be able to proceed from an empty R environment to wherever you >> are having the problem (reproducible), in as few steps as possible >> (minimal). The example needs to include data, preferably in R syntax as the >> dput function creates... see the howtos referenced below for help with >> that. [1], [2], [3] >> >> You also need to set your email program to send plain text format, since >> HTML gets mangled to various degrees as it gets forced into text format >> going through the mailing list. Read the Posting Guide. >> >> A wild guess is that you have negative values in your data or too few data >> points... >> >> [1] http://stackoverflow.com/questions/5963269/how-to-make- >> a-great-r-reproducible-example >> >> [2] http://adv-r.had.co.nz/Reproducibility.html >> >> [3] https://cran.r-project.org/web/packages/reprex/index.html (read the >> vignette) >> -- >> Sent from my phone. Please excuse my brevity. >> >> On November 21, 2017 12:48:08 AM PST, yadav neog >> wrote: >>> I am working on Johansen cointegration test, using urca and var >>> package. >>> in the selection of var, I have got following results. >>> >>>> VARselect(newd, lag.max = 10,type = "none") >>> >>> $selection >>> AIC(n) HQ(n) SC(n) FPE(n) >>>6 6 6 5 >>> >>> $criteria >>> 1 2 3 4 >>> 56789 >>> AIC(n) -3.818646e+01 -3.864064e+01 -3.833435e+01 -4.089169e+01 >>> NaN -Inf -Inf -Inf -Inf >>> HQ(n) -3.754345e+01 -3.744647e+01 -3.658903e+01 -3.859523e+01 >>> NaN -Inf -Inf -Inf -Inf >>> SC(n) -3.630096e+01 -3.513899e+01 -3.321655e+01 -3.415775e+01 >>> NaN -Inf -Inf -Inf -Inf >>> FPE(n) 2.700145e-17 2.114513e-17 5.350381e-17 2.035215e-17 >>> -9.147714e-650000 >>>10 >>> AIC(n) -Inf >>> HQ(n) -Inf >>> SC(n) -Inf >>> FPE(n)0 >>> >>> Warning messages: >>> 1: In log(sigma.det) : NaNs produced >>> 2: In log(sigma.det) : NaNs produced >>> 3: In log(sigma.det) : NaNs produced >>> >>> so do in my ca.jo test... I have found similar NaNs results. please >>> help me >>> in solving the problem. >>> Yadawananda Neog >>> Research Scholar >>> Department of Economics >>> Banaras Hindu University >>> Mob. 9838545073 >>> >>> [[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. >> > > > > -- > Yadawananda Neog > Research Scholar > Department of Economics > Banaras Hindu University > Mob. 9838545073 > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] R-How to unlist data frame multiple structured list column value and new column
> On Nov 21, 2017, at 7:13 AM, muthu m wrote: > > Hi, > > How to unlist list column value and add column into data frame. After looking at this and playing with the output of dput on the first 4 rows in this sample of what I suspect is a much larger data object my suspicion is that this cam from a JSON file or a SQL file and got inappropriately rearranged into a dataframe. It probably should have been processed differently. My advice would be to go back a couple of steps to the original data input process and see if you can deliver a less mangled version of your data. -- David. > > Data frame > > ID ContractDe >PassengersDe > TrainnerDe > > 1 list(ConID=c("Zx","78yu"),ConRes = c("98","Tut")) > list(PassID =1,PassIt="Lits,uy") > list(Trnid=1,Trncont =5,EmpAddInfo=list(list(CohID ="pi",InVoice=77))) > > 2 list(ConID=c("Half","Yut","Weq"),ConRes =c("ref","Cr")) > list(PassID =c("pfil","Q"),Name ="Tic",PassIt="S5,Y1 > list(Trnid=7,Trncont =3,EmpAddInfo=list(list(CohID =c("AB","NI","OL"),InVoice > = c("4","Y" > > 3 list(ConID=c("Ui","pric"),ConRes = c("Num","Patch")) > list(PassID =1,PassIt ="St,Bp") > list(Trnid=c("U", "l"),Trncont=c("10","78"),EmpAddInfo=list(list(CohID > =c("AB","NI","OL"),InVoice =c("4","Y" > > 4 list(ConID=c("2","7","IO"),ConRes = c("Res","Qty"),ConVal =c("Wno", > "ip"))list(PassID =1,Name ="RT",Name1 ="RR",PassIt="st7,st9") > list(Trnid=c("1", "3"),Trncont=c("yt","re"),EmpAddInfo=list(list(CohID > =c("Ly","qp"),InVoice =c("2","P" > > > > > > Expected data frame. > > ID ConID ConResConVal PassID PassItName Name1 > TrnidTrncontCohIDInVoice > > 1 Zx,78yu 98,Tut NA 1 Lits,uyNA NA >15 pi 77 > > 2 Half,Yut,Weq ref,Cr NA pfil,Q S5,Y1 TicNA >73 AB,NI,OL 4,Y > > 3 Ui,pric Num,Patch NA 1 St,Bp NA NA >U,l10,78 AB,NI,OL 4,Y > > 4 2,7,IORes,QtyWno,ip 1 st7,st9RT st7,st9 > 1,3 yt,re Ly,qp 2,P > > > > dput > > > structure(list(ID = c("1", "2", "3","4"), ContractDe = list( >structure(list(ConID = c("Zx", "78yu"), ConRes = c("98", >"Tut")), .Names = c("ConID", "ConRes"), class = "data.frame", row.names = > 1:2), >structure(list(ConID = c("Half", "Yut","Weq"), ConRes = c("ref", >"Cr")), .Names = c("ConID", "ConRes"), class = "data.frame", row.names = > 1:2), > structure(list(ConID = c("Ui", "pric"), ConRes = c("Num", >"Patch")), .Names = c("ConID", "ConRes"), class = "data.frame", row.names > = 1:2), >structure(list(ConID = c("2", "7","IO"), ConRes = c("Res", >"Qty"),ConVal=c("Wno","ip")), .Names = c("ConID", "ConRes","ConVal"), > class = "data.frame", row.names = 1:2)), >PassengersDe = list(structure(list(PassID = 1, PassIt = "Lits, uy"), > .Names = c("PassID", >"PassIt"), class = "data.frame", row.names = 1L), structure(list( >PassID = c("pfil","Q"), Name = "Tic", PassIt = "S5, Y1"), .Names = > c("PassID", >"Name", "PassIt"), class = "data.frame", row.names = 1L), > structure(list(PassID = 1, PassIt = "St, Bp"), .Names = c("PassID", >"PassIt"), class = "data.frame", row.names = 1L), > structure(list(PassID = 1, Name = "RT", Name1 = "RR", PassIt = &
Re: [R] libPaths displays truncated path?
> On Nov 23, 2017, at 4:34 AM, Loris Bennett wrote: > > Hi, > > TL;DR > - > > I define the path > >/cm/shared/apps/R/site-library/3.4.2 > > and add it to libPath. Why does libPath then display it as > >/cm/shared/apps/R/site-library/3.4 Generally one only has a different library for each major version of R. Major versions are consider just the first two numbers in the dot-separated versions system. Apparently libPaths is "smart" enough to make an effort to adhere to that convention. It appears your definition of "major" differs from the usual convention. -- David > > ? > > Long version > > > I run a cluster of diskless nodes for which the OS is loaded > directly into RAM and other software is provided by an NFS server. > However, in the case of R, we use the R version provided by the OS and > just install additional packages on the NFS server. > > So that R can find these additional packages, I have the following in > the site-wide Rprofile > > v <- R.Version() > base_path = "/cm/shared/apps/R/site-library/" > major_minor_version = paste(v["major"],v["minor"],sep=".") > cm_shared_lib_path = paste0(base_path,major_minor_version) > full_cm_shared_lib_path <- c(file.path(chartr("\\", "/", R.home()), > "site-library"), cm_shared_lib_path) > .libPaths( c( .libPaths(), full_cm_shared_lib_path ) ) > > Thus, when I start R I get this: > >> full_cm_shared_lib_path > [1] "/usr/lib64/R/site-library" > [2] "/cm/shared/apps/R/site-library/3.4.2" > > but also this > >> .libPaths() > [1] "/home/loris/R/x86_64-redhat-linux-gnu-library/3.4" > [2] "/usr/lib64/R/library" > [3] "/usr/share/R/library" > [4] "/usr/lib64/R/site-library" > [5] "/cm/shared/apps/R/site-library/3.4" > > However, in order to get R to find the packages, I have to add a > symbolic link, thus: > > [/cm/shared/apps/R/site-library] $ ls -l 3.4.2 > lrwxrwxrwx 1 root root 3 Nov 23 09:21 3.4.2 -> 3.4 > > So, my mistake was to think that "minor" would return "4", whereas it in > fact returns "4.2". So I actually set the path to ".../3.4.2" and > that's where R looks for packages. > > But why does libPaths display the the path I *thought* I had set, but in > fact looks at the path I *really did* set? > > Cheers, > > Loris > > -- > Dr. Loris Bennett (Mr.) > ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Multiple sets of proportion tests
> On Nov 24, 2017, at 3:35 PM, Allaisone 1 wrote: > > Thank you for clarifying this point but my main question was about how to > modify my code to do the analysis correctly. You need to first clarify what your proposed statistical hypothesis might be. If you are doing prop.test on 300 columns you have a serious multiple comparisons issue in your analysis plan that you have not recognized. Removing the columns that "fail" a test set at nominal level of 0.05 is statistical malpractice. > The code I mentioned :- > > MyResults <- apply(Mydata, 2, function(x)prop.test(Mydata,c(200,100)) The code as written appears to have the obvious error of using `Mydata` as an argument inside the prop.test function. Should almost certainly be `x` instead. (I suspect the length of the 'x'-argument to prop.test will be on the order of 200 and the length of n is 2, hence the error.) It would also be ideal if you could post the output of dput(Mydata[,1:3] ). > Results in this error : 'x' and 'n' must have the same length in the > prop.test(x,n). > > > How can I modify "x' or "n" arguments so the analysis gives me the desired > output You desperately need to read the help page for the function you are using. This need was pointed out to you, but it appears to me that you have ignored Thierry's advice. (Going back to your original example ... The x variable is supposed to be the number of success and the n variable is the number of trials. So in all instances n MUST be greater than or equal to x. Your data example is going to fail that requirement even after you correct the semantic error noted above.) (And do learn to post with plain text.) -- David. > > shown in my previous post ? > > > From: Thierry Onkelinx > Sent: 24 November 2017 21:06:39 > To: Allaisone 1 > Cc: r-help@r-project.org > Subject: Re: [R] Multiple sets of proportion tests > > Hi anonymous, > > ?prop.test states that it returns a list. And one of the element is > 'p.value'. str() on the output of prop.test() reveals that too. So > prop.test()$p.value or prop.test()["p.value"] should work. > > Best regards, > > ir. Thierry Onkelinx > Statisticus / Statistician > > Vlaamse Overheid / Government of Flanders > INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE > AND FOREST > Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance > thierry.onkel...@inbo.be > Kliniekstraat 25, B-1070 Brussel > www.inbo.be<http://www.inbo.be> > > /// > To call in the statistician after the experiment is done may be no > more than asking him to perform a post-mortem examination: he may be > able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher > The plural of anecdote is not data. ~ Roger Brinner > The combination of some data and an aching desire for an answer does > not ensure that a reasonable answer can be extracted from a given body > of data. ~ John Tukey > /// > > > Van 14 tot en met 19 december 2017 verhuizen we uit onze vestiging in > Brussel naar het Herman Teirlinckgebouw op de site Thurn & Taxis. > Vanaf dan ben je welkom op het nieuwe adres: Havenlaan 88 bus 73, 1000 > Brussel. > > /// > > > > 2017-11-24 12:09 GMT+01:00 Allaisone 1 : >> >> Hi all , >> >> >> I have a dataframe of 200 columns and 2 rows. The first row in each column >> contains the frequency of cases in group I . The second row in each column >> contains the frequency of cases in group II. The frequency of trails is a >> fixed value for group I(e.g.200) and it is also another fixed values for >> group II (e.g. 100). The dataset looks like this :- >> >> >>> Mydata >> >> >> variable I variable IIVariable >> III . 200 >> >> Freq.of cases (gp I) 6493 9375 5524 >> >> Freq. of cases (gpII) 509 462 54 >> >> >> >> The result I need for the first column can be given using this code : >> >> >> MyResultsI <- prop.test(Mydata$variable I ,c(200,100)) >> for the second column :- >> MyResultsII <- prop.test(Mydata$variable II ,c(200,100)) and so on .. >> >> >> I need to do the analysis for all colum
Re: [R] dplyr - add/expand rows
> On Nov 25, 2017, at 11:18 AM, Hutchinson, David (EC) > wrote: > > I have a returned tibble of station operational record similar to the > following: > >> data.collection > # A tibble: 5 x 4 > STATION_NUMBER YEAR_FROM YEAR_TO RECORD > > 107EA001 19601960QMS > 207EA001 19611970QMC > 307EA001 19711971QMM > 407EA001 19721976QMC > 507EA001 19771983QRC > > I would like to reshape this to one operational record (row) per year per > station. Something like: > > 07EA001 1960 QMS > 07EA001 1961 QMC > 07EA001 1962 QMC > 07EA001 1963 QMC > ... > 07EA001 1971 QMM > > Can this be done in dplyr easily? Probably, yes. This looks like a feasible plan might be to "fill-in" the gaps with a last observation carried forward value within categories of station number. The na.locf function in package zoo is very handy for some of these tasks. Or Perhaps merging this data with a skeleton data object with station numbers and a `seq`-built vectors for the range of years. Why don't you post a data example with sufficient complexity to represent the problem? Perhaps: dput( head( data.collection, 20) ) It's clear that the first 5 lines are not sufficient since there's only one station. It's kind of a pain to try to construct tibble objects from their print output representations. And posting code to build examples is a specific suggestion in the Posting Guide. -- David > > Thanks in advance, > > David > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Removing a data subset
Say I have a dataset that looks like LocationYear GW_Elv MW011999 546.63 MW021999 474.21 MW031999 471.94 MW041999466.80 MW012000545.90 MW022000546.10 The whole dataset is at http://doylesdartden.com/ExampleData.csv and I use the code below to do the graph but I want to do it without MW01. How can I remove MW01?? I'm sure I can do it by SubSeting but I can not figure out how to do it. Thank you David -- library(ggplot2) MyData <- read.csv("http://doylesdartden.com/ExampleData.csv";, header=TRUE, sep=",") #Sets whic are detections and nondetects MyData$Detections <- ifelse(MyData$D_GW_Elv ==1, "Detected", "NonDetect") #Removes the NAs MyDataWONA <- MyData[!is.na(MyData$Detections), ] #does the plot p <- ggplot(data = MyDataWONA, aes(x=Year, y=GW_Elv , col=Detections)) + geom_point(aes(shape=Detections)) + ##sets the colors scale_colour_manual(values=c("black","red")) + #scale_y_log10() + #location of the legend theme(legend.position=c("right")) + #sets the line color, type and size geom_line(colour="black", linetype="dotted", size=0.5) + ylab("Elevation Feet Mean Sea Level") ## does the graph using the Location IDs as the different Locations. p + facet_grid(Location ~ .) [[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] 2^3 confounded factorial experiment
> On Nov 29, 2017, at 9:20 AM, Jyoti Bhogal wrote: > > The following R commands were written: >> help.search("factorial") >> data(npk) >> npk >> coef(npk.aov) > > In the output of coef command, please explain me the interpretation of > coefficients of block1 to block 6 in this 2^3 confounded factorial experiment. This is very much a statistics question and as such is off-topic (as it also would be off-topic on StackOverflow.) Rhelp is for persons having difficulty coding the R language itself. Consider CrossValidated.com but read their posting help section first since this is really very terse question. Better would be to include the output and make your best interpretation so peolple get the sense you at least put in some individual effort. > > Thanks. > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Help avoiding setting column type two times
> On Nov 30, 2017, at 6:27 AM, Martin Møller Skarbiniks Pedersen > wrote: > > Hi, > I think and hope this a good place to ask for code review for a R > beginners? > > I have made a R script which generates a dataset based on 2009 danish > referendum and it does work. > > But I think the code could be better and I would any comments how the > code can be improved. > At least I would like to know how I avoid converting several of the > columns to factors in the end of the code? > > Description of the code: > > It reads a lot of xml-files from ../raw/ and saves a data.frame with > information > from these xml-files. > > In the ../raw/ directiory I have placed the xml-files which I got from > "Statistics Denmark" > I have also put these xml-files on my website and they can be download > freely from http://20dage.dk/R/referendum-2009/raw.tar.gz > > The code is below but I have also put the code at this place: > http://20dage.dk/R/referendum-2009/convert_from_xml.R > > Best Regards > Martin M. S. Pedersen > > --- > library(xml2) > > convert_one_file <- function(url) { >x <- read_xml(url) > >Sted <- xml_find_first(x, ".//Sted") >StedType <- xml_attr(Sted, "Type") >StedTekst <- xml_text(Sted) > >Parti <- xml_find_all(x, ".//Parti") >PartiId <- xml_attr(Parti, "Id") >PartiBogstav <- xml_attr(Parti, "Bogstav") >PartiNavn <- xml_attr(Parti, "Navn") > > >StemmerAntal <- xml_attr(Parti, "StemmerAntal") >Stemmeberettigede <- xml_integer(xml_find_first(x, > ".//Stemmeberettigede")) >DeltagelsePct <- xml_double(xml_find_first(x, ".//DeltagelsePct")) >IAltGyldigeStemmer <- xml_integer(xml_find_first(x, > ".//IAltGyldigeStemmer")) >BlankeStemmer <- xml_integer(xml_find_first(x, ".//BlankeStemmer")) >AndreUgyldigeStemmer <- xml_integer(xml_find_first(x, > ".//AndreUgyldigeStemmer")) > >data.frame(cbind(StedType, StedTekst, PartiId, PartiBogstav, PartiNavn, > StemmerAntal, Stemmeberettigede, DeltagelsePct, > IAltGyldigeStemmer, > BlankeStemmer, AndreUgyldigeStemmer), stringsAsFactors = FALSE) The construction `data.frame(cbind( ...` is a serious source of potential error. The cbind coerces to matrix class which also then coerces to a single atomic class, either numeric or character. Factors loose all their meaning. Dates get messed up. Error ensues. Better would be: data.frame( StedType, StedTekst, PartiId, PartiBogstav, PartiNavn, StemmerAntal, Stemmeberettigede, DeltagelsePct, IAltGyldigeStemmer, BlankeStemmer, AndreUgyldigeStemmer, stringsAsFactors = FALSE) -- David. > } > > raw_path <- "../raw" > filenames <- dir(path = raw_path, pattern = "fintal_.*", full.names = T) > > result <- data.frame(StedType = factor(), > StedTekst = character(), > PartiId = factor(), > PartiBogstav = factor(), > PartiNavn= factor(), > StemmerAntal = integer(), > Stemmeberettigede = integer(), > DeltagelsePct = numeric(), > IAltGyldigeStemmer = integer(), > BlankeStemmer = integer(), > AndreUgyldigeStemmer = integer(), > stringsAsFactors = FALSE) > > for (i in 1:length(filenames)) { >#cat(paste0(filenames[i],"\n")) >returnCode <- tryCatch({ > result <- rbind(result, convert_one_file(filenames[i])) >}, error = function(e) { > cat(paste0(filenames[i]," failed:\n",e,"\n")) >}) > } > > result$StedType <- as.factor(result$StedType) > result$PartiId <- as.factor(result$PartiId) > result$PartiBogstav <- as.factor(result$PartiBogstav) > result$PartiNavn <- as.factor(result$PartiNavn) > result$StemmerAntal <- as.integer(result$StemmerAntal) > result$Stemmeberettigede <- as.integer(result$Stemmeberettigede) > result$DeltagelsePct <- as.numeric(result$DeltagelsePct) > result$IAltGyldigeStemmer <- as.integer(result$IAltGyldigeStemmer) > result$BlankeStemmer <- as.integer(result$BlankeStemmer) > result$AndreUgyldigeStemmer <- as.integer(result$AndreUgyldigeStemmer) > str(result) > save(result, file = "folkeafstemning2009.Rdata") > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing
Re: [R] Removing a data subset
Thank Rainer and Jim!! The end result was: #Makes a new data set name "MyData_Minus_MW01" that contains all the data where the Location Column is not equal to MW01 and the comma after that ensures that all columns are copied into the amended data.frame. MyData_Minus_MW01 <- MyData[ MyData$Location != "MW01", ] The final code is as follows: #Loads ggplot2 library(ggplot2) #Loads data from internet and names it MyData MyData <- read.csv( "http://doylesdartden.com/ExampleData.csv";, header = TRUE, stringsAsFactors = FALSE ) #Makes a new data set name "MyData_Minus_MW01" that contains all the data where the Location Column is not equal to MW01 and the comma after that ensures that all columns are copied into the amended data.frame. MyData_Minus_MW01 <- MyData[ MyData$Location != "MW01", ] #Sets whic are detections and nondetects MyData_Minus_MW01$Detections <- ifelse(MyData_Minus_MW01$D_GW_Elv ==1, "Detected", "NonDetect") #Removes the NAs MyData_Minus_MW01WONA <- MyData_Minus_MW01[!is.na(MyData_Minus_MW01$Detections), ] #does the plot p <- ggplot(data = MyData_Minus_MW01WONA, aes(x=Year, y=GW_Elv , col=Detections)) + geom_point(aes(shape=Detections)) + ##sets the colors scale_colour_manual(values=c("black","red")) + #scale_y_log10() + #location of the legend theme(legend.position=c("right")) + #sets the line color, type and size geom_line(colour="black", linetype="dotted", size=0.5) + ylab("Elevation Feet Mean Sea Level") ## does the graph using the Location IDs as the different Locations. p + facet_grid(Location ~ .) Thanks again David [[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] Odd dates generated in Forecasts
quot;04/13/13", "04/14/07", > "04/14/12", "04/15/06", "04/16/05", "04/16/11", "04/16/16", "04/17/04", > "04/17/10", "04/18/09", "04/18/15", "04/19/03", "04/19/08", "04/19/14", > "04/20/13", "04/21/07", "04/21/12", "04/22/06", "04/23/05", "04/23/11", > "04/23/16", "04/24/04", "04/24/10", "04/25/09", "04/25/15", "04/26/03", > "04/26/08", "04/26/14", "04/27/13", "04/28/07", "04/28/12", "04/29/06", > "04/30/05", "04/30/11", "04/30/16", "05/01/04", "05/01/10", "05/02/09", > "05/02/15", "05/03/03", "05/03/08", "05/03/14", "05/04/13", "05/05/07", > "05/05/12", "05/06/06", "05/07/05", "05/07/11", "05/07/16", "05/08/04", > "05/08/10", "05/09/09", "05/09/15", "05/10/03", "05/10/08", "05/10/14", > "05/11/13", "05/12/07", "05/12/12", "05/13/06", "05/14/05", "05/14/11", > "05/14/16", "05/15/04", "05/15/10", "05/16/09", "05/16/15", "05/17/03", > "05/17/08", "05/17/14", "05/18/13", "05/19/07", "05/19/12", "05/20/06", > "05/21/05", "05/21/11", "05/21/16", "05/22/04", "05/22/10", "05/23/09", > "05/23/15", "05/24/03", "05/24/08", "05/24/14", "05/25/13", "05/26/07", > "05/26/12", "05/27/06", "05/28/05", "05/28/11", "05/28/16", "05/29/04", > "05/29/10", "05/30/09", "05/30/15", "05/31/03", "05/31/08", "05/31/14", > "06/01/13", "06/02/07", "06/02/12", "06/03/06", "06/04/05", "06/04/11", > "06/04/16", "06/05/04", "06/05/10", "06/06/09", "06/06/15", "06/07/03", > "06/07/08", "06/07/14", "06/08/13", "06/09/07", "06/09/12", "06/10/06", > "06/11/05", "06/11/11", "06/11/16", "06/12/04", "06/12/10", "06/13/09", > "06/13/15", "06/14/03", "06/14/08", "06/14/14", "06/15/13", "06/16/07", > "06/16/12", "06/17/06", "06/18/05", "06/18/11", "06/18/16", "06/19/04", > "06/19/10", "06/20/09", "06/20/15", "06/21/03", "06/21/08", "06/21/14", > "06/22/13", "06/23/07", "06/23/12", "06/24/06", "06/25/05", "06/25/11", > "06/25/16", "06/26/04", "06/26/10", "06/27/09", "06/27/15", "06/28/03", > "06/28/08", "06/28/14", "06/29/13", "06/30/07", "06/30/12", "07/01/06", > "07/02/05", "07/02/11", "07/02/16", "07/03/04", "07/03/10", "07/04/09", > "07/04/15", "07/05/03", "07/05/08", "07/05/14", "07/06/13", "07/07/07", > "07/07/12", "07/08/06", "07/09/05", "07/09/11", "07/09/16", "07/10/04", > "07/10/10", "07/11/09", "07/11/15", "07/12/03", "07/12/08", "07/12/14", > "07/13/13", "07/14/07", "07/14/12", "07/15/06", "07/16/05", "07/16/11", > "07/16/16", "07/17/04", "07/17/10", "07/18/09", "07/18/15", "07/19/03", > "07/19/08", "07/19/14", "07/20/13", "07/21/07", "07/21/12", "07/22/06", > "07/23/05", "07/23/11", "07/23/16", "07/24/04", "07/24/10", "07/25/09", > "07/25/15", "07/26/03", "07/26/08", "07/26/14", "07/27/13", "07/28/07", > "07/28/12", "07/29/06", "07/30/05", "07/30/11", "07/30/16", "07/31/04", > "07/31/10",
Re: [R] Odd dates generated in Forecasts
> On Dec 6, 2017, at 11:09 AM, Paul Bernal wrote: > > Thank you very much David. As a matter of fact, I solved it by doing the > following: > > MyTimeSeriesObj <- ts(MyData, freq=365.25/7, > start=decimal_date(mdy("01-04-2003"))) > > After doing that adjustment, my forecasts dates started from 2017 on. Not clear what MyData consisted of. If it was the factor variable in the `dataset` object in your earlier communication, then you gave the `ts` function garbage. The fact that it was labeled to your liking would not create a palatable result. -- David. > > Cheers, > > Paul > > 2017-12-06 12:03 GMT-05:00 David Winsemius : > > > On Dec 6, 2017, at 5:07 AM, Paul Bernal wrote: > > > > Dear friends, > > > > I have a weekly time series which starts on Jan 4th, 2003 and ends on > > december 31st, 2016. > > > > I set up my ts object as follows: > > > > MyTseries <- ts(mydataset, start=2003, end=2016, frequency=52) > > > > MyModel <- auto.arima(MyTseries, d=1, D=1) > > > > MyModelForecast <- forecast (MyModel, h=12) > > > > Since my last observation was on december 31st, 2016 I expected my forecast > > date to start on 2017, but instead it returned odd dates. > > > > This is my dataset > > > > dput(dataset): > > > > structure(list(Date = structure(c(8L, 22L, 36L, 50L, 64L, 78L, > > 92L, 106L, 120L, 134L, 148L, 162L, 176L, 190L, 204L, 218L, 232L, > > 246L, 260L, 274L, 288L, 302L, 316L, 330L, 344L, 358L, 372L, 386L, > > 400L, 414L, 428L, 442L, 456L, 470L, 484L, 498L, 512L, 526L, 540L, > > 554L, 568L, 582L, 596L, 610L, 624L, 638L, 652L, 666L, 680L, 694L, > > 708L, 722L, 5L, 19L, 33L, 47L, 61L, 75L, 89L, 103L, 117L, 130L, > > 144L, 158L, 172L, 186L, 200L, 214L, 228L, 242L, 256L, 270L, 284L, > > 298L, 312L, 326L, 340L, 354L, 368L, 382L, 396L, 410L, 424L, 438L, > > 452L, 466L, 480L, 494L, 508L, 522L, 536L, 550L, 564L, 578L, 592L, > > 606L, 620L, 634L, 648L, 662L, 676L, 690L, 704L, 718L, 1L, 15L, > > 29L, 43L, 57L, 71L, 85L, 99L, 113L, 127L, 141L, 155L, 169L, 183L, > > 197L, 211L, 225L, 239L, 253L, 267L, 281L, 295L, 309L, 323L, 337L, > > 351L, 365L, 379L, 393L, 407L, 421L, 435L, 449L, 463L, 477L, 491L, > > 505L, 519L, 533L, 547L, 561L, 575L, 589L, 603L, 617L, 631L, 645L, > > 659L, 673L, 687L, 701L, 715L, 729L, 13L, 27L, 41L, 55L, 69L, > > 83L, 97L, 111L, 126L, 140L, 154L, 168L, 182L, 196L, 210L, 224L, > > 238L, 252L, 266L, 280L, 294L, 308L, 322L, 336L, 350L, 364L, 378L, > > 392L, 406L, 420L, 434L, 448L, 462L, 476L, 490L, 504L, 518L, 532L, > > 546L, 560L, 574L, 588L, 602L, 616L, 630L, 644L, 658L, 672L, 686L, > > 700L, 714L, 728L, 12L, 26L, 40L, 54L, 68L, 82L, 96L, 110L, 124L, > > 138L, 152L, 166L, 180L, 194L, 208L, 222L, 236L, 250L, 264L, 278L, > > 292L, 306L, 320L, 334L, 348L, 362L, 376L, 390L, 404L, 418L, 432L, > > 446L, 460L, 474L, 488L, 502L, 516L, 530L, 544L, 558L, 572L, 586L, > > 600L, 614L, 628L, 642L, 656L, 670L, 684L, 698L, 712L, 726L, 10L, > > 24L, 38L, 52L, 66L, 80L, 94L, 108L, 121L, 135L, 149L, 163L, 177L, > > 191L, 205L, 219L, 233L, 247L, 261L, 275L, 289L, 303L, 317L, 331L, > > 345L, 359L, 373L, 387L, 401L, 415L, 429L, 443L, 457L, 471L, 485L, > > 499L, 513L, 527L, 541L, 555L, 569L, 583L, 597L, 611L, 625L, 639L, > > 653L, 667L, 681L, 695L, 709L, 723L, 6L, 20L, 34L, 48L, 62L, 76L, > > 90L, 104L, 118L, 132L, 146L, 160L, 174L, 188L, 202L, 216L, 230L, > > 244L, 258L, 272L, 286L, 300L, 314L, 328L, 342L, 356L, 370L, 384L, > > 398L, 412L, 426L, 440L, 454L, 468L, 482L, 496L, 510L, 524L, 538L, > > 552L, 566L, 580L, 594L, 608L, 622L, 636L, 650L, 664L, 678L, 692L, > > 706L, 720L, 3L, 17L, 31L, 45L, 59L, 73L, 87L, 101L, 115L, 131L, > > 145L, 159L, 173L, 187L, 201L, 215L, 229L, 243L, 257L, 271L, 285L, > > 299L, 313L, 327L, 341L, 355L, 369L, 383L, 397L, 411L, 425L, 439L, > > 453L, 467L, 481L, 495L, 509L, 523L, 537L, 551L, 565L, 579L, 593L, > > 607L, 621L, 635L, 649L, 663L, 677L, 691L, 705L, 719L, 2L, 16L, > > 30L, 44L, 58L, 72L, 86L, 100L, 114L, 128L, 142L, 156L, 170L, > > 184L, 198L, 212L, 226L, 240L, 254L, 268L, 282L, 296L, 310L, 324L, > > 338L, 352L, 366L, 380L, 394L, 408L, 422L, 436L, 450L, 464L, 478L, > > 492L, 506L, 520L, 534L, 548L, 562L, 576L, 590L, 604L, 618L, 632L, > > 646L, 660L, 674L, 688L, 702L, 716L, 730L, 14L, 28L, 42L, 56L, > > 70L, 84L, 98L, 112L, 125L, 139L, 153L, 167L, 181L, 195L, 209L, > > 223L, 237L, 251L, 265L, 279L, 293L, 307L, 321L, 335L, 349L, 363L, > > 377L, 391L, 405L, 419L, 433L, 447L, 461L, 475L, 489L, 503L, 517L, > > 531L, 545L, 559L, 573L, 587L, 601L, 615L, 629L, 643L, 657L, 671L, > > 685L, 6
Re: [R] Remove
> On Dec 6, 2017, at 3:15 PM, Ashta wrote: > > Hi all, > In a data set I have group(GR) and two variables x and y. I want to > remove a group that have the same record for the x variable in each > row. > > DM <- read.table( text='GR x y > A 25 125 > A 23 135 > A 14 145 > A 12 230 > B 25 321 > B 25 512 > B 25 123 > B 25 451 > C 11 521 > C 14 235 > C 15 258 > C 10 654',header = TRUE, stringsAsFactors = FALSE) > > In this example the output should contain group A and C as group B > has the same record for the variable x . > > The result will be > A 25 125 > A 23 135 > A 14 145 > A 12 230 > C 11 521 > C 14 235 > C 15 258 > C 10 654 Try: DM[ !duplicated(DM$x) , ] > > How do I do it R? > 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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Remove
> On Dec 6, 2017, at 4:27 PM, Ashta wrote: > > Thank you Ista! Worked fine. Here's another (possibly more direct in its logic?): DM[ !ave(DM$x, DM$GR, FUN= function(x) {!length(unique(x))==1}), ] GR x y 5 B 25 321 6 B 25 512 7 B 25 123 8 B 25 451 -- David > On Wed, Dec 6, 2017 at 5:59 PM, Ista Zahn wrote: >> Hi Ashta, >> >> There are many ways to do it. Here is one: >> >> vars <- sapply(split(DM$x, DM$GR), var) >> DM[DM$GR %in% names(vars[vars > 0]), ] >> >> Best >> Ista >> >> On Wed, Dec 6, 2017 at 6:58 PM, Ashta wrote: >>> Thank you Jeff, >>> >>> subset( DM, "B" != x ), this works if I know the group only. >>> But if I don't know that group in this case "B", how do I identify >>> group(s) that all elements of x have the same value? >>> >>> On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller >>> wrote: >>>> subset( DM, "B" != x ) >>>> >>>> This is covered in the Introduction to R document that comes with R. >>>> -- >>>> Sent from my phone. Please excuse my brevity. >>>> >>>> On December 6, 2017 3:21:12 PM PST, David Winsemius >>>> wrote: >>>>> >>>>>> On Dec 6, 2017, at 3:15 PM, Ashta wrote: >>>>>> >>>>>> Hi all, >>>>>> In a data set I have group(GR) and two variables x and y. I want to >>>>>> remove a group that have the same record for the x variable in each >>>>>> row. >>>>>> >>>>>> DM <- read.table( text='GR x y >>>>>> A 25 125 >>>>>> A 23 135 >>>>>> A 14 145 >>>>>> A 12 230 >>>>>> B 25 321 >>>>>> B 25 512 >>>>>> B 25 123 >>>>>> B 25 451 >>>>>> C 11 521 >>>>>> C 14 235 >>>>>> C 15 258 >>>>>> C 10 654',header = TRUE, stringsAsFactors = FALSE) >>>>>> >>>>>> In this example the output should contain group A and C as group B >>>>>> has the same record for the variable x . >>>>>> >>>>>> The result will be >>>>>> A 25 125 >>>>>> A 23 135 >>>>>> A 14 145 >>>>>> A 12 230 >>>>>> C 11 521 >>>>>> C 14 235 >>>>>> C 15 258 >>>>>> C 10 654 >>>>> >>>>> Try: >>>>> >>>>> DM[ !duplicated(DM$x) , ] >>>>>> >>>>>> How do I do it R? >>>>>> 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. >>>>> >>>>> David Winsemius >>>>> Alameda, CA, USA >>>>> >>>>> 'Any technology distinguishable from magic is insufficiently advanced.' >>>>> -Gehm's Corollary to Clarke's Third Law >>>>> >>>>> __ >>>>> 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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Error in loadNamespace
> On Dec 7, 2017, at 10:47 AM, James Henson wrote: > > Hello R Community, > > I inadvertently updated packages via R Studio when a package was open. Now > when R Studio is opened the message below appears in the console panel. > > Error in loadNamespace(name) : there is no package called ‘yaml’ > > Error in loadNamespace(name) : there is no package called ‘yaml’ > > When running R code, so far the only function that has not worked is > datatable () in the ‘DT’ package. Removing the ‘DT’ package and > reinstalling it had no effect. A possible fix is to update R from an older > version, which was not running when I made the mistake. Is this a good > idea? There is a package on CRAN named "yaml". Have your tried installing it? > > Thanks for your help. > > James F. Henson > > [[alternative HTML version deleted]] Rhelp is a plain text mailing list. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Seeking help with code
> On Dec 7, 2017, at 2:51 PM, Stephanie Tsalwa wrote: > > Assuming the days of raining during half a year of all states(provinces) of a > country is normally distributed (mean=�, standard deviation=�) with sigma (�) > equals to 2. We now have 10 data points here: 26.64, 30.65, 31.27, 33.04, > 32.56, 29.10, 28.96, 26.44, 27.76, 32.27. Try to get the 95% level of CI for > �, using parametric Bootstrap method with bootstrap size B=8000. This has the definite appearance of a homework assignment. It also has several other features which likewise suggest a failure to read the Posting Guide, a link to which is at the bottom of every posting sent out from the Rhelp mail-server. You are advised to post credential/affiliation information and more context of the wider goals if my assumption of HW-status is incorrect. -- David. (And yes I do realize that I am also not posting any affiliation information, either, but I'm retired and am not asking for free advice, am I? Don't follow my bad example.) > > my code - what am i doing wrong > > #set sample size n, bootstrap size B > n = 10 > b = 8000 > > > set a vector of days of rain into "drain" > drain = c(26.64, 30.65, 31.27, 33.04, 32.56, 29.10, 28.96, 26.44, 27.76, > 32.27) > > #calculate mean of the sample for days of rain > mdr=mean(drain) > mdr > > #calculate the parameter of the exponential distribution > lambdahat = 1.0/mdr > lambdahat > > #draw the bootstrap sample from Exponential > x = rexp(n*b, lambdahat) > x > > bootstrapsample = matrix(x, nrow=n, ncol=b) > bootstrapsample > > # Compute the bootstrap lambdastar > lambdastar = 1.0/colMeans(bootstrapsample) > lambdastar > > # Compute the differences > deltastar = lambdastar - lambdahat > deltastar > > # Find the 0.05 and 0.95 quantile for deltastar > d = quantile(deltastar, c(0.05,0.95)) > d > > # Calculate the 95% confidence interval for lambda. > ci = lambdahat - c(d[2], d[1]) > ci > > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Remove
> On Dec 8, 2017, at 4:48 PM, Ashta wrote: > > Hi David, Ista and all, > > I have one related question Within one group I want to keep records > conditionally. > example within > group A I want keep rows that have " x" values ranged between 15 and 30. > group B I want keep rows that have " x" values ranged between 40 and 50. > group C I want keep rows that have " x" values ranged between 60 and 75. When you have a problem where there are multiple "parallel: parameters, the function to "reach for" is `mapply`. mapply( your_selection_func, group_vec, min_vec, max_vec) ... and this will probably return the values as a list (of dataframes if you build the function correctly, so you may may need to then do: do.call(rbind, ...) -- David. > > > DM <- read.table( text='GR x y > A 25 125 > A 23 135 > A 14 145 > A 35 230 > B 45 321 > B 47 512 > B 53 123 > B 55 451 > C 61 521 > C 68 235 > C 85 258 > C 80 654',header = TRUE, stringsAsFactors = FALSE) > > > The end result will be > A 25 125 > A 23 135 > B 45 321 > B 47 512 > C 61 521 > C 68 235 > > Thank you > > On Wed, Dec 6, 2017 at 10:34 PM, David Winsemius > wrote: >> >>> On Dec 6, 2017, at 4:27 PM, Ashta wrote: >>> >>> Thank you Ista! Worked fine. >> >> Here's another (possibly more direct in its logic?): >> >> DM[ !ave(DM$x, DM$GR, FUN= function(x) {!length(unique(x))==1}), ] >> GR x y >> 5 B 25 321 >> 6 B 25 512 >> 7 B 25 123 >> 8 B 25 451 >> >> -- >> David >> >>> On Wed, Dec 6, 2017 at 5:59 PM, Ista Zahn wrote: >>>> Hi Ashta, >>>> >>>> There are many ways to do it. Here is one: >>>> >>>> vars <- sapply(split(DM$x, DM$GR), var) >>>> DM[DM$GR %in% names(vars[vars > 0]), ] >>>> >>>> Best >>>> Ista >>>> >>>> On Wed, Dec 6, 2017 at 6:58 PM, Ashta wrote: >>>>> Thank you Jeff, >>>>> >>>>> subset( DM, "B" != x ), this works if I know the group only. >>>>> But if I don't know that group in this case "B", how do I identify >>>>> group(s) that all elements of x have the same value? >>>>> >>>>> On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller >>>>> wrote: >>>>>> subset( DM, "B" != x ) >>>>>> >>>>>> This is covered in the Introduction to R document that comes with R. >>>>>> -- >>>>>> Sent from my phone. Please excuse my brevity. >>>>>> >>>>>> On December 6, 2017 3:21:12 PM PST, David Winsemius >>>>>> wrote: >>>>>>> >>>>>>>> On Dec 6, 2017, at 3:15 PM, Ashta wrote: >>>>>>>> >>>>>>>> Hi all, >>>>>>>> In a data set I have group(GR) and two variables x and y. I want to >>>>>>>> remove a group that have the same record for the x variable in each >>>>>>>> row. >>>>>>>> >>>>>>>> DM <- read.table( text='GR x y >>>>>>>> A 25 125 >>>>>>>> A 23 135 >>>>>>>> A 14 145 >>>>>>>> A 12 230 >>>>>>>> B 25 321 >>>>>>>> B 25 512 >>>>>>>> B 25 123 >>>>>>>> B 25 451 >>>>>>>> C 11 521 >>>>>>>> C 14 235 >>>>>>>> C 15 258 >>>>>>>> C 10 654',header = TRUE, stringsAsFactors = FALSE) >>>>>>>> >>>>>>>> In this example the output should contain group A and C as group B >>>>>>>> has the same record for the variable x . >>>>>>>> >>>>>>>> The result will be >>>>>>>> A 25 125 >>>>>>>> A 23 135 >>>>>>>> A 14 145 >>>>>>>> A 12 230 >>>>>>>> C 11 521 >>>>>>>> C 14 235 >>>>>>>> C 15 258 >>>>>>>> C 10 654 >>>>>>> >>>>>>> Try: >>>>>>> >>>>>>> DM[ !duplicated(DM$x) , ] >>>>>>>> >>&g
Re: [R] Remove
> On Dec 8, 2017, at 6:16 PM, David Winsemius wrote: > > >> On Dec 8, 2017, at 4:48 PM, Ashta wrote: >> >> Hi David, Ista and all, >> >> I have one related question Within one group I want to keep records >> conditionally. >> example within >> group A I want keep rows that have " x" values ranged between 15 and 30. >> group B I want keep rows that have " x" values ranged between 40 and 50. >> group C I want keep rows that have " x" values ranged between 60 and 75. > > When you have a problem where there are multiple "parallel: parameters, the > function to "reach for" is `mapply`. > >mapply( your_selection_func, group_vec, min_vec, max_vec) > > ... and this will probably return the values as a list (of dataframes if you > build the function correctly, so you may may need to then do: > >do.call(rbind, ...) do.call( rbind, mapply( function(dat, grp, minx, maxx) {dat[ dat$GR==grp & dat$x >= minx & dat$x <= maxx, ]}, grp=LETTERS[1:3], minx=c(15,40,60), maxx=c(30,50,75) , MoreArgs=list(dat=DM), IMPLIFY=FALSE)) GR x y A.1 A 25 125 A.2 A 23 135 B.5 B 45 321 B.6 B 47 512 C.9 C 61 521 C.10 C 68 235 > > -- > David. >> >> >> DM <- read.table( text='GR x y >> A 25 125 >> A 23 135 >> A 14 145 >> A 35 230 >> B 45 321 >> B 47 512 >> B 53 123 >> B 55 451 >> C 61 521 >> C 68 235 >> C 85 258 >> C 80 654',header = TRUE, stringsAsFactors = FALSE) >> >> >> The end result will be >> A 25 125 >> A 23 135 >> B 45 321 >> B 47 512 >> C 61 521 >> C 68 235 >> >> Thank you >> >> On Wed, Dec 6, 2017 at 10:34 PM, David Winsemius >> wrote: >>> >>>> On Dec 6, 2017, at 4:27 PM, Ashta wrote: >>>> >>>> Thank you Ista! Worked fine. >>> >>> Here's another (possibly more direct in its logic?): >>> >>> DM[ !ave(DM$x, DM$GR, FUN= function(x) {!length(unique(x))==1}), ] >>> GR x y >>> 5 B 25 321 >>> 6 B 25 512 >>> 7 B 25 123 >>> 8 B 25 451 >>> >>> -- >>> David >>> >>>> On Wed, Dec 6, 2017 at 5:59 PM, Ista Zahn wrote: >>>>> Hi Ashta, >>>>> >>>>> There are many ways to do it. Here is one: >>>>> >>>>> vars <- sapply(split(DM$x, DM$GR), var) >>>>> DM[DM$GR %in% names(vars[vars > 0]), ] >>>>> >>>>> Best >>>>> Ista >>>>> >>>>> On Wed, Dec 6, 2017 at 6:58 PM, Ashta wrote: >>>>>> Thank you Jeff, >>>>>> >>>>>> subset( DM, "B" != x ), this works if I know the group only. >>>>>> But if I don't know that group in this case "B", how do I identify >>>>>> group(s) that all elements of x have the same value? >>>>>> >>>>>> On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller >>>>>> wrote: >>>>>>> subset( DM, "B" != x ) >>>>>>> >>>>>>> This is covered in the Introduction to R document that comes with R. >>>>>>> -- >>>>>>> Sent from my phone. Please excuse my brevity. >>>>>>> >>>>>>> On December 6, 2017 3:21:12 PM PST, David Winsemius >>>>>>> wrote: >>>>>>>> >>>>>>>>> On Dec 6, 2017, at 3:15 PM, Ashta wrote: >>>>>>>>> >>>>>>>>> Hi all, >>>>>>>>> In a data set I have group(GR) and two variables x and y. I want to >>>>>>>>> remove a group that have the same record for the x variable in each >>>>>>>>> row. >>>>>>>>> >>>>>>>>> DM <- read.table( text='GR x y >>>>>>>>> A 25 125 >>>>>>>>> A 23 135 >>>>>>>>> A 14 145 >>>>>>>>> A 12 230 >>>>>>>>> B 25 321 >>>>>>>>> B 25 512 >>>>>>>>> B 25 123 >>>>>>>>> B 25 451 >>>>>>>>> C 11 521 >>>>>>>>> C 14 235 >>>>>>>>> C 15 258 &g
Re: [R] MSVAR model
> On Dec 9, 2017, at 8:51 PM, ah a via R-help wrote: > > Hello, > > As I'm interested to search about the monetary transmission channel in our > country by MSVAR model,Could you do me favor and tell me How I can run > different types of MSVAR model (such as MSIAH(2)-VAR(2)) and finding > impulse response function in different regimes and also variance > decomposition? This is uncomfortably close to an existing fortune: fortunes::fortune("brain surgery") Why don't you read the Posting Guide. Then perhaps you can improve your question? -- David. > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] delta and sd parameters for power.t.test
> On Dec 14, 2017, at 2:26 PM, Lasse Kliemann wrote: > > What is the rationale behind having both the delta and sd parameters for > the power.t.test function? One is the standard deviation of the hypothesized data (or pooled sd in the case of two sample) under the "alternative" and one is the mean of that data (or equivalently the differences if this is a two-sample test). > For the relevant noncentrality parameter, we > only need the ratio delta/sd. If my effect size is given as Cohen's d, > then I only got that ratio and not sd. > If the data has been "standardized", then Cohen's d could be given to the function as the value for delta since the sd default is 1. > As far as I see, in such a case, I can specify delta=d and leave sd at > its default value 1. Is this correct or am I missing something? > Actually it sounds as though we are missing something. The power.t.test function makes no mention of Cohen's d or effect size. Is this question in response to a homework assignment about which we have not been informed? Further questions should have some actual R code to make this an on-topic discussion for Rhelp. > Thanks. > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] something weird has happened....!!!!!!!!!!
> On Dec 15, 2017, at 4:45 AM, akshay kulkarni wrote: > > dear Members, > > > > Today something weird has happened on my R console. I have attached two > screenshots of the same vector in my R console but they differ. > > > Also one of my function returns negative values, even after double checking > the code, which should return only positive values.. > > > Whats wrong..? Reinstall R? > > > Thanks for help We have no way of knowing what the function `yguii` might be doing. Apparently it has some sort of "random" internal process. If you want to see whether this is really a deterministic process (a pseudo-random process), then you should use `set.seed` to establish a reproducible state in the RNG prior to your function call. > > > AKSHAY M KULKARNI > > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Errors in reading in txt files
> On Dec 15, 2017, at 9:21 AM, lily li wrote: > > I use the method, df$Time = as.POSIXct(df$Time), but it has the warning > message: > Error in as.POSIXlt.character(x, tz, ...) : > character string is not in a standard unambiguous format That's because your date-time data is not in "%Y-%m-%d %H:%M" format. Read: ?strptime -- David. > > On Thu, Dec 14, 2017 at 1:31 PM, MacQueen, Don wrote: > >> In addition to which, I would recommend >> >> df <- read.table("DATAM", header = TRUE, fill = TRUE, >> stringsAsFactors=FALSE) >> >> and then converting the Time column to POSIXct date-time values using >> as.POSIXct() >> specifying the format using formatting codes found in >> ?strptime >> because the times are not in the POSIXct default format. >> >> >> This example might indicate the idea: >> >>> as.POSIXct('2012-10-12 13:14') >> [1] "2012-10-12 13:14:00 PDT" >>> class(as.POSIXct('2012-10-12 13:14')) >> [1] "POSIXct" "POSIXt" >> >> -Don >> >> -- >> Don MacQueen >> Lawrence Livermore National Laboratory >> 7000 East Ave., L-627 >> Livermore, CA 94550 >> 925-423-1062 >> Lab cell 925-724-7509 >> >> >> >> On 12/14/17, 11:01 AM, "R-help on behalf of Ista Zahn" < >> r-help-boun...@r-project.org on behalf of istaz...@gmail.com> wrote: >> >>On Thu, Dec 14, 2017 at 1:58 PM, Berend Hasselman >> wrote: >>> >>>> On 14 Dec 2017, at 19:36, lily li wrote: >>>> >>>> Hi R users, >>>> >>>> I have a question about reading from text files. The file has the >> structure >>>> below: >>>> >>>> TimeColumn1 Column2 >>>> 01.01.2001-12:00:00 >>> >>> This line does not contain 3 elements; only one. >>> You'll have to fix that line. Delete it, prepend it with a comment >> character of add enough columns. >> >>I definitely don't recommend that. Instead, read >> >>?read.table >> >>to learn about the "fill" and "header" arguments. >> >>df = read.table("DATAM", header = TRUE, fill = TRUE) >> >>will probably work. >> >>Best, >>Ista >> >> >>> >>> >>> Berend >>> >>>> 01.01.2001-24:00:0012 11 >>>> 01.02.2001-12:00:0013 10 >>>> 01.02.2001-24:00:0011 12 >>>> 01.03.2001-12:00:0015 11 >>>> 01.03.2001-24:00:0016 10 >>>> ... >>>> >>>> I just use the simple script to open it: df = read.table('DATAM', >> head=T). >>>> >>>> But it has the error and thus cannot read the file: >>>> Error in scan(file = file, what = what, sep = sep, quote = quote, >> dec = >>>> dec, : >>>> line 1 did not have 3 elements >>>> >>>> How to read it with three fixed columns, and how to read the time >> format in >>>> the first column correctly? Thanks for your help. >>>> >>>> [[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-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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] offset with a factor
> On Dec 20, 2017, at 6:51 AM, Bond, Stephen wrote: > > Knowledgeable useRs, > > Please, advise how to use offset with a factor. I estimate monthly effects > from a much bigger data set as monthly effects seem to be stable, and other > variables are estimated from a small, but recent data set as there is > variation in those non-seasonal coefficients. > How can I use the seasonality estimates from the big data set as an offset > provided to the small data set. I know an offset is supposed to be > quantitative, but this is such a practical and sensible scenario, I feel > compelled. Assume I have 11 coefs estimated with contr.sum. Why not create a variable that specifies the relevant coefficient for each of the various levels of the factor (and 0 for the reference level? Then pass that variable to the offset argument. -- David. > > Thanks everybody > > Stephen > > > [[alternative HTML version deleted]] Do note: Rhelp is a plain-text mailing list. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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 in installing "simpleaffy"
> On Dec 20, 2017, at 7:55 AM, Rahele Amirkhah > wrote: > > Dear Madam/ Sir, > I am using R version 3.4.2. I want to analyse microarray data. when I want to > install "simpleaffy" package I get this error "package ‘simpleaffy’ is not > available (for R version 3.4.2)". I have the same problem with R version > 3.3.2. That's because it's not a CRAN package. It's a Bioc package. > Could you please help me to solve it? > I am working with RStudio 0.99.903.exe. I also have problem in getting the > new release of RStudio. Could you please tell me how I can get the last > release? That's off-topic for this mailing list. Ask at RStudio > Many thanks in advance.Best regards,Raheleh Amirkhah > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] LSD-test
> On Dec 25, 2017, at 10:21 AM, Ahmed Attia wrote: > > LSD.test ?LSD.test No documentation for ‘LSD.test’ in specified packages and libraries: you could try ‘??LSD.test’ -- David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] LSD-test
> On Dec 25, 2017, at 2:09 PM, Ahmed Attia wrote: > > The model should be class aov or lm and my model class is aovlist. > tried tidy from broom library but did not work. To make it class aov, > I had to remove the error term; > > model <- > aov(Rotationdata_R$`GY(Mg/ha)`~Rep+code*as.factor(Nitrogen),data=Rotationdata_R) You seemed to have missed my point that LSD.test is not in the packages loaded by default. > Ahmed Attia, Ph.D. > Agronomist & Soil Scientist > > > > > > > On Mon, Dec 25, 2017 at 7:38 PM, David Winsemius > wrote: >> >>> On Dec 25, 2017, at 10:21 AM, Ahmed Attia wrote: >>> >>> LSD.test >> >> ?LSD.test >> No documentation for ‘LSD.test’ in specified packages and libraries: >> you could try ‘??LSD.test’ >> >> -- >> David Winsemius >> Alameda, CA, USA >> >> 'Any technology distinguishable from magic is insufficiently advanced.' >> -Gehm's Corollary to Clarke's Third Law >> >> >> >> >> David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] RQuantLib
> On Dec 30, 2017, at 7:54 AM, rsherry8 wrote: > > OA, > > Thanks for the response. I downloaded the file RQuantLib_0.4.4.tar.gz > into a directory c:\r.zip on my Windows machine. I then ran the > following command and I received the following output: > >> install.packages("RQuantLib", lib="/r.zip/") > Warning message: > package ‘RQuantLib’ is not available (for R version 3.4.3) The install.packages command should include repo=NULL when installing from local binary package, and it also should include type="source when the package is not binary. > > I did not unpack the .gz file. Should I have? > > Please comment. > Bob Sherry > > On 12/30/2017 2:24 AM, Orvalho Augusto wrote: >> Hi Bob, >> >> I don't know what is the cause of your trouble but try this: >> 1. Download the zip of package. >> >> 2. And install it from local zip files. This you find on the Packages >> menu. >> >> Hope it helps >> OA >> >> >> On Fri, Dec 29, 2017 at 10:31 AM, rsherry8 > <mailto:rsher...@comcast.net>> wrote: >> >>Joshua, >> >>Thanks for the response. When you said at least version 3.4.0, I >>upgraded to 3.4.2 which I believe is the current version. Now, I >>attempted to install the package RQuantLib but it did not work. >>Here is what I got: >> >>> install.packages("RQuantLib") >>Installing package into ‘C:/Users/rsher/Documents/R/win-library/3.4’ >>(as ‘lib’ is unspecified) >>Warning message: >>package ‘RQuantLib’ is not available (for R version 3.4.2) >> >> >>Please help. >>Thanks, >>Bob Sherry >> >> >>On 12/28/2017 10:28 PM, Joshua Ulrich wrote: >> >>On Thu, Dec 28, 2017 at 6:02 PM, rsherry8 >>mailto:rsher...@comcast.net>> wrote: >> >>I have recently installed R on my new computer. I also >>want to install the >>package RQuantLib. So I run the following command and get >>the following >>output: >> >> install.packages("RQuantLib") >> >>Installing package into >>‘C:/Users/rsher/Documents/R/win-library/3.2’ >>(as ‘lib’ is unspecified) >>--- Please select a CRAN mirror for use in this session --- >>Warning message: >>package ‘RQuantLib’ is not available (for R version 3.2.4 >>Revised) >> >>The package did not install. Am I doing something wrong. >>Is the package >>going to be updated for the latest version of R? >> >>Windows binary packages are only built for the most current >>(major) >>version of R. You need to upgrade to at least R-3.4.0, or you >>will >>have to install RQuantLib (and therefore QuantLib itself) from >>source. >> >>Thanks, >>Bob >> >>__ >>R-help@r-project.org <mailto:R-help@r-project.org> mailing >>list -- To UNSUBSCRIBE and more, see >>https://stat.ethz.ch/mailman/listinfo/r-help >><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. >> >> >> >> >>__ >>R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- >>To UNSUBSCRIBE and more, see >>https://stat.ethz.ch/mailman/listinfo/r-help >><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 -- 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] RQuantLib
> On Dec 30, 2017, at 9:44 AM, David Winsemius wrote: > > >> On Dec 30, 2017, at 7:54 AM, rsherry8 wrote: >> >> OA, >> >> Thanks for the response. I downloaded the file RQuantLib_0.4.4.tar.gz >> into a directory c:\r.zip on my Windows machine. I then ran the >> following command and I received the following output: >> >>> install.packages("RQuantLib", lib="/r.zip/") >> Warning message: >> package ‘RQuantLib’ is not available (for R version 3.4.3) > > The install.packages command should include repo=NULL when installing from > local binary package, and it also should include type="source when the > package is not binary. Furthermore, the system requirements in the DESCRIPTION file are: SystemRequirements: QuantLib library (>= 1.8.0) from http://quantlib.org, Boost library from http://www.boost.org >> >> I did not unpack the .gz file. Should I have? >> >> Please comment. >> Bob Sherry >> >> On 12/30/2017 2:24 AM, Orvalho Augusto wrote: >>> Hi Bob, >>> >>> I don't know what is the cause of your trouble but try this: >>> 1. Download the zip of package. >>> >>> 2. And install it from local zip files. This you find on the Packages >>> menu. >>> >>> Hope it helps >>> OA >>> >>> >>> On Fri, Dec 29, 2017 at 10:31 AM, rsherry8 >> <mailto:rsher...@comcast.net>> wrote: >>> >>> Joshua, >>> >>> Thanks for the response. When you said at least version 3.4.0, I >>> upgraded to 3.4.2 which I believe is the current version. Now, I >>> attempted to install the package RQuantLib but it did not work. >>> Here is what I got: >>> >>>> install.packages("RQuantLib") >>> Installing package into ‘C:/Users/rsher/Documents/R/win-library/3.4’ >>> (as ‘lib’ is unspecified) >>> Warning message: >>> package ‘RQuantLib’ is not available (for R version 3.4.2) >>> >>> >>> Please help. >>> Thanks, >>> Bob Sherry >>> >>> >>> On 12/28/2017 10:28 PM, Joshua Ulrich wrote: >>> >>> On Thu, Dec 28, 2017 at 6:02 PM, rsherry8 >>> mailto:rsher...@comcast.net>> wrote: >>> >>> I have recently installed R on my new computer. I also >>> want to install the >>> package RQuantLib. So I run the following command and get >>> the following >>> output: >>> >>> install.packages("RQuantLib") >>> >>> Installing package into >>> ‘C:/Users/rsher/Documents/R/win-library/3.2’ >>> (as ‘lib’ is unspecified) >>> --- Please select a CRAN mirror for use in this session --- >>> Warning message: >>> package ‘RQuantLib’ is not available (for R version 3.2.4 >>> Revised) >>> >>> The package did not install. Am I doing something wrong. >>> Is the package >>> going to be updated for the latest version of R? >>> >>> Windows binary packages are only built for the most current >>> (major) >>> version of R. You need to upgrade to at least R-3.4.0, or you >>> will >>> have to install RQuantLib (and therefore QuantLib itself) from >>> source. >>> >>> Thanks, >>> Bob >>> >>> __ >>> R-help@r-project.org <mailto:R-help@r-project.org> mailing >>> list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> <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. >>> >>> >>> >>> >>> __ >>> R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- >>> To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> <https://stat.ethz.ch/
Re: [R] RQuantLib
> On Dec 30, 2017, at 9:46 AM, David Winsemius wrote: > > >> On Dec 30, 2017, at 9:44 AM, David Winsemius wrote: >> >> >>> On Dec 30, 2017, at 7:54 AM, rsherry8 wrote: >>> >>> OA, >>> >>> Thanks for the response. I downloaded the file RQuantLib_0.4.4.tar.gz >>> into a directory c:\r.zip on my Windows machine. I then ran the >>> following command and I received the following output: >>> >>>> install.packages("RQuantLib", lib="/r.zip/") >>> Warning message: >>> package ‘RQuantLib’ is not available (for R version 3.4.3) >> >> The install.packages command should include repo=NULL when installing from >> local binary package, and it also should include type="source" Added the missing dbl-quote. >> when the package is not binary. > > Furthermore, the system requirements in the DESCRIPTION file are: > > > SystemRequirements: QuantLib library (>= 1.8.0) from http://quantlib.org, > Boost library from http://www.boost.org And finally (perhaps): The binaries at CRAN for windows are still at 0.4.2 so you might consider install that version from source: RQuantLib_0.4.2.tar.gz at https://cran.r-project.org/src/contrib/Archive/RQuantLib/RQuantLib_0.4.2.tar.gz > > >>> >>> I did not unpack the .gz file. Should I have? >>> >>> Please comment. >>> Bob Sherry >>> >>> On 12/30/2017 2:24 AM, Orvalho Augusto wrote: >>>> Hi Bob, >>>> >>>> I don't know what is the cause of your trouble but try this: >>>> 1. Download the zip of package. >>>> >>>> 2. And install it from local zip files. This you find on the Packages >>>> menu. >>>> >>>> Hope it helps >>>> OA >>>> >>>> >>>> On Fri, Dec 29, 2017 at 10:31 AM, rsherry8 >>> <mailto:rsher...@comcast.net>> wrote: >>>> >>>> Joshua, >>>> >>>> Thanks for the response. When you said at least version 3.4.0, I >>>> upgraded to 3.4.2 which I believe is the current version. Now, I >>>> attempted to install the package RQuantLib but it did not work. >>>> Here is what I got: >>>> >>>>> install.packages("RQuantLib") >>>> Installing package into ‘C:/Users/rsher/Documents/R/win-library/3.4’ >>>> (as ‘lib’ is unspecified) >>>> Warning message: >>>> package ‘RQuantLib’ is not available (for R version 3.4.2) >>>> >>>> >>>> Please help. >>>> Thanks, >>>> Bob Sherry >>>> >>>> >>>> On 12/28/2017 10:28 PM, Joshua Ulrich wrote: >>>> >>>> On Thu, Dec 28, 2017 at 6:02 PM, rsherry8 >>>> mailto:rsher...@comcast.net>> wrote: >>>> >>>> I have recently installed R on my new computer. I also >>>> want to install the >>>> package RQuantLib. So I run the following command and get >>>> the following >>>> output: >>>> >>>>install.packages("RQuantLib") >>>> >>>> Installing package into >>>> ‘C:/Users/rsher/Documents/R/win-library/3.2’ >>>> (as ‘lib’ is unspecified) >>>> --- Please select a CRAN mirror for use in this session --- >>>> Warning message: >>>> package ‘RQuantLib’ is not available (for R version 3.2.4 >>>> Revised) >>>> >>>> The package did not install. Am I doing something wrong. >>>> Is the package >>>> going to be updated for the latest version of R? >>>> >>>> Windows binary packages are only built for the most current >>>> (major) >>>> version of R. You need to upgrade to at least R-3.4.0, or you >>>> will >>>> have to install RQuantLib (and therefore QuantLib itself) from >>>> source. >>>> >>>> Thanks, >>>> Bob >>>> >>>> __ >>>> R-help@r-project.org <mailto:R-help@r-project.org> mailing >>>> list -- To UNSUBSCRIBE and more, see >>>> https://stat.ethz.ch/mailman/listinfo/r-help &g
Re: [R] httr::content without message
> On Jan 2, 2018, at 9:30 AM, Roy Mendelssohn - NOAA Federal > wrote: > > Hi All: > > I am using httr to download files form a service, in this case a .csv file. > When I use httr::content on the result, I get a message. Since this will be > in a package. I want to suppress the message, but haven't figured out how > to do so. > > The following should reproduce the result: > > myURL <- > 'https://coastwatch.pfeg.noaa.gov/erddap/griddap/erdMH1sstdmday.csvp?time[0:1:last]' > r1 <- httr::GET(myURL) > junk <- httr::content(r1) Instead try: junk <- suppressMessages(httr::content(r1)) > > when the last command is run, you get: > > Parsed with column specification: > cols( > `time (UTC)` = col_datetime(format = "") > ) > > I want to suppress that output. > > Thanks, > > -Roy > > ** > "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > ** > Roy Mendelssohn > Supervisory Operations Research Analyst > NOAA/NMFS > Environmental Research Division > Southwest Fisheries Science Center > ***Note new street address*** > 110 McAllister Way > Santa Cruz, CA 95060 > Phone: (831)-420-3666 > Fax: (831) 420-3980 > e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ > > "Old age and treachery will overcome youth and skill." > "From those who have been given much, much will be expected" > "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Help with Regular expression
On Wed, Jan 03, 2018 at 07:56:27PM +0530, Christofer Bogaso wrote: > Hi, > > I was working on following expression : > > "\":\"03-JAN-2018 16:00:00\"" > > > This is basically a combination of Date and Time mixed with some Noise. > > I want to extract only Date and Time part i.e. "03-JAN-2018 16:00:00 > > I tried following : > > gsub("![0-9][0-9]-[a-zA-Z][a-zA-Z][a-zA-Z]-[0-9][0-9][0-9][0-9] > [0-9][0-9]:[0-9][0-9]:[0-9][0-9]", "", "\":\"03-JAN-2018 16:00:00\"", > ignore.case = TRUE) > > Obviously, with above code, I am removing that portion of my string > which I actually I wanted! > > How can I reverse above code, so that I will be removing that portion > of my string which I actually I ***NOT*** wanted? > You may find strptime() more suitable for the intended purpose. Peace, david -- David H. Wolfskill r...@catwhisker.org If you want the best Fake News, go to the best source of it: Donald J. Trump. See http://www.catwhisker.org/~david/publickey.gpg for my public key. signature.asc Description: PGP signature __ 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] summary.rms help
> On Jan 3, 2018, at 11:57 AM, Andras Farkas via R-help > wrote: > > Dear All, > using the example from the help of summary.rms > > library(rms) > n <- 1000# define sample size > set.seed(17) # so can reproduce the results > age<- rnorm(n, 50, 10) > blood.pressure <- rnorm(n, 120, 15) > cholesterol<- rnorm(n, 200, 25) > sex<- factor(sample(c('female','male'), n,TRUE)) > label(age)<- 'Age' # label is in Hmisc > label(cholesterol)<- 'Total Cholesterol' > label(blood.pressure) <- 'Systolic Blood Pressure' > label(sex)<- 'Sex' > units(cholesterol)<- 'mg/dl' # uses units.default in Hmisc > units(blood.pressure) <- 'mmHg' > # Specify population model for log odds that Y=1 > L <- .4*(sex=='male') + .045*(age-50) + > (log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male')) > # Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)] > y <- ifelse(runif(n) < plogis(L), 1, 0) > ddist <- datadist(age, blood.pressure, cholesterol, sex) > options(datadist='ddist') > fit <- lrm(y ~ blood.pressure + sex * (age + rcs(cholesterol,4))) > s <- summary(fit) > plot(s) > as you will see the plot will by default include the low and high values from > the summary printed on the plot to the right of the variable name... Any > thoughts on how printing these low and high values can be suppressed, ie: > prevent them from being printed? > Luke, ... Look at the code! The values are suppressed if the "Diff." has NA's so ... s[ , "Diff."] <- NA plot(s) -- David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] format integer numbers with leading 0
On Thu, Jan 04, 2018 at 09:12:12PM +0100, Marc Girondot via R-help wrote: > Dear R-er, > > I would like format integer number as characters with leading 0 for a > fixed width, for example: > > 1 shoud be "01" > 2 shoud be "02" > 20 should be "20" > > Now I use: > > x <- c(1, 2, 20) > > gsub(" ", "0", format(x, width=2)) > > But I suspect more elegant way could be done directly with format > options, but I don't find. > x <- c(1, 2, 20) > sprintf("%02d", x) [1] "01" "02" "20" > Peace, david -- David H. Wolfskill r...@catwhisker.org If you want the best Fake News, go to the best source of it: Donald J. Trump. See http://www.catwhisker.org/~david/publickey.gpg for my public key. signature.asc Description: PGP signature __ 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] svm
> On Jan 10, 2018, at 10:50 AM, AbouEl-Makarim Aboueissa > wrote: > > Dear All: > > > I am trying to use the R function "svm" with "type =C-classification" , > but I got the following error message > > > SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, *type='C-classification'*, > kernel='linear',scale=FALSE) > > *Error in eval(predvars, data, env) : object 'type' not found* Yopu misspelled the name of your "typey" variable. > > > I am wondering if I should install a specific R package(s). > > > > *Here is my codes:* > > > feature.x1 <- c(0.25,0.5,1,1,1.5,2,2.25,2.5,2,1,3, 5,3.75, > 1,3.5,4,4,5,5.5,6,6,6.5) > > length(feature.x1) > > > > feature.x2 <- c(2,3.5,1,2.5,1.75,2,1.75,1.5,2.5,1,1, > 3.5,3.5,5.8,3,4,4.5,5,4,1,4,3) > > length(feature.x2) > > > y <- c(rep(-1,11), rep(1,11)) > > typey<-as.factor(y) > > > my.data.x1x2y <- data.frame(feature.x1, feature.x2, typey) > > my.data.x1x2y > > > > install.packages("e1071") > > library(e1071) > > > > SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, type='C-classification', > kernel='linear',scale=FALSE) > > plot(my.data.x1x2y[,-3],col=(typey+3)/2, pch=18, xlim=c(-1,6), ylim=c(-1,6)) > > box(lwd = 2, col="darkgreen") > > > > > > > > with many thanks > abou > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor of Statistics* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > [[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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Help with packages (methods, stats, stats4)
gt;>>> >>>>>> (i want to install those packages in order to use the "DVstats" package) >>>>>> >>>>>> (i have the latest version of R (3.4.3 ) and Rstudio(1.2.240) ) >>>>>> >>>>>> thank you >>>>>> Regards >>>>>> >>>>>> >>>>> [[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/posti >>>> ng-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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] Time-dependent coefficients in a Cox model with categorical variants
> On Jan 15, 2018, at 12:58 AM, Max Shell wrote: > > Suppose I have a dataset contain three variants, looks like >> head(dta) > > SextumorsizeHistology time status >01.52 12.1000 0 >11.81 38.4000 0 > . > > Sex: 1 for male; 0 for female., two levels > Histology: 1 for SqCC; 2 for High risk AC; 3 for low risk AC, three levels > Now I need to get a Time-dependent coefficients cox fit: > > library(survival) > for(i in c(1,3) dta[,i] <- factor(dta[,i]) > fit <- > coxph( >Surv(time, status) ~ Sex + tumorsize + Histology + tt(Histology), >data = dta, >tt = function(x, t, ...) x * log(t) > ) > > But I keep gettting this error says: > > Error in if (any(infs)) warning(paste("Loglik converged before variable ", : > missing value where TRUE/FALSE needed > In addition: Warning message: > In Ops.factor(x, log(t)) : ‘*’ not meaningful for factors. The error message seems pretty clear. You are passing a factor to the x parameter of the tt function, and then you are attempting to multiply that value times log(t). You are lucky that it was a factor and not jsut an integer because then you might not have gotten an error or a warning. I worry that your hopes of separate estimates may not be easily supportable by the tt-mechanism. However, the example of its use in the help page for `coxph` shows a spline function being passed and the boundary knots and weights mush estimated, so my fears may be over-blown. The knot locations and weights are not reported in the print.coxph but it doesn't look too difficult to extract then from the attributes of the model. You might look at the mechanism for estimation of spline component effects to see if you can learn how to estimate multiple components: > coef( coxph(Surv(time, status) ~ ph.ecog + tt(age), data=lung, + tt=function(x,t,...) pspline(x + t/365.25)) ) ph.ecog ps(x + t/365.25)3 ps(x + t/365.25)4 ps(x + t/365.25)5 ps(x + t/365.25)6 ps(x + t/365.25)7 0.4528363 0.2426635 0.4876185 0.7796924 1.0160954 1.0765967 ps(x + t/365.25)8 ps(x + t/365.25)9 ps(x + t/365.25)10 ps(x + t/365.25)11 ps(x + t/365.25)12 ps(x + t/365.25)13 1.0449439 0.9170725 0.9276695 1.1349794 1.2837341 1.7024045 ps(x + t/365.25)14 2.1863712 > attr( coxph(Surv(time, status) ~ ph.ecog + tt(age), data=lung, + tt=function(x,t,...) pspline(x + t/365.25))$terms, "predvars" ) list(Surv(time, status), ph.ecog, pspline(age, nterm = 10, intercept = FALSE, Boundary.knots = c(39.0136892539357, 82.0848733744011), `NA` = NULL)) The coefficients for the spline also get reported as exponentiated values in the summary output. And if you used a crossing operator in the formula you get some sort of interaction result. Whether it has any sensible interpretation is decision that's above my pay grade. The code for `pspline` is readily available. It's not even necessary to sue the triple-colon or getAnywhere functions. -- David. > > How can I fix it? I know that the "Sex" and "Histology" are both > categorical variants. I want to have a model that have two β(t) = a + > blog(t) for each histology level. > 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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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] reading lisp file in R
> On Jan 17, 2018, at 8:22 PM, Ranjan Maitra wrote: > > Dear friends, > > Is there a way to read data files written in lisp into R? > > Here is the file: > https://archive.ics.uci.edu/ml/machine-learning-databases/university/university.data > > I would like to read it into R. Any suggestions? It's just a text file. What difficulties are you having? > > > Thanks very much in advance for pointers on this and best wishes, > Ranjan > > -- > Important Notice: This mailbox is ignored: e-mails are set to be deleted on > receipt. Please respond to the mailing list if appropriate. For those needing > to send personal or professional e-mail, please use appropriate addresses. > > __ > 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 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law __ 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.