Re: [R-es] Resumen de R-help-es, Vol 176, Envío 1
Me chas gracias!! Ya lo pude instalar!!! El El sáb, 7 de oct. de 2023 a la(s) 07:01, escribió: > Envíe los mensajes para la lista R-help-es a > r-help-es@r-project.org > > Para subscribirse o anular su subscripción a través de la WEB > https://stat.ethz.ch/mailman/listinfo/r-help-es > > O por correo electrónico, enviando un mensaje con el texto "help" en > el asunto (subject) o en el cuerpo a: > r-help-es-requ...@r-project.org > > Puede contactar con el responsable de la lista escribiendo a: > r-help-es-ow...@r-project.org > > Si responde a algún contenido de este mensaje, por favor, edite la > linea del asunto (subject) para que el texto sea mas especifico que: > "Re: Contents of R-help-es digest...". Además, por favor, incluya en > la respuesta sólo aquellas partes del mensaje a las que está > respondiendo. > > > Asuntos del día: > >1. TeachingDemos (Amable Moreno) >2. Re: TeachingDemos (Javier Marcuzzi) > > ------ > > Message: 1 > Date: Fri, 6 Oct 2023 17:26:43 -0300 > From: Amable Moreno > To: r-help-es@r-project.org > Subject: [R-es] TeachingDemos > Message-ID: > < > cadothbhp6s5_ulc5eitx0otc7e37kx6pp2c+rekfcioj9bf...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Estimados colegas > > Hasta el año pasado he usado el paquete "TeachingDemos" > Pero ahora, este paque no lo tengo instalado y no lo puedo volver a > instalar > me marca error > Agradecweria me constesten, por favor, si alguien sabe porque ocurre > > [[alternative HTML version deleted]] > > > > > -- > > Message: 2 > Date: Fri, 6 Oct 2023 19:54:10 -0300 > From: Javier Marcuzzi > To: Amable Moreno > Cc: "R-help-es@r-project.org" > Subject: Re: [R-es] TeachingDemos > Message-ID: <32218d4b-5644-4ac8-8489-f7c01ecdd...@gmail.com> > Content-Type: text/plain; charset="utf-8" > > Estimada Amable Moreno > > En Mac, R actualizado, anda. Observe mi escritura y la respuesta. > > > install.packages("TeachingDemos") > trying URL ' > https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.3/TeachingDemos_2.12.tgz > ' > Content type 'application/x-gzip' length 1237702 bytes (1.2 MB) > == > downloaded 1.2 MB > > > Javier Rubén Marcuzzi > > > El 6 oct 2023, a las 17:26, Amable Moreno > escribió: > > > > TeachingDemos > > > [[alternative HTML version deleted]] > > > > > -- > > Subject: Pié de página del digest > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > > > -- > > Fin de Resumen de R-help-es, Vol 176, Envío 1 > * > [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R-es] TeachingDemos
Estimados colegas Hasta el año pasado he usado el paquete "TeachingDemos" Pero ahora, este paque no lo tengo instalado y no lo puedo volver a instalar me marca error Agradecweria me constesten, por favor, si alguien sabe porque ocurre [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R-es] error
Muchas gracias por la ayuda. El El lun, 10 de jul. de 2023 a la(s) 08:43, Carlos Ortega < c...@qualityexcellence.es> escribió: > Hola, > > Sí, el error no es estrictamente de "SemPlot" si no de una librería de la > que depende... > >- *namespace ‘vctrs’ 0.4.1 is being loaded, but >= 0.5.0 is required"* > > Tienes que actualizar la librería "vctrs". > De forma general, si haces un "Update" de todas las librerías, seguramente > se resuelvan este y otros problemas de dependencias. > > Gracias, > Carlos Ortega > www.qualityexcellence.es > > > El dom, 9 jul 2023 a las 4:08, Amable Moreno () > escribió: > >> Necesito que me ayuden a resolver el siguiente error al intentar usar el >> paquete "semPlot": El error es: >> "package or namespace load failed for ‘semPlot’ in loadNamespace(i, >> c(lib.loc, .libPaths()), versionCheck = vI[[i]]): >> namespace ‘vctrs’ 0.4.1 is being loaded, but >= 0.5.0 is required" >> >> [[alternative HTML version deleted]] >> >> ___ >> R-help-es mailing list >> R-help-es@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-help-es >> > > > -- > Saludos, > Carlos Ortega > www.qualityexcellence.es > [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R-es] error
Necesito que me ayuden a resolver el siguiente error al intentar usar el paquete "semPlot": El error es: "package or namespace load failed for ‘semPlot’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace ‘vctrs’ 0.4.1 is being loaded, but >= 0.5.0 is required" [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R-es] Resumen de R-help-es, Vol 172, Envío 23
Buen dia Tengo un problema con el paquete "semPlot", no puedo realizar un digrama de senderos porque me da este error:: "package or namespace load failed for ‘semPlot’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace ‘vctrs’ 0.4.1 is being loaded, but >= 0.5.0 is required" Agradeceria que alguien me ayude El vie, 16 jun 2023 a la(s) 17:16, escribió: > Envíe los mensajes para la lista R-help-es a > r-help-es@r-project.org > > Para subscribirse o anular su subscripción a través de la WEB > https://stat.ethz.ch/mailman/listinfo/r-help-es > > O por correo electrónico, enviando un mensaje con el texto "help" en > el asunto (subject) o en el cuerpo a: > r-help-es-requ...@r-project.org > > Puede contactar con el responsable de la lista escribiendo a: > r-help-es-ow...@r-project.org > > Si responde a algún contenido de este mensaje, por favor, edite la > linea del asunto (subject) para que el texto sea mas especifico que: > "Re: Contents of R-help-es digest...". Además, por favor, incluya en > la respuesta sólo aquellas partes del mensaje a las que está > respondiendo. > > > Asuntos del día: > >1. Re: Seleccionar valores consecutivos en un dataframe > (Juan Carlos Lopez Mesa) >2. Supuestos de una ANOVA (Yesica Pallavicini Fernandez) >3. Opciones de guardado - gráfico en png (David Camilo Gomez Medina) > > -- > > Message: 1 > Date: Fri, 16 Jun 2023 05:02:14 -0500 > From: Juan Carlos Lopez Mesa > To: jose luis > Cc: "r-help-es@r-project.org" , Jaume Tormo > > Subject: Re: [R-es] Seleccionar valores consecutivos en un dataframe > Message-ID: > < > cahuwr6oentz4dpwxyuop0k39txmyfv4nrdmrkxn4kayp1k5...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Hola, > Este código le puede servir para lo que necesita > library(dplyr) > > ejemplo$dia <- as.Date(ejemplo$dia) > > ejemplo <- arrange(ejemplo, dia) > > ejemplo$suma <- NA > > ejemplo$suma[1] <- as.numeric(ejemplo$germ) > > for(i in 2:nrow(ejemplo)){ > > ejemplo$suma[i] <- ifelse(ejemplo$germ[i], > ejemplo$suma[i-1] + ejemplo$p[i], > 0) > } > > > Saludos > > > > El vie, 16 jun 2023 a las 3:21, jose luis via R-help-es (< > r-help-es@r-project.org>) escribió: > > > Hola Jaumecomo todos los valores de p son menores de 1he entendido > > esto: por ejemplo en la fila 5 que sería el segundo TRUE, quieres que la > > nueva variable sea la suma del valor de la fila 4 mas el de la fila 5 y > asi > > sucesivamente. ¿o me desvío mucho? > > En viernes, 16 de junio de 2023, 09:28:18 CEST, Jaume Tormo via > > R-help-es escribió: > > > > Estimados eRReros, > > Tengo un df como el adjunto (en txt y como objeto de R)Como veréis hay > una > > columna T/F que se llama germ y cada fila corresponde a datos de un día. > > Me gustaría que R fuera siguiendo la columna germ y en cada serie de días > > con TRUE sumara el valor de la columna p. Se trata de saber si en esa > serie > > de días con valor T el total de p es mayor que 1 o no. > > He hecho algo parecido con rle() que me cuenta la longitud de las series > > de TRUE, pero este siguiente paso no se como darlo.Si uso apply o subset > me > > toma todas las filas del df con T en la columna germ. Lo que no se el > como > > decirle a R que empiece por el principio y vaya tomando grupo a grupo.Me > > imagino que podría llegar a construir un bucle que lo hiciera, pero no > > quiero pasarme tres horas dándole vueltas si hay una función o > combinación > > de funciones que lo hace ¿Alguna sugerencia o me pongo ya con el bucle? > > > > Muchas gracias. > > Jaume. > > > > > > -- > > Dr. Jaume Tormo. > > Area of Ecology > > Department of Agrarian and Environmental Sciences > > Technological College. Agri-food and Environment > > University of Zaragoza, Spain > > 0034 974292678 > > https://flipboard.com/@jaumetormo/hallazgos-interesantes-bj8opmboy > > https://acercad.wordpress.com/ > > > > ___ > > R-help-es mailing list > > R-help-es@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-help-es > > > > [[alternative HTML version deleted]] > > > > ___ > > R-help-es mailing list > > R-help-es@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-help-es > > > > -- > *Aviso legal:* El contenido de este mensaje y los archivos adjuntos son > confidenciales y de uso exclusivo de la Universidad Nacional de Colombia. > Se encuentran dirigidos sólo para el uso del destinatario al cual van > enviados. La reproducción, lectura y/o copia se encuentran prohibidas a > cualquier persona diferente a este y puede ser ilegal. Si usted lo ha > recibido por error, infórmenos y elimínelo de su correo. Los Datos > Personales serán tratados conforme a la Ley 1581 de 2012 y a nuestra > Política de Datos Personales que podrá
[R-es] covarianza
Quisiera saber, si existe algún paquete de R específico para los modelos lineales, en particular el modelo de covarianza [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R-es] paquete npsm
Buen dia a todos Quisiera saber con qué paquete hacer el test de Fligner Killen porque lo solia resolver con el paquete npsm pero ahora ese paquete no se puede bajar [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R] recovering PLSDA equations for prediction (outside R)
Hi all, I'm trying to use the result of a PLSDA model outside R, but I'm having a really hard time finding documentation on how to write the model from the results in the fit object. In order to provide a good starting point I believe that this code creates a good model that is stored in the fit variable. I know that I can use the predict function to create the predictions but I would like to "write the predict function outside R". Can anyone provide me with the equations? Thanks # load the package library(caret) data(iris) x <- iris[,1:4] y <- iris[,5] # fit model fit <- plsda(x, y, probMethod="Bayes") # summarize the fit summary(fit) # make predictions predictions <- predict(fit, iris[,1:4]) # summarize accuracy table(predictions, iris$Species) [[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] Soft Question: Where to find this reference.
See book: Statistical Models in S (ISBN-10: 041283040X; ISBN-13: 978-0412830402) Chapter 5, p. 145. • Analysis of Variance; Designed Experiments, J. M. Chambers, A. E. Freeny and R. M. Heiberger, Statistical Models in S, J. M. Chambers and T. J. Hastie (editors), Wadsworth & Brooks/Cole, Pacific Grove, California, 1992. > On Jul 25, 2016, at 06:48, Justin Thongwrote: > > I notice a lot of r documentation refer to this reference below. I can't > seem to find it anywhere. > Does anyone have a link to point to where I can either view it or buy it? > > > *Chambers, J. M., Freeny, A and Heiberger, R. M. (1992) Analysis of > variance; designed experiments* > > -- > Yours sincerely, > Justin > > *I check my email at 9AM and 4PM everyday* > *If you have an EMERGENCY, contact me at +447938674419(UK) or > +60125056192(Malaysia)* > > [[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-es] Problemas de instalación
Buenos días, He cambiado la versión de R como siempre a través de: install.packages("installr") library(installr) updateR() En esta ocasión trabajando bajo windows 10. La versión 3.2.2 me ofrece menos mirror, pero mi principal problema es que no soy capaz de trabajar con Rcommander (ahora lo hago con RStudio) me da la siguiente salida: > utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- probando la URL ' https://ftp.cixug.es/CRAN/bin/windows/contrib/3.2/Rcmdr_2.2-3.zip' Content type 'application/zip' length 5464077 bytes (5.2 MB) downloaded 5.2 MB package ‘Rcmdr’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\JUSMI\AppData\Local\Temp\Rtmpeui6Qa\downloaded_packages pero no lanza la interfaz, dando el siguiente fallo: > library(Rcmdr) Loading required package: car Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called ‘lme4’ Error: package ‘car’ could not be loaded Pensaba que había algún problema con la descarga de archivo, pero no parce. Alguien puede ayudarme Gracias por anticipado Saludos Justo [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] ncdf size error
Sure, here it is. Thanks for any help with this Dr. Pierce: # Exporting to NETCDF files # # define the netcdf coordinate variables library(ncdf) dim1 = dim.def.ncdf( Nodes,, seq(1,19000)) dim2= dim.def.ncdf( Time,Hours since 2005-01-01 00:00:00,seq(1:2190)) #final[1,2,])) varT2 = var.def.ncdf(T2,celsius, list(dim1,dim2), -9, longname=T2) varQ2 = var.def.ncdf(Q2,kg kg-1, list(dim1,dim2), -9, longname=Q2) varQVAPOR = var.def.ncdf(QVAPOR,kg kg-1, list(dim1,dim2), -9, longname=QVAPOR) varQCLOUD = var.def.ncdf(QCLOUD,kg kg-1, list(dim1,dim2), -9, longname=QCLOUD) varPSFC = var.def.ncdf(PSFC,Pa, list(dim1,dim2), -9, longname=PSFC) varW10 = var.def.ncdf(W10,ms-1, list(dim1,dim2), -9, longname=W10) varW = var.def.ncdf(W,ms-1, list(dim1,dim2), -9, longname=W) varVEGFRA = var.def.ncdf(VEGFRA,, list(dim1,dim2), -9, longname=VEGFRA) varMAXVEGFRA = var.def.ncdf(MAXVEGFRA,, list(dim1,dim2), -9, longname=MAXVEGFRA) varTPREC = var.def.ncdf(TPREC,mm, list(dim1,dim2), -9, longname=TPREC) varFRAC_FROZ_PREC = var.def.ncdf(FRAC_FROZ_PREC,mm, list(dim1,dim2), -9, longname=FRAC_FROZ_PREC) varSWDOWN = var.def.ncdf(SWDOWN,W m-2, list(dim1,dim2), -9, longname=SWDOWN) varGLW = var.def.ncdf(GLW,W m-2, list(dim1,dim2), -9, longname=GLW) varPBLH = var.def.ncdf(PBLH,m, list(dim1,dim2), -9, longname=PBLH) varTSLB = var.def.ncdf(TSLB,Celsius, list(dim1,dim2), -9, longname=TSLB) # associate the netcdf variable with a netcdf file # put the variable into the file, and # close nc.ex = create.ncdf(/media/D/output.nc,list(varT2, varQ2, varQVAPOR, varQCLOUD, varPSFC, varW10, varW, varVEGFRA, varMAXVEGFRA, varTPREC, varFRAC_FROZ_PREC, varSWDOWN, varGLW, varPBLH, varTSLB)) Error in R_nc_enddef: NetCDF: One or more variable sizes violate format constraints Error in R_nc_sync: NetCDF: Operation not allowed in define mode --- Hernan A. Moreno, Ph.D. Postdoctoral Research Associate Department of Civil Architectural Engineering Room 3038, Engineering Building University of Wyoming Phone: 480-3990571 http://www.public.asu.edu/~hamoreno/ From: davidwilliampie...@gmail.com davidwilliampie...@gmail.com on behalf of David W. Pierce dpie...@ucsd.edu Sent: Monday, September 15, 2014 7:00 PM To: Hernan A. Moreno Ramirez Cc: r-help@r-project.org Subject: Re: [R] ncdf size error On Mon, Sep 15, 2014 at 4:20 PM, Hernan A. Moreno Ramirez hmore...@uwyo.edu wrote: Hi I am using both ncdf and ncdf4 libraries and with both I keep getting the same error: Error in R_nc_enddef: NetCDF: One or more variable sizes violate format constraints. Error in R_nc_sync: NetCDF: Operation not allowed in define mode. This happens when I try to create.ncdf() a file with more than 13 variables. I think is a problem of memory size. What would you recommend? Any help will be appreciated Hi Hernan, can you supply an example that shows the problem? Regards, --Dave --- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography, La Jolla, California, USA (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ncdf size error
Hi Professor, Thanks for you valuable help. I did change my code to use ncdf4 package and still I get the same error: # Exporting to NETCDF files # # define the netcdf coordinate variables -- note these have values! library(ncdf4) cat(--Exporting final NETCDF file to Outputfolder,fill=TRUE) dim1 = ncdim_def( Nodes,, seq(1,19000)) dim2= ncdim_def( Time,Hours since 2005-01-01 00:00:00,seq(1:2190)) #final[1,2,])) #dim2= dim.def.ncdf( Time,,as.data.frame(final[1,2,])) # define the EMPTY (elevation) netcdf variable varT2 = ncvar_def(T2,celsius, list(dim1,dim2), -9, longname=T2) varQ2 = ncvar_def(Q2,kg kg-1, list(dim1,dim2), -9, longname=Q2) varQVAPOR = ncvar_def(QVAPOR,kg kg-1, list(dim1,dim2), -9, longname=QVAPOR) varQCLOUD = ncvar_def(QCLOUD,kg kg-1, list(dim1,dim2), -9, longname=QCLOUD) varPSFC = ncvar_def(PSFC,Pa, list(dim1,dim2), -9, longname=PSFC) varW10 = ncvar_def(W10,ms-1, list(dim1,dim2), -9, longname=W10) varW = ncvar_def(W,ms-1, list(dim1,dim2), -9, longname=W) varVEGFRA = ncvar_def(VEGFRA,, list(dim1,dim2), -9, longname=VEGFRA) varMAXVEGFRA = ncvar_def(MAXVEGFRA,, list(dim1,dim2), -9, longname=MAXVEGFRA) varTPREC = ncvar_def(TPREC,mm, list(dim1,dim2), -9, longname=TPREC) varFRAC_FROZ_PREC = ncvar_def(FRAC_FROZ_PREC,mm, list(dim1,dim2), -9, longname=FRAC_FROZ_PREC) varSWDOWN = ncvar_def(SWDOWN,W m-2, list(dim1,dim2), -9, longname=SWDOWN) varGLW = ncvar_def(GLW,W m-2, list(dim1,dim2), -9, longname=GLW) varPBLH = ncvar_def(PBLH,m, list(dim1,dim2), -9, longname=PBLH) varTSLB = ncvar_def(TSLB,Celsius, list(dim1,dim2), -9, longname=TSLB) nc.ex = nc_create(/media/D/output.nc,list(varT2, varQ2, varQVAPOR, varQCLOUD, varPSFC, varW10, varW, varVEGFRA, varMAXVEGFRA, varTPREC, varFRAC_FROZ_PREC, varSWDOWN, varGLW, varPBLH, varTSLB)) Error in R_nc4_enddef: NetCDF: One or more variable sizes violate format constraints Error in R_nc4_sync: NetCDF: Operation not allowed in define mode Thanks a lot for more help --- Hernan A. Moreno, Ph.D. Postdoctoral Research Associate Department of Civil Architectural Engineering Room 3038, Engineering Building University of Wyoming Phone: 480-3990571 http://www.public.asu.edu/~hamoreno/ From: davidwilliampie...@gmail.com davidwilliampie...@gmail.com on behalf of David W. Pierce dpie...@ucsd.edu Sent: Tuesday, September 16, 2014 2:21 PM To: Hernan A. Moreno Ramirez Cc: r-help@r-project.org Subject: Re: [R] ncdf size error On Tue, Sep 16, 2014 at 11:36 AM, Hernan A. Moreno Ramirez hmore...@uwyo.edu wrote: Sure, here it is. Thanks for any help with this Dr. Pierce: # Exporting to NETCDF files # # define the netcdf coordinate variables library(ncdf) ... rest of example omitted ... Hi Hernan, The file you are trying to make is violating size constraints imposed by the netcdf library/R interface, which is 2 GB in the R ncdf package. To get around this switch to the R ncdf4 package, which is the replacement for the ncdf package (I stopped supporting the ncdf package in 2010) and set force_v4=TRUE in the nc_create() call. This requires a modern version of the netcdf library to be installed on your machine, which it probably is, since the netcdf version 4 library has been out for many years now. Regards, --Dave http://www.public.asu.edu/~hamoreno/ From: davidwilliampie...@gmail.com davidwilliampie...@gmail.com on behalf of David W. Pierce dpie...@ucsd.edu Sent: Monday, September 15, 2014 7:00 PM To: Hernan A. Moreno Ramirez Cc: r-help@r-project.org Subject: Re: [R] ncdf size error On Mon, Sep 15, 2014 at 4:20 PM, Hernan A. Moreno Ramirez hmore...@uwyo.edu wrote: Hi I am using both ncdf and ncdf4 libraries and with both I keep getting the same error: Error in R_nc_enddef: NetCDF: One or more variable sizes violate format constraints. Error in R_nc_sync: NetCDF: Operation not allowed in define mode. This happens when I try to create.ncdf() a file with more than 13 variables. I think is a problem of memory size. What would you recommend? Any help will be appreciated Hi Hernan, can you supply an example that shows the problem? Regards, --Dave --- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography, La Jolla, California, USA (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography, La Jolla, California, USA (858) 534-8276 (voice) / (858) 534-8561 (fax)dpie...@ucsd.edu __ R-help@r-project.org
[R] ncdf size error
Hi I am using both ncdf and ncdf4 libraries and with both I keep getting the same error: Error in R_nc_enddef: NetCDF: One or more variable sizes violate format constraints. Error in R_nc_sync: NetCDF: Operation not allowed in define mode. This happens when I try to create.ncdf() a file with more than 13 variables. I think is a problem of memory size. What would you recommend? Any help will be appreciated,. Sent from my iPhone __ 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] writing spdiags function for R
I am posting here the brilliant solutions, gently provided by Prof JC Nash nashjc at uottawa.ca, to me; so that people struggling in the future with the same issue can find a way through. FYI, compared to the original Matlab implementation: 1) it does not handle the case with more than one input, and 2) (m n) matrices give the B matrix columns in a different order, but the d vector of indices will also be changed accordingly, so the set of columns is OK, just ordered differently cif. JN. Copied below the .R version of the spdiags code, a Fortran implementation of it, and an R wrapper to run the .f thanks again JN, your help was really invaluable :) # R version # spdiagsj - function(A) { # A is a matrix m - dim(A)[[1]] n - dim(A)[[2]] k - min(m, n) # length of diagonals Bdata-NULL # start with nothing in B matrix (as vector) jb-0 # column index of last column saved for B d-NULL # index vector of diagonals from A # d contains 0 for the principal diagonal, -i for i'th lower # diagonal (prefaced with zeros), +j for j'th upper diagonal # (suffixed by zeros) q-(m-1)+n # There are m-1 subdiagonals and n-1 superdiagonals + main diagonal if (m n) { # tall matrix Adata - as.vector(t(A)) # convert to vector BY ROWS } else { # fat or square matrix (m = n) Adata - as.vector(A) # convert to vector BY COLUMNS } # Augment the data with columns of zeros fore and aft Adata-c(rep(0,(k-1)*k), Adata, rep(0,(k-1)*k)) cat(Augmented Adata with ,length(Adata), elements:\n) print(Adata) for (i in 1:q) { tv - c(Adata[[k*(i-1)+1]], rep(0,k-1)) # top element of augmented column # plus enough zeros to pad it out (some zeros may be replaced below) # i.e., start at 1, then m+1, 2*m+1 etc. qx-min((q-i), (k-1)) # cat( qx=,qx,\n) if (qx 0) { # qx will be 0 when we are at last superdiagonal,i.e., i == q for (j in 1:qx) { # get the rest of the diagonal elements tv[[j+1]] - Adata[[k*(i+j-1)+j+1]] } } if (any(tv != 0)){ # check for non-zeros, if there are, then save jb-jb+1 # next column of B d-c(d,(i-k)) # record the index Bdata-c(Bdata, tv) # save the diagonal as column of B in vector form } } if (m n) d - -d # reset index cat(Bdata:); print(Bdata) B - matrix(Bdata, nrow=k, byrow=FALSE) # convert to matrix form result-list(B=B, d=d) } cat(Matlab example 1\n) dta - c(0, 5, 0, 10, 0, 0, 0, 0, 6, 0, 11, 0, 3, 0, 0, 7, 0, 12, 1, 4, 0, 0, 8, 0, 0, 2, 5, 0, 0, 9) A1 - matrix(dta, nrow=5, ncol=6, byrow=TRUE) print(A1) res1-spdiagsj(A1) print(res1) tmp-readline(Next) cat(Matlab example 2\n) n-10 # choose 10 for an example A2-matrix(rep(0, n*n), nrow=n, ncol=n) for (i in 1:n) { for (j in 1:n) { if (i == j) A2[i, j] - -2 if ( (i == (j-1)) || (i == (j+1))) A2[i,j] - 1 } } print(A2) res2-spdiagsj(A2) print(res2) tmp-readline(Next) cat(Matlab example 3\n) dta3 - c(11, 0, 13, 0, 0, 22, 0, 24, 0, 0, 33, 0, 41, 0, 0, 44, 0, 52, 0, 0, 0, 0, 63, 0, 0, 0, 0, 74) A3 - matrix(dta3, nrow=7, ncol=4, byrow=TRUE) print(A3) res3-spdiagsj(A3) print(res3) tmp-readline(Next) cat(try transpose\n) A3T-t(A3) print(A3T) res3T-spdiagsj(A3T) print(res3T) tmp-readline(Next) cat(Example 5B \n) dta5b1-c(6, 0, 13, 0, 0, 0, 7, 0, 14, 0, 1, 0, 8, 0, 15, 0, 2, 0, 9, 0, 0, 0, 3, 0, 10) A5b1-matrix(dta5b1, nrow=5, ncol=5, byrow=TRUE) print(A5b1) res5b1-spdiagsj(A5b1) print(res5b1) # Fortran version # subroutine jspd(m, n, k, Adata, jb, Bdata, d, tv, na, nb, nd) C Central part of spdiags for R C m and n are row and column sizes of A (underlying matrix) C jb will be number of returned diagonals C returns jb, Bdata, d integer m, n, na, nb, nd, jb, d(nd) integer i, j, k, kend, q, mn, kk1, js, je, qx double precision Adata(na), Bdata(nb), tv(k) LOGICAL not0 C k = min(m, n) C ?? check if k=1 C Bdata-NULL # start with nothing in B matrix (as vector) jb = 0 kend=0 C column index of last column saved for B C d = NULL # index vector of diagonals from A C # d contains 0 for the principal diagonal, -i for i'th lower C # diagonal (prefaced with zeros), +j for j'th upper diagonal C # (suffixed by zeros) q = (m-1)+n C There are m-1 subdiagonals and n-1 superdiagonals + main diagonal C assume we have already built Adata for tall or fat matrix C # Augment the data with columns of zeros fore and aft mn = m*n C print *,Original Adata C print
Re: [R] writing spdiags function for R
Dear R-list, l have been working on a translation of a matlab library into R, it took me a while but I am almost there to submit it to CRAN...however, for this library to be computationally competitive I need to solve an issue with the home-made R version of the spdiags.m function (an old issue coming back). What I have now working is: # A = rbind(c(1,3,1,0), c(1,1,0,2), c(2,1,0,0) ) # A = replicate(100, rnorm(50)) A = replicate(1000, rnorm(1000)) exdiag - function(mat, off) {mat[row(mat)+off == col(mat)]} spdiags - function(A){ require(Matrix) indx = which(A != 0, arr.ind = T) i = indx[,1]; j = indx[,2] d = sort(j-i); d = d[which(diff(c(-Inf, d) ) != 0)] m = nrow(A); n = ncol(A); p = length(d) empty = vector() A = as.matrix(A) ## make A logical, otherwise exdiag throws horrible warnings ## might have to condition the above command on the type of input matrix B = Matrix(0, nrow = min(c(m,n)), ncol = p, sparse = TRUE); system.time( for (k in 1:p){ print(k) if (m = n){ i = max(c(1, 1 + d[k])):min(c(n, m + d[k]) ) } else { i = max(c(1, 1 - d[k])):min(c(m, n-d[k]) ) } if (length(i) != 0){ B[i, k] = exdiag(A, d[k]) # print(B) # print(i) # print(k) } } ) return (list( B = B, d = d) ) } the advantages are: 1) that it works with matrices of any dimension (previous versions worked only with squared matrices). 2) it does not need other functions, beside exdiag to work. However, I run into serious issues with computational efficiency. As I am extracting non-zero diagonals and filling B in a for loop, the time it takes to complete each iteration highly depends on the dimensions of the matrix. Try the different starting A matrices to test this. Unfortunately, I really need to optimize this aspect, as the people who I am expecting to use this library would have really long time-series, i.e. it would make .m win over .R So, as I am wondering if there is a more efficient solution to do this (perhaps using apply?) that I cannot currently see. Perhaps using sparse matrices could help, but exdiag throws a warning: sparse[ logic ] : .M.sub.i.logical() maybe inefficient (noted also in previous responses to this post of mine). Using the function ?band has the drawback of padding the matrix with 0 (except the diagonal considered, e.g., band(A,1,1) ). Often, however, you want to keep the 0s along the diagonal of interest, distinguished from the 0s of the other diagonals. Thus, doing something like: which(band(A,1,1) != 0, arr.ind = TRUE) to get the non-zero element would also discard the 0s along the diagonal. The nice getband,R posted by Ben above, makes a combined use of diag and band, together with a system of indeces, and tries to work around the issue of the zero padding. However, I did not manage to use/adapt this function to work with matrices that are not squared. And, as I am not really 100% a programmer, I did not find a solution to it... Moreover, I believe the problem of computational efficiency would still be there, even fixing the dimensionality issue. I really hope somebody out there can help me to figure this out. thanks a lot for your precious time and attention, Moreno -- View this message in context: http://r.789695.n4.nabble.com/writing-spdiags-function-for-R-tp4552626p4674540.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] choose many files
Hello everyone on the list I want to run a FindU function on as many files as in a directory. Due of my limitations on data management I am calling the function, wait until finish the process, call for the next file and so on. I have almost 120 CSV files on the same directory. This the example of calling the function FindU(InSeries=C:/RHTests/data/tmax/00032015tmax.csv, MissingValueCode=-99.9, p.lev=0.95, Iadj=1, Mq=10, Ny4a=0, output=C:/RHTests/data/tmax/32015tmx) As you can see my input file is 00032015tmax.csv and my output file is 32015tmx. Any suggestions? Thanks a lot in advance Dr Victor M Rodríguez M Doctor en Ciencias, en Ciencias de la Tierra / Geociencias Ambientales INIFAP. CEPAB. (465) 9580167 y 86 Ext 108 y 220 / Este msg y su(s) atado(s) tiene carácter de CONFIDENCIAL y solo es para los fines descritos en su contenido. Queda expresamente prohibida bajo la ley de protección de datos del Gobierno de los Estados Unidos Mexicanos y para su difusion o extensión a terceros, se requiere del consentimiento expresso del titular de la cuenta de correo electrónico y/o del administrador del sitio en extenso de sus responsabilidades . / [[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] problem on reading many files
Hi, I have to run almost 120 stations files of temperatura (mx and min), separated, and rain. I am following the instructions on RHtests tutorial as on http://www.cmc.org.ve/mediawiki/index.php?title=Preparando_los_datos link. Bit I have no success on running on multiple files. I have the .ls file which include the names of the file station, which I include on this msg for your consideration. The instruction that I wrote on the console is listatmn - readLines (tmaxcopia.ls, warn=false) for(ifile in listatmn) FindU(paste(./,ifile,sep=),paste(salidas/,ifile,sep=),-999.9) Of course the tmaxcopia.ls is the list of stations for tmax data. But once running on the console, this is the error msg I got listatmn - readLines (tmaxcopia.ls, warn=false) Error: inesperado entrada in listatmn - readLines ( for(ifile in listatmn) FindU(paste(./,ifile,sep=),paste(salidas/,ifile,sep=),-999.9) Error: objeto 'ifnames' no encontrado What I'd like to do is to make easier and fast running the RHtest Thank's a lot in advance for your help. Dr Victor M Rodríguez M Doctor en Ciencias, en Ciencias de la Tierra / Geociencias Ambientales INIFAP. CEPAB. (465) 9580167 y 86 Ext 108 y 220 / Este msg y su(s) atado(s) tiene carácter de CONFIDENCIAL y solo es para los fines descritos en su contenido. Queda expresamente prohibida bajo la ley de protección de datos del Gobierno de los Estados Unidos Mexicanos y para su difusion o extensión a terceros, se requiere del consentimiento expresso del titular de la cuenta de correo electrónico y/o del administrador del sitio en extenso de sus responsabilidades . / [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] changing cex pointwise in lattice
, 10, 1, 13, 5, 14, 4, 21, 6, 16, 3, 0, 1, 0, 0, 8, 3, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 14, 2, 5, 3, 3, 4, 14, 6, 9, 4, 4, 3, 14, 2, 5, 85, 17, 4, 4, 1, 3, 0, 8, 2, 10, 11, 43, 10, 27, 6, 16, 11, 2, 0, 3, 0, 2, 0, 1, 3, 4, 1, 3, 1, 10, 3, 3, 1, 10, 2, 1, 1, 11, 15, 3, 1, 0, 0, 6, 2, 3, 0, 0, 1, 3, 0, 3, 2, 2, 0, 1, 2, 2, 2, 3, 0, 3, 0, 2, 3, 6, 1, 7, 0, 1, 2, 3, 3, 1, 0, 2, 1, 1, 0, 0, 0, 6, 2, 0, 2, 12, 4, 6, 5, 8, 4, 8, 4, 12, 3, 0, 0, 4, 0, 4, 0, 5, 2, 4, 1, 8, 3, 3, 1, 1, 2, 1, 1, 8, 0, 0, 0, 13, 1, 18, 1, 5, 0, 14, 2, 2, 1, 2, 0, 4, 1, 1, 1, 4, 3, 3, 2, 3, 4, 8, 2, 2, 2, 8, 4, 4, 2, 6, 4, 7, 4, 3, 1, 10, 5, 4, 40, 4, 2, 14, 3, 5, 1, 7, 4, 4, 2, 6, 4, 2, 3, 9, 1, 13, 6, 22, 8)), .Names = c(y, x, group, z), class = data.frame, row.names = c(35L, 83L, 131L, 179L, 227L, 275L, 323L, 371L, 419L, 467L, 515L, 563L, 611L, 659L, 707L, 755L, 803L, 851L, 899L, 947L, 995L, 1043L, 1091L, 1139L, 1187L, 1235L, 1283L, 1331L, 1379L, 1427L, 1475L, 1523L, 1571L, 1619L, 1667L, 1715L, 1763L, 1811L, 1859L, 1907L, 1955L, 2003L, 2051L, 2099L, 2147L, 2195L, 2243L, 2291L, 2339L, 2387L, 2435L, 2483L, 2531L, 2579L, 2627L, 2675L, 2723L, 2771L, 2819L, 2867L, 2915L, 2963L, 3011L, 3059L, 3107L, 3155L, 3203L, 3251L, 3299L, 3347L, 3395L, 3443L, 3491L, 3539L, 3587L, 3635L, 3683L, 3731L, 3779L, 3827L, 3875L, 3923L, 3971L, 4019L, 4067L, 4115L, 4163L, 4211L, 4259L, 4307L, 4355L, 4403L, 4451L, 4499L, 4547L, 4595L, 4643L, 4691L, 4739L, 4787L, 4835L, 4883L, 4931L, 4979L, 5027L, 5075L, 5123L, 5171L, 5219L, 5267L, 5315L, 5363L, 5411L, 5459L, 5507L, L, 5603L, 5651L, 5699L, 5747L, 5795L, 5843L, 5891L, 5939L, 5987L, 6035L, 6083L, 6131L, 6179L, 6227L, 6275L, 6323L, 6371L, 6419L, 6467L, 6515L, 6563L, 6611L, 6659L, 6707L, 6755L, 6803L, 6851L, 6899L, 6947L, 6995L, 7043L, 7091L, 7139L, 7187L, 7235L, 7283L, 7331L, 7379L, 7427L, 7475L, 7523L, 7571L, 7619L, 7667L, 7715L, 7763L, 7811L, 7859L, 7907L, 7955L, 8003L, 8051L, 8099L, 8147L, 8195L, 8243L, 8291L, 8339L, 8387L, 8435L, 8483L, 8531L, 8579L, 8627L, 8675L, 8723L, 8771L, 8819L, 8867L, 8915L, 8963L, 9011L, 9059L, 9107L, 9155L, 9203L, 9251L, 9299L, 9347L, 9395L, 9443L, 9491L, 9539L, 9587L, 9635L, 9683L, 9731L, 9779L, 9827L, 9875L, 9923L, 9971L, 10019L, 10067L, 10115L, 10163L, 10211L, 10259L, 10307L, 10355L, 10403L, 10451L, 10499L, 10547L, 10595L, 10643L, 10691L, 10739L, 10787L, 10835L, 10883L, 10931L, 10979L, 11027L, 11075L, 11123L, 11171L, 11219L, 11267L, 11315L, 11363L, 11411L, 11459L, 11507L, 11555L, 11603L, 11651L, 11699L, 11747L, 11795L, 11843L, 11891L, 11939L, 11987L, 12035L, 12083L, 12131L, 12179L, 12227L, 12275L)) -- --- José M. Blanco-Moreno Dept. de Biologia Vegetal (Botà nica) Facultat de Biologia Universitat de Barcelona Av. Diagonal 643 08028 Barcelona SPAIN --- phone: (+34) 934 039 863 fax: (+34) 934 112 842 --- The best argument against democracy is a five-minute conversation with the average voter. -Winston Churchill, statesman, military and author (1874-1965) Aquest correu electrònic i els annexos poden contenir informació confidencial o protegida legalment i està adreçat exclusivament a la persona o entitat destinatà ria. Si no sou el destinatari final o la persona encarregada de rebreâl, no esteu autoritzat a llegir-lo, retenir-lo, modificar-lo, distribuir-lo, copiar-lo ni a revelar-ne el contingut. Si heu rebut aquest correu electrònic per error, us preguem que nâinformeu al remitent i que elimineu del sistema el missatge i el material annex que pugui contenir. Grà cies per la vostra col·laboració. Este correo electrónico y sus anexos pueden contener información confidencial o legalmente protegida y está exclusivamente dirigido a la persona o entidad destinataria. Si usted no es el destinatario final o la persona encargada de recibirlo, no está autorizado a leerlo, retenerlo, modificarlo, distribuirlo, copiarlo ni a revelar su contenido. Si ha recibido este mensaje electrónico por error, le rogamos que informe al remitente y elimine del sistema el mensaje y el material anexo que pueda contener. Gracias por su colaboración. This email message and any documents attached to it may contain confidential or legally protected material and are intended solely for the use of the individual or organization to whom they are addressed. We remind you that if you are not the intended recipient of this email message or the person responsible for processing it, then you are not authorized to read, save, modify, send, copy or disclose any of its contents. If you have received this email message by mistake, we kindly ask you to inform the sender of this and to eliminate both the message and any attachments it carries from your account. Thank you for your collaboration. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch
Re: [R] changing cex pointwise in lattice
Sorry about that, when I asked before I meant that I had tried your proposed syntax. That has a problem, and it is that it uses the same set of values for the character expansion *for both groups*, and it is not what I wanted to do. If you plot the data (now a reduced set! sorry!) you'll see that both plots are exactly the same: I have data on the same positions, but the values that I want to represent with cex are different for each group. The intention is to take advantage of the fact that (I think that) lattice will use the same scaling on both plots. I think I have found it... # This is just to make sure that a group has a value of 1 and the other of 2 dd$z - (1:50)%%2 + 1 xyplot(y~x|group, panel=function(x,y,subscripts){panel.xyplot(x,y, cex=dd$z[subscripts])}, data=dd) Cheers, José M. Blanco El 20/07/2012 21:34, Peter Ehlers escribió: Sorry, I had meant to include the following line: Try: xyplot(y~x|group,cex=dd$z,data=dd) Peter Ehlers structure(list(y = c(3L, 3L, 3L, 3L, 9L, 9L, 9L, 9L, 38L, 38L, 38L, 38L, 44L, 44L, 44L, 44L, 38L, 38L, 38L, 38L, 44L, 44L, 44L, 44L, 38L, 38L, 38L, 38L, 44L, 44L, 44L, 44L, 54L, 54L, 54L, 54L, 60L, 60L, 60L, 60L, 54L, 54L, 54L, 54L, 60L, 60L, 60L, 60L, 54L, 54L), x = c(3.25, 3.25, 9.75, 9.75, 3.25, 3.25, 9.75, 9.75, 16.25, 16.25, 22.75, 22.75, 16.25, 16.25, 22.75, 22.75, 29.25, 29.25, 35.75, 35.75, 29.25, 29.25, 35.75, 35.75, 42.25, 42.25, 48.75, 48.75, 42.25, 42.25, 48.75, 48.75, 3.25, 3.25, 9.75, 9.75, 3.25, 3.25, 9.75, 9.75, 16.25, 16.25, 22.75, 22.75, 16.25, 16.25, 22.75, 22.75, 29.25, 29.25), group = structure(c(2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c(B, A), class = factor), z = c(2, 0, 8, 3, 3, 4, 5, 4, 14, 11, 4, 2, 37, 7, 6, 5, 4, 3, 14, 5, 9, 3, 3, 1, 9, 4, 9, 7, 4, 2, 9, 1, 9, 2, 9, 1, 5, 2, 10, 1, 13, 5, 14, 4, 21, 6, 16, 3, 0, 1)), .Names = c(y, x, group, z), row.names = c(NA, 50L ), class = data.frame) -- --- José M. Blanco-Moreno Dept. de Biologia Vegetal (Botànica) Facultat de Biologia Universitat de Barcelona Av. Diagonal 643 08028 Barcelona SPAIN --- phone: (+34) 934 039 863 fax: (+34) 934 112 842 --- The best argument against democracy is a five-minute conversation with the average voter. -Winston Churchill, statesman, military and author (1874-1965) Aquest correu electrònic i els annexos poden contenir informació confidencial o protegida legalment i està adreçat exclusivament a la persona o entitat destinatària. Si no sou el destinatari final o la persona encarregada de rebre’l, no esteu autoritzat a llegir-lo, retenir-lo, modificar-lo, distribuir-lo, copiar-lo ni a revelar-ne el contingut. Si heu rebut aquest correu electrònic per error, us preguem que n’informeu al remitent i que elimineu del sistema el missatge i el material annex que pugui contenir. Gràcies per la vostra col·laboració. Este correo electrónico y sus anexos pueden contener información confidencial o legalmente protegida y está exclusivamente dirigido a la persona o entidad destinataria. Si usted no es el destinatario final o la persona encargada de recibirlo, no está autorizado a leerlo, retenerlo, modificarlo, distribuirlo, copiarlo ni a revelar su contenido. Si ha recibido este mensaje electrónico por error, le rogamos que informe al remitente y elimine del sistema el mensaje y el material anexo que pueda contener. Gracias por su colaboración. This email message and any documents attached to it may contain confidential or legally protected material and are intended solely for the use of the individual or organization to whom they are addressed. We remind you that if you are not the intended recipient of this email message or the person responsible for processing it, then you are not authorized to read, save, modify, send, copy or disclose any of its contents. If you have received this email message by mistake, we kindly ask you to inform the sender of this and to eliminate both the message and any attachments it carries from your account. Thank you for your collaboration. __ 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] writing spdiags function for R
Hi Ben, A couple of quick comments: the semicolons at the end of each line are unnecessary (they're harmless, but considered bad style -- most common in code of C and MATLAB coders yes, I know, just forgot to clean it up after translating :) You don't need to source(getband.R) inside the body of spdiags, probably better to do it outside (so it doesn't get run every time the function is called) if (length(which(bd) == T) != 0) can be shortened to if (any(bd!=0)) I haven't looked too carefully but can't all the i/j/d/p stuff be replaced by n - nrow(A) p - 2*n-1 d - seq(-(n-1),(n-1)) yes, all good points, I have acted the changes you suggested, and it works smooth. thanks, Moreno -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] writing spdiags function for R
Hi Ben, thank you soo much:) your code worked, and we managed to halven computing time. I am copying below the final version of the function, if anybody is willing to use/improve it. thanks again, Moreno ### spdiags = function(A){ require(Matrix) source(getband.R) # Find all nonzero diagonals i = rep(seq(1, nrow(A),1),nrow(A)); j = sort(i); d = sort(j-i); d = unique(d); p = length(d); ##the nr. col of the new matrix m = nrow(A); n = ncol(A); B = Matrix(FALSE, nrow = min(c(m,n)), ncol = p, sparse = TRUE); count = 0 for (k in 1:p){ if (m = n){ i = max(1, 1+d[k]):min(n, m+d[k]); } else { i = max(1, 1-d[k]):min(m,n-d[k]); } if (length(i) != 0){ bd = getband(A, d[k]); if (length(which(bd) == T) != 0){ count = count + 1; # print( paste( non-zero diagonal, count) ) B[i,count] = bd } else { # print (paste (ncol, ncol(B), diag, k ) ) B = B[, -ncol(B)] } } } return (list( B = B, d = d) ) } Quoting Ben Bolker bbol...@gmail.com on Fri, 13 Apr 2012 20:09:52 +: Ben Bolker bbolker at gmail.com writes: I'm not quite sure how to do it, but I think you should look at the ?band function in Matrix. In combination with diag() of a suitably truncated matrix, you should be able to extract bands of sparse matrices efficiently ... getband - function(A,k) { n - nrow(A) if (abs(k)(n-1)) stop(bad band requested) if (k0) { v - seq(n-k) ## -seq((n-k+1),n) w - seq(k+1,n) ## -seq(n-k-1) } else if (k0) { v - seq(-k+1,n) w - seq(n+k) } else return(diag(A)) diag(band(A,k,k)[v,w,drop=FALSE]) } PS: I think this should extract the k^th off-diagonal band in a way that should (?) work reasonably efficiently with sparse matrices. I have not tested it carefully, nor benchmarked it. Ben Bolker __ 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. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] writing spdiags function for R
Dear R-list, I am in the process of translating a long function written in Matlab into R (mainly because I am a big of fan of R, and folks will not have to pay to use it :). In the translation of this function I got stack because they use spdiags, which, as far as I can tell it is not available in R. I have explored the Matrix package, from which I borrowed some of the functions (e.g., sparseMatrix), but I could not actually find an equivalent to spdiags (please, let me know if it is there somewhere). So, I have written my own spdiags function (below); following also a suggestion in an old, and perhaps unique post, about this issue. It works only for square matrices (that's my need), however I have a couple of issues, mainly related to computational efficiency: 1) if I use it with a sparseMatrix, it throws a tedious warning sparse[ logic ] : .M.sub.i.logical() maybe inefficient; can I suppress this warning somehow, this is slowing the computation very radically; 2) I can go around this problem by translating a sparseMatrix back into a logical matrix before I run spdiags on it. However, the loop gets very slow for large matrices (e.g., 2000x2000), which is the kind of matrices I have to handle. If you look in the code, I have placed a system.time() where the code is slowing down, and it takes about: user system elapsed 0.280.050.33 to complete an iteration...thus, I was wondering whether there is a more efficient way to do what I am doing...also, if you spot other places where the function could be optimized I would be very glad to hear it! thank you very much in advance for your kind help, Best, Moreno ### ## it works only for square matrices ## it could work with sparse matrices but it spits a tedious warning ## it is definitely inefficient compared to the original matlab code ## choose below different matrices to test the function. # r = c(2,3,5,5); c = c(2,1,4,5) # A = sparseMatrix(r, c) # A = replicate(1000, rnorm(1000) ) # A = rbind(c(1,2,3),c(2,3,4),c(3,4,5)) spdiags = function(A){ # Find all nonzero diagonals i = rep(seq(1, nrow(A),1),nrow(A)); j = sort(i); d = sort(j-i); # d = d(find(diff([-inf; d]))); ## from Matlab ... # d = c(d[which(diff(d) == 1)], d[length(d)] ) ## this emulate above but needs to stick in last element d = unique(d); ##this should work just fine and it is simpler p = length(d); ##the nr. col of the new matrix m = nrow(A); n = ncol(A); B = matrix(0, nrow = min(c(m,n)), ncol = p); for (k in 1:p){ # print(k) cl = vector(); if (m = n){ i = max(1, 1+d[k]):min(n, m+d[k]); } else { i = max(1, 1-d[k]):min(m,n-d[k]); } system.time( if (length(i) != 0){ B[i,k] = A[ col(A) == row (A) - d[k]] } ) } return (list( B = B, d = d) ) } -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] XML package: modify info of internal node
Dear All, I have a very simple question to which I did not find any answer online (apologize if it exists). I have an XML file (attached) on which I just want to modify the info of a node. So, I load my xml file: current = xmlTreeParse(file, useInternalNodes=T) and I want to change the information of: filename1.jpg/filename to be, for example: 1-1.jpg (newname) I do: xmlValue( xpathApply( current, /annotation/filename)[[1]] ) = newname now, the crazy thing is that it does the change to the xml but it also through the following error: Error in xmlValue(xpathApply(current, /annotation/filename)[[1]]) = newname : could not find function xpathApply- it seems that it works, but for a mysterious reason, it also seems that it does not work. Since I have to apply this change many times, and write the resulting modified .xmls, the loop would stop as a result of the error... what am i missing here? is there any simpler way to do it? thanks a lot for your kind help, Moreno P.S. I also try: xmlSApply(xpathApply( current, /annotation/filename)[[1]], xmlValue) = newname obtaining the same result. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] modulo operation
Dear R-users, May be there is something that I am not understanding, missed or else... Why do these operations yield these results? 25%/%0.2 [1] 124 25%%0.2 [1] 0.2 I would expect (although I know that what I do expect and what is really intended in the code may be different things) 25/0.2 [1] 125 25 - floor(25/0.25)*0.25 [1] 0 (At least this second one is what I would expect from the code in arithmetic.c, lines 168 to 178) -- --- José M. Blanco-Moreno Dept. de Biologia Vegetal (Botànica) Facultat de Biologia Universitat de Barcelona Av. Diagonal 645 08028 Barcelona SPAIN --- phone: (+34) 934 039 863 fax: (+34) 934 112 842 __ 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] modulo operation
Did you read the documentation before you read the code? ‘%%’ and ‘x %/% y’ can be used for non-integer ‘y’, e.g. ‘1 %/% 0.2’, but the results are subject to rounding error and so may be platform-dependent. Because the IEC 60059 representation of ‘0.2’ is a binary fraction slightly larger than ‘0.2’, the answer to ‘1 %/% 0.2’ should be ‘4’ but most platforms give ‘5’. I suspect that is relevant to your interests Yes. I think José is assuming that 25 %/% 0.2 and floor(25/0.2) are equal, but they are not, because rounding affects them differently. (The first is a single operation with no rounding except in the representation of 0.2; the second is two operations and is subject to another set of rounding.) Duncan Murdoch Thank you (both) very much for the info. Indeed I wasn't aware of that piece of documentation and of the implications of rounding. Excuse me for my hasty question when facing this behaviour. -- --- José M. Blanco-Moreno Dept. de Biologia Vegetal (Botànica) Facultat de Biologia Universitat de Barcelona Av. Diagonal 645 08028 Barcelona SPAIN --- phone: (+34) 934 039 863 fax: (+34) 934 112 842 __ 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] Neyman-Scott in 1-dimension?
Dear R-Users, I would like to use the spatstat package in R for simulation and analysis of point processes in 1d = 1 dimension, i.e. on the line. I tried to use the owin class to obtain a 1-dimensional window, e.g. [1,..L], but it doesn't work. Does anyone know if the spatstat package can deal with linear point processes? If yes, how? Thank you very much for your help, Moreno -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] updating specific arguments of formula
-- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] updating specific arguments of formula
-- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] updating specific arguments of formula
-- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] updating arguments of formulae
Dear R-Community, I am relatively new with R, so sorry for things which for you might be obvious... I am trying to automatically update lmer formulae. the variables of the model are: depM= my dependent measure Sb2= a random factor OS = a predictor VR= another predictor So, I am building the first model with random intercept only: model = lmer(depM ~ (1 |Sb2)) then I update the formula adding the first predictor model1 = update(model, as.formula(paste(. ~ . + , OS))) the resulting formula will be: depM ~ (1 |Sb2) + OS let suppose now I want to update the model to have OS both as a fixed effect and in the random term, something like: depM ~ (1 + OS |Sb2) + OS I can do something very ugly (please tell me if there is a more elegant way to do it) that looks like: model2 = update(model1, as.formula(paste(paste(paste(paste(. ~ . + (1 + , OS), | ), Sb2), the resulting model2 formula will be: depM ~ (1 |Sb2) + OS + (1 + OS | Sb2) one first thing I am wondering at this point is whether having (1 |Sb2) and (1 + OS | Sb2) in the same expression is redundant. in the output it will obviously tell me that group Sb2 is considered twice: number of obs: 6514, groups: Sb2, 23; Sb2, 23 and i am not sure if am doing it correctly...any advice? So let suppose now I want to add the new predictor VR again both in the fixed and in the random part of the formula. If i just repeat the two steps above: model3 = update(model2, as.formula(paste(. ~ . + , VR))) and then: model4 = update(model3, as.formula(paste(paste(paste(paste(. ~ . + (1 + , VR), | ), Sb2), the formula I get is: depM ~ (1 |Sb2) + OS + (1 + OS | Sb2) + VR + (1 + VR | Sb2) so, basically I am adding new stuff on the right side of the formula... My first question at this point is whether the above formula is equivalent to: depM ~ OS + VR + (1 + OS + VR | Sb2) if is not equivalent, which one of the two is correct? obviously in the second case, group Sb2, is considered only once. If the second version of the formula is the correct one, I don't understand how I can update arguments inside the formula rather than adding things on his right side... thus, in the ideal case, how do I go from something like this: depM ~ OS + (1 + OS | Sb2) to something like this: depM ~ OS + VR + (1 + OS + VR | Sb2) Thanks a lot for your help, Best, Moreno -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] updating arguments of formulae
Michael, Thanks a lot for your reply, I have now understood how to fiddle around with the formulae updates...my question (see my previous e-mail where I was sketching this problem out) about LME models remains open... whether: depM ~ (1 |Sb2) + OS + (1 + OS | Sb2) + VR + (1 + VR | Sb2) is equivalent to: depM ~ OS + VR + (1 + OS + VR | Sb2) and if probably not what is the best approach to it and where I can find a kind of guideline/rule of thumb list to build semi-automatically linear mixed effect models with fixed effects and random intercepts/slopes on it. I am putting in copy the group you suggested me... Thanks again, Moreno Quoting Meyners,Michael,LAUSANNE,AppliedMathematics michael.meyn...@rdls.nestle.com: Moreno, I leave the discussion on the mixed models to others (you might consider the SIG group on mixed models as well for this), but try a few hints to make your code more accessible: * The . in updating a formula is substituted with the respective old formula (depending on the side), but is not mandatory. You could give the new formula explicitly, i.e. consider something like model1 = update(model, . ~ (1 |Sb2) + OS) if you loose control about your models. See ?update.formula * I don't see the need for using your construct with as.formula(paste()), this makes things unnecessarily complicated. See my above example, which should work as well on your data (and see ?update) * There is also the - operator available in update.formula to remove terms (because it uses formula, see ?formula). As to your question on how to move from depM ~ OS + (1 + OS | Sb2) to depM ~ OS + VR + (1 + OS + VR | Sb2) try something like update(model1, .~. - (1 + OS|Sb2) + VR + (1 + OS + VR | Sb2)) while it goes without saying that in this case, it would be easier to drop the . and use something like update(model1, .~ OS + VR + (1 + OS + VR | Sb2)) directly. * paste accepts more than just two arguments to be pasted: Try somthing like model2 = update(model1, as.formula(paste(. ~ . + (1 + , OS, | , Sb2, ))) instead of your construct with several nested calls to paste, and see ?paste. (Note that I added quotes to OS and Sb2, it didn't work for me otherwise as I have no object OS, not sure what happens if you have such an object on our search path, but I would suspect you encounter problems as well.) If you work yourself through these and thereby simplify your code, you are more likely to get responses to your questions on which model to use (which is actually independent from the use of update). As far as I see it, it doesn't make sense to use a formula like in your model4, but the mixed model experts might tell me wrong (and I got a bit lost in your code as well). Please also try to provide commented, minimal, self-contained, reproducible code for further enquiries (use e.g. one of the examples on ?lmer to create appropriate examples for your questions). HTH, Michael -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Moreno Ignazio Coco Sent: Donnerstag, 10. Dezember 2009 13:35 To: R-help@r-project.org Subject: [R] updating arguments of formulae Dear R-Community, I am relatively new with R, so sorry for things which for you might be obvious... I am trying to automatically update lmer formulae. the variables of the model are: depM= my dependent measure Sb2= a random factor OS = a predictor VR= another predictor So, I am building the first model with random intercept only: model = lmer(depM ~ (1 |Sb2)) then I update the formula adding the first predictor model1 = update(model, as.formula(paste(. ~ . + , OS))) the resulting formula will be: depM ~ (1 |Sb2) + OS let suppose now I want to update the model to have OS both as a fixed effect and in the random term, something like: depM ~ (1 + OS |Sb2) + OS I can do something very ugly (please tell me if there is a more elegant way to do it) that looks like: model2 = update(model1, as.formula(paste(paste(paste(paste(. ~ . + (1 + , OS), | ), Sb2), the resulting model2 formula will be: depM ~ (1 |Sb2) + OS + (1 + OS | Sb2) one first thing I am wondering at this point is whether having (1 |Sb2) and (1 + OS | Sb2) in the same expression is redundant. in the output it will obviously tell me that group Sb2 is considered twice: number of obs: 6514, groups: Sb2, 23; Sb2, 23 and i am not sure if am doing it correctly...any advice? So let suppose now I want to add the new predictor VR again both in the fixed and in the random part of the formula. If i just repeat the two steps above: model3 = update(model2, as.formula(paste(. ~ . + , VR))) and then: model4 = update(model3, as.formula(paste(paste(paste(paste(. ~ . + (1 + , VR), | ), Sb2), the formula I get is: depM ~ (1 |Sb2) + OS + (1 + OS | Sb2) + VR + (1 + VR | Sb2) so, basically I am adding new stuff on the right side of the formula... My first question at this point is whether the above formula
Re: [R] Combine vectors in order to form matrixes with combn
Moreno, I don't understand exactly what it is you are trying to do. Can you explain what you want your matrices to look like? Perhaps give an example. Bryan Dear Bryan, let's try with an example: i have 8 column vectors v1-matrix(c(2,5,6,8)) v2-matrix(c(3,7,9,11)) v3-matrix(c(13,4,2,7)) v4-matrix(c(3.4,6,11,21)) v5-matrix(c (1,9,45,3)) v6-matrix(c(2,76,4,2)) v7-matrix(c(34,7,8,1)) v8-matrix(c (2,6,1,9)) I would like to form a combination of theese vectors in order to obtain a set of matrixes in the form k-combinations from a set of n elements, when the set is the number of vectors (in this case 8) and k is the number of columns (in this case 4): in this example, i would like to obtain matrix_1 [,1] [,2] [,3] [,4] [1,]23 13 3.4 [2,]574 6.0 [3,]692 11.0 [4,]8 117 21.0 matrix_2 [,1] [,2] [,3] [,4] [1,]23 131 [2,]5749 [3,]692 45 [4,]8 1173 matrix_3 [,1] [,2] [,3] [,4] [1,] 23 132 [2,]574 76 [3,]6924 [4,]8 1172 [...] matrix_n!/k!(n-k!) [,1] [,2] [, 3] [,4] [1,]12 342 [2,]9 7676 [3,] 45 481 [4,]3219 I hope I was more clear! However, thanks in advance, Moreno Tutto Incluso Light: chiami e navighi senza limiti a soli 9,95 euro al mese. Gratis la Sim Tiscali Mobile con 25 euro di traffico! ATTIVA ORA http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/tuttoincluso_light/ __ 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] saving large matrices with decimal numbers
Hi everybody, I am struggling to save txt. or csv. large sparse matrices (1024 X 768 image size), initialized at 0.1. image1[0:10,0:10] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [2,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [3,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [4,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [5,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [6,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [7,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [8,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [9,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [10,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 with small distributions located at different points of matrix. If I try the same matrix but initialized at 0, it can save it. It seems that R manages to save up around 800 X 600 decimal matrices but for bigger sizes the output is an empty file. Does anyone know whether there is a limit in saving such matrices and how can I work around this problem? Thanks a lot, Regards, Moreno -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] saving large matrices with decimal numbers
Please tell us what you did exactly when you got the empty file: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. well, that's exactly the point, I didn't do anything fancy or special, just save the matrix I gave you before (1024 X 768) either in format txt. write.table(image, ~/mydata/blablabla/data.txt, col.names=F, row.names=F) or csv: write.csv (image, ~/mydata/blablabla/data.csv) both cases the output is an empty file. Do you know what can be the problem? Thanks a lot, Moreno write.csv (image, /afs/inf.ed.ac.uk/user/s07/s0788806/R/r_data/ProdEyeTrack/DataFrame/Clustered/Clut/Cluster1/Cl1Verb-tr.csv.1) Quoting Uwe Ligges lig...@statistik.tu-dortmund.de: Moreno Ignazio Coco wrote: Hi everybody, I am struggling to save txt. or csv. large sparse matrices (1024 X 768 image size), initialized at 0.1. image1[0:10,0:10] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [2,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [3,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [4,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [5,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [6,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [7,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [8,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [9,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [10,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 with small distributions located at different points of matrix. If I try the same matrix but initialized at 0, it can save it. It seems that R manages to save up around 800 X 600 decimal matrices but for bigger sizes the output is an empty file. Does anyone know whether there is a limit in saving such matrices and how can I work around this problem? Please tell us what you did exactly when you got the empty file: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Best wishes, Uwe Ligges Thanks a lot, Regards, Moreno -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] Solutions of equation systems
Ravi Varadhan wrote: [cut] It seems to work! Thanks a lot Ravi and Berend. Moreno. __ 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] Solutions of equation systems
Greg Snow wrote: ?solve Dear Greg, I tried to use function solve, but I have some problems with it. Let's try with a simple equation: x + 3y -2z = 5 3x + 5y + 6z =7 a-matrix(c(1,3,-2,3,5,6),nrow=2,ncol=3) a [,1] [,2] [,3] [1,]1 -25 [2,]336 b-matrix(c(5,7),nrow=2,ncol=1) b [,1] [1,]5 [2,]7 When I try to solve this system, I find this error: solve(a,b) Error in solve.default(a, b) : 'b' must be compatible with 'a' Also, when i try to solve a system with n equation and n variables, solve works perfectly. Thanks in advance! Moreno __ 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] Solutions of equation systems
Moshe Olshansky wrote: Is your system of equations linear? dear sir, Yes, the system is linear. It can have this form: a x + b y + c z = d e x + f y + g z = h But it can be more complex. I would like to calculate in R the solutions under the form of equation of x,y and z. Any idea? Thanks in advance, Moreno __ 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] Solutions of equation systems
Hello all! Maybe it's a newbie question(in fact I _am_, a newbie), but I hope you'll find the solution. I have an equation system which has k equation and n variables (kn). I would like to obtain a description of the solutions (which can be the equation of lines or a plane, or everything else) with the lesser degree of freedom, obviously using R. In other words, I would like to obtain a result which is very similar to the results of Maxima or similar software. I tried to search on internet and i found the systemfit package, but I think it is not related with my problem. Any idea? Thanks in advance, Moreno __ 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] [R-sig-Geo] error in trmesh (alphahull package)
Hello, The problem is that your first three points CANNOT be collinear. This is a feature of trmesh in tripack. So: either you unsort your data (keeping the indices you can sort them again) or alter (e.g. jitter) the coordinates very slightly. Either solution will do the work. Cheers, José M. Blanco Murray Richardson escribió: Hello R community, I have cross-posted with r-sig-geo as this issue could fall under either interest group I believe. I just came accross the alphahull package and am very pleased I may not need to use CGAL anymore for this purpose. However, I am having a problem computing alpha shapes with my point data, and it seems to have to do with the spatial configuration of my points (which form long, skinny, contiguous clusters). If I use rnorm to generate the same sample size with the same mean and SD, I can compute the alpha shape without trouble (which is why I think it might have to do with the spatial arrangement of my points). See below: # first here's a quick sample of my data (UTM coordinates) xcoords[1:5] [1] 670080.2 670080.2 670080.2 670080.2 670080.2 ycoords[1:5] [1] 5005501 5005499 5005498 5005497 5005495 xcoords[1:5] #try the ashape routine with error alpha.shape-ashape(xcoords,ycoords,15) Error in tri.mesh(X) : error in trmesh #get statistics to generate a similar dataset to test against length(xcoords) [1] 26257 length(ycoords) [1] 26257 mean(xcoords) [1] 670462.4 mean(ycoords) [1] 5005382 sd(xcoords) [1] 149.3114 sd(ycoords) [1] 181.5950 #generate the test data xtest-rnorm(26257,670462.4,149.3) ytest-rnorm(26257,5005382,181.60) # try ashape routine with success alpha.shape-ashape(xtest,ytest,15) class(alpha.shape) [1] ashape Thanks for any insight into this! Murray ps I am able to compute the alpha shapes for this same dataset without problem using CGAL but I find it a pain to work with ___ R-sig-Geo mailing list r-sig-...@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- --- José M. Blanco Moreno Dept. de Biologia Vegetal (Botànica) Universitat de Barcelona Av. Diagonal 645 08028 Barcelona SPAIN --- phone: (+34) 934 039 863 fax: (+34) 934 112 842 e-mail: jmbla...@ub.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] heatmap-changing column or row names
Hi Kevin, thanks a lot for the advices. The first suggestion worked, overall, I have to find a way to scale the names/numbers on the interval considered. But it was the good way to look at the problem. The second suggestion didn't really work. It is not a problem of custom fitting, it is more where in the plot, zero is centered. If I say abline(v=0) it produces a vertical line much more right on the x axis than the actual 0. It is a problem of where the axis of the plots are set and they don't seem to match the layout of the heatmap. Any suggestion on this? Moreno Quoting Kevin J. Thompson [EMAIL PROTECTED]: would this work for you? cl2=c(rep('',4500)) for (i in seq(500,4500,by=500)){ + cl2[i]=as.character(i)} heatmap(x, labCol=cl2) you might have to custom fit the lines d=seq(.2,.8,by=.1) abline(v=d) hope it helps, kt - Original Message - From: Moreno Ignazio Coco [EMAIL PROTECTED] Date: Wednesday, May 28, 2008 12:55 pm Subject: [R] heatmap-changing column or row names Dear R Community, I am trying to create an heatmap for the following set of data: ##example of data matrix o4 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 green 27 28 29 29 28 28 26 25 25 23 23 22 22 21 21 22 22 22 yellow 6 8 8 7 7 7 6 6 6 7 7 7 6 6 6 6 6 5 red15 15 15 15 15 15 14 13 12 11 12 10 9 8 7 6 8 9 pink 11 11 11 11 11 10 12 11 13 14 14 15 15 14 14 17 17 17 blue 17 15 15 16 17 17 17 17 18 18 18 19 20 20 20 21 22 21 the column names are timepoints 450 in total. When I run the heatmap code: x - as.matrix(o4) ramp - colorRamp(c(yellow,green,blue)) cv-rgb( ramp(seq(0, 1, length = 83)), max = 255) heatmap(x, col = cv, Colv=NA, Rowv=NA,xaxt=n, yaxt=n, scale=column, margins=c(5,10), labCol=NA,xlab = Time, ylab= Colors,main = ) I have quite few problems to change the column names. Being 450 timepoints too many to be readable on the plot, I wanted to reduce/scale them to, let say 45. So, as you can see from the code above, I have removed the x and y, row and column information. Then I have tried to create a new name vector: ##create col vector to add names Colname-as.character(seq(0,4500,500)) ##putting it as arguments of (labCol=Colname, in the heatmap function) but this solution didn't work. It looks like as it cannot find the exact point on the axis where to stick the label in and it clutters all the datapoint on the same spot without being able to unfold it. Therefore I have tried to introduce an axis: axis(1, at=seq(0,450,1),line=1) and then adding some text on top mtext(paste(seq(0,4500, 250),sep=),side=1, at=seq(0,450,25),line=2,cex=0.6,las=1) also this way didn't work out. Actually, it has created a kind of axis but the zero of it was aligned to the middle of the plot. So, it was completely shifted. That was my first problem. Second small problem. I am trying to mark on the heatmap some crucial timepoints. I wanted to do it by adding a straight abline on the heatmap plot abline(v=80,col=green) but also this doesn't seem to have any result It seems that it is quite difficult to add any information to the heatmap, but perhaps some of you might know how to do it. Many thanks in advance Moreno -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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.htmland provide commented, minimal, self-contained, reproducible code. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] 3dscatterplot -different colors for different factors of the same variable
Dear R users, I was trying to do a 3d scatterplot for the following set of datas: obj time X Y 1 yellow 333 388.7 492.3 2 yellow 567 388.7 492.3 3 green 621 135.5 371.7 4 green 1039 135.5 371.7 5 red 1373 744.1 205.0 6 red 1763 744.1 205.0 The points should be drew in the plot taking information of time, X and Y. The colors of these points should be assigned according to the information contained in variable obj. What I did but it didn't work out is: 1) Plotting only one set of points (the green one) s3d-scatterplot3d(greenpts[,3],greenpts[,2],greenpts[,4],type=p,scale.y=4, angle=10, color=green) and try to overlay the others (as you normally would do with plot): s3d$points3d(redpts[,3],redpts[,2],redpts[,4],col=red,type=o) s3d$points3d(yellowpts[,3],yellowpts[,2],yellowpts[,4], col=yellow,type=o) s3d$points3d(bluepts[,3],bluepts[,2],bluepts[,4],col=blue,type=o) s3d$points3d(pinkpts[,3],pinkpts[,2],pinkpts[,4],col=pink,type=o) R has plotted only the first set and wasn't able to overlay other points. 2) I have generated a for loop that should have taken points information ,arranged into a list object, plotting them one by one. - listpoints = list(X,Y,time) -color-rep(black,26) ##solution found in one of the discussion around scatterplot color[mat1$obj==green]-green color[mat1$obj==yellow]-yellow color[mat1$obj==red]-red color[mat1$obj==pink]-pink color[mat1$obj==blue]-blue for (i in 1:26) points3d(listpoints[i],type=1, col=color[i]) Also this way didn't work out. Do you have any solution? Many thanks Moreno P.S. I have tried also points3d(rgl) trying to follow an explanation given in the forum but i haven't understood how to set the function. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] install problem 2.6 mac os x 10.5
I am having the very SAME problem. I removed Version 2.5.1 before trying to install 2.6.0. Please help. TIA, Oscar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] standard errors of regression coefficients
Hi, If I have two vectors x and y and I do lm(y~x) and now I want to define variables that are the standard errors of the slope and intercept, how do I do that? Thanks, Alex [[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.