Re: [R] error when trying to install {rgdal} on Windows
[I have fixed your subject: "text" is really on of the most unuseful subjects we've ever seen on this list ... ] > Farzad Ghooshi on Sun, 28 Apr 2024 12:17:34 +0330 writes: > Hi dear friend I use rgdal package for shape files. > When installing the package, it gives me the following > error, a picture of the error is attached. What command > should I run to fix this error? Did you install the Rtools, in your case Rtools43 (If you'd use a current version of R, R 4.4.0 you'd needed Rtools44 to install packages from source on Windows. Note that we *DO NOT WANT* screen shot images, but rather simple cut'n'paste plain text in this mailing list. Best regards, Martin __ 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
В Fri, 22 Mar 2024 14:52:05 -0500 Val пишет: > : 8d5a 35f8 1ac5 cc14 a04e be5c 572f a3ad .Z5..N.\W/.. > 0010: 6210 7024 9b58 93c7 34d0 acb7 7a82 3f99 b.p$.X..4...z.?. Thank you! This doesn't look like any structured data to me. In particular, it doesn't look like something written by R: those created by modern versions of R with default settings typically start with an "RDX2\n" (52 44 58 32 0a) or at least "X\n" (58 0a). Could be a middle of compressed stream, as if the file was truncated while it was being written. Do you get similar results with saveRDS(datafilename, 'X1.rds') and data2 <- readRDS('X1.rds')? Does this happen with other R objects that you try to save or in your other scripts? -- Best regards, Ivan __ 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
Here is the first few bytes, xxd -l 128 X1.RData : 8d5a 35f8 1ac5 cc14 a04e be5c 572f a3ad .Z5..N.\W/.. 0010: 6210 7024 9b58 93c7 34d0 acb7 7a82 3f99 b.p$.X..4...z.?. 0020: 66ce 0ebb 2057 ec36 55b4 0ece a036 695a f... W.6U6iZ 0030: 258b 3493 b661 f620 f7fe ada7 158a 15f7 %.4..a. 0040: e016 a548 6fcb 20c8 6fb4 493d adc9 ea4a ...Ho. .o.I=...J 0050: 0a2b b7cf a416 336e 5e4e abc5 9874 7be3 .+3n^N...t{. 0060: 5a5a 3405 fe35 8a3d ad80 0dc0 ca3e ea7a ZZ4..5.=.>.z 0070: e628 b220 ee50 0b9f 3a81 e971 8a19 4f54 .(. .P..:..q..OT On Fri, Mar 22, 2024 at 2:36 PM Ivan Krylov wrote: > > В Fri, 22 Mar 2024 14:31:17 -0500 > Val пишет: > > > How do I get the first few bytes? > > What does file.info('X1.RData') say? > > Do you get any output if you run print(readBin('X1.RData', raw(), 128))? > > If this is happening on a Linux or macOS machine, the operating system > command xxd -l 128 X1.RData will give the same output in a more > readable manner, but the readBin(...) output from R should be fine too. > > -- > Best regards, > Ivan __ 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
В Fri, 22 Mar 2024 14:31:17 -0500 Val пишет: > How do I get the first few bytes? What does file.info('X1.RData') say? Do you get any output if you run print(readBin('X1.RData', raw(), 128))? If this is happening on a Linux or macOS machine, the operating system command xxd -l 128 X1.RData will give the same output in a more readable manner, but the readBin(...) output from R should be fine too. -- Best regards, Ivan __ 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
Yes, X1.RData is large(more than 40M rows) . How do I get the first few bytes? On Fri, Mar 22, 2024 at 2:20 PM Ivan Krylov wrote: > > В Fri, 22 Mar 2024 14:02:09 -0500 > Val пишет: > > > X2.R > > load("X1.RData") > > > > I am getting this error message: > > Error in load("X1.RData", : > > bad restore file magic number (file may be corrupted) .. no data > > loaded. > > This error happens very early when R tries to load the file, right > at the first few bytes. Is "X1.RData" large? Can you share it, or at > least a hexadecimal dump of the first few hundred bytes? > > -- > Best regards, > Ivan __ 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
В Fri, 22 Mar 2024 14:02:09 -0500 Val пишет: > X2.R > load("X1.RData") > > I am getting this error message: > Error in load("X1.RData", : > bad restore file magic number (file may be corrupted) .. no data > loaded. This error happens very early when R tries to load the file, right at the first few bytes. Is "X1.RData" large? Can you share it, or at least a hexadecimal dump of the first few hundred bytes? -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error message
Hi all, I am creating an X1.RData file using the R 4.2.2 library. x1.R save(datafilename, file="X1.RData") When I am trying to load this file using another script X2.R load("X1.RData") I am getting this error message: Error in load("X1.RData", : bad restore file magic number (file may be corrupted) .. no data loaded. I am using the same R library (R 4.2.2) What would be the cause for this error message and how to fix it? 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.
Re: [R] Error while installing the R from CRAN website!
В Thu, 14 Dec 2023 22:30:17 +0530 siddharth sahasrabudhe via R-help пишет: > I have installed R on my machine. What operating system does your machine run? Was it the latest version of R that you installed? > After I open the R program I am getting the following message on the > console: > Error: evaluation nested too deeply: infinite recursion / > options(expressions=)? Can you run traceback() after you receive this message? What are the last few lines of the output? Do you have a file named .Rprofile or .RData in the home directory or the current directory? Try moving them away (or deleting them if you're sure they don't contain anything useful). See https://search.r-project.org/R/refmans/base/html/Startup.html for more information on things that may cause R to run code when you start it. -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error while installing the R from CRAN website!
Hello, I have installed R on my machine. After I open the R program I am getting the following message on the console: Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Can anyone please let me know what this message is? Is there any issue while installing R and how to get rid of this message? A same error message is also popping up in my RStudio workspace! Best, Siddharth -- Regards Siddharth Sahasrabudhe [[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 in setwd(dir) when initializing R
On Mon, 20 Nov 2023 12:18:11 +0100 Ana de las Heras Molina wrote: > Error in setwd(dir) : no es posible cambiar el directorio de trabajo If you run traceback() first thing after getting this error, does it say anything useful? (Anything besides "No traceback available" would count as useful.) Do you have a file named .RData in your home directory? If yes, it may help to move it away (or remove it if you don't use the saved session). -- Best regards, Ivan __ 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 setwd(dir) when initializing R
I think that you may be correct about OneDrive being related. I have seen OneDrive associated with problems before. What happens if you manually set the working directory to that location? Does it work if your default home directory is local to your machine? > On Nov 20, 2023, at 6:18 AM, Ana de las Heras Molina wrote: > > [You don't often get email from andel...@ucm.es. Learn why this is important > at https://aka.ms/LearnAboutSenderIdentification ] > > Hello, > I am Ana de las Heras, and I write to you because every time I open RStudio > or R directly I have the following message, before I can do anything at > all: > > Error in setwd(dir) : no es posible cambiar el directorio de trabajo > > > At first I didn't pay much attention to it, but I am having lots of > troubles with different programs, including LinDa, ANCOMBC or Genome > InfoDbdata (and thus, phyloseq). After asking in the different forus of > each program, they have told me that the issue is more related to my R > installation and that first message I obtain when I start the program. > > I would be very grateful if someone could help me. This issue started when > I installed the latest version of R (4.3.1. and now 4.3.2.). I have already > uninstalled and reinstalled both programs, as well as Rtools. I am not sure > if the issue could be related to ONe Drive, since the HOME folder is in > OneDrive. I am currently working on Windows 10, 64 bits. > > Yours faithfully, > Ana > -- > *Ana de las Heras Molina* > > > Nutrición Animal > Departamento de Producción Animal > Facultad de Veterinaria > Universidad Complutense de Madrid > > *Contacto*: 913943855/anaher...@ucm.es > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in setwd(dir) when initializing R
Hello, I am Ana de las Heras, and I write to you because every time I open RStudio or R directly I have the following message, before I can do anything at all: Error in setwd(dir) : no es posible cambiar el directorio de trabajo At first I didn't pay much attention to it, but I am having lots of troubles with different programs, including LinDa, ANCOMBC or Genome InfoDbdata (and thus, phyloseq). After asking in the different forus of each program, they have told me that the issue is more related to my R installation and that first message I obtain when I start the program. I would be very grateful if someone could help me. This issue started when I installed the latest version of R (4.3.1. and now 4.3.2.). I have already uninstalled and reinstalled both programs, as well as Rtools. I am not sure if the issue could be related to ONe Drive, since the HOME folder is in OneDrive. I am currently working on Windows 10, 64 bits. Yours faithfully, Ana -- *Ana de las Heras Molina* Nutrición Animal Departamento de Producción Animal Facultad de Veterinaria Universidad Complutense de Madrid *Contacto*: 913943855/anaher...@ucm.es [[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 running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run
Actually a better solution would be to make PID into a factor. They can always be coerced to a number, but will display with your meaningful labels. Duncan Murdoch On 25/10/2023 3:38 p.m., Duncan Murdoch wrote: I don't see it documented, but it appears that the gee() function assumes the id variable can be coerced to a number. Your ids are in PID, and are strings like "HIPS004", etc. Change that to "004" or a numeric 4 and the error goes away. Duncan Murdoch On 25/10/2023 3:23 p.m., Sorkin, John wrote: Colleagues, I am receiving several error messages from the gee function. I don't understand the ides the error messages are trying to impart, and I don't know how to debug or correct the error. The error messages follow: fitgee <- gee(HipFlex ~ StepHeight,data=datashort,id=PID,corstr="exchangeable",na.action=na.omit) Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27 running glm to get initial regression estimate (Intercept) StepHeight 1.400319 58.570236 Error in gee(HipFlex ~ StepHeight, data = datashort, id = PID, corstr = "exchangeable", : NA/NaN/Inf in foreign function call (arg 3) In addition: Warning message: In gee(HipFlex ~ StepHeight, data = datashort, id = PID, corstr = "exchangeable", : NAs introduced by coercion Of note, when the analysis is run using lm, there is no problem. My fully data and code follow: Thank you, John CODE: if (!require(gee)) {install.packages("gee")} library(gee) datashort <- structure(list(HipFlex = c(1.95, 2.07, 1.55, 0.44, 0.23, 0.41, 0.22, 4.61, 10.02, 1.08, 1.43, 1.82, 0.34, 0.77, 0.22, 1.06, 0.13, 0.36, 2.84, 5.2, 12.27, 1.37, 2.33, 3.48, 4.76, 1.92, 2.09, 4.67, 2.94, 0.75, 0.11, 3.56, 1.63, 0.8, 1.54, 5.06, NA,5.41, 6.18, 3.75, 3.12, 17.43, 3.18, 0.85, 14.54, 14.34, 21.92, 4.91, 1.52, 0.38, 0.43, 0.47, 0.56, 6.4, 12.4, 3.98, 0.57, 1.84, 12.06, 0.45, 8.16, 0.02, 0,0.05, 0.52, 0.11, 0.48, 1.5, 3.29, 2.58, 2.07, 6.06, 1.46, 1.06, 3.82, 1.09, 2.86, 3.47, 2.22, 1.89, NA, 3.48, 6.38, 3.58, 1.83, 2.8, 8.28, 7.15, 4.77, 4.93, 0, 0.11, 1.99, 2.01, 2.3, 1.24, 1.33, 2, 1.01), PID = c("HIPS004", "HIPS004", "HIPS005", "HIPS005", "HIPS005", "HIPS006", "HIPS006", "HIPS008", "HIPS010", "HIPS024", "HIPS024", "HIPS024", "HIPS025", "HIPS028", "HIPS028", "HIPS030", "HIPS030", "HIPS030", "HIPS035", "HIPS035", "HIPS035", "HIPS036", "HIPS036", "HIPS037", "HIPS044", "HIPS047", "HIPS047", "HIPS056", "HIPS056", "HIPS057", "HIPS057", "HIPS057", "HIPS058", "HIPS059", "HIPS059", "HIPS061", "HIPS062", "HIPS062", "HIPS062", "HIPS064", "HIPS074", "HIPS079", "HIPS084", "HIPS089", "HIPS090", "HIPS090", "HIPS090", "HIPS091", "HIPS091", "HIPS092", "HIPS092", "HIPS092", "HIPS001", "HIPS001", "HIPS001", "HIPS004", "HIPS004", "HIPS004", "HIPS005", "HIPS005", "HIPS005", "HIPS006", "HIPS006", "HIPS008", "HIPS022", "HIPS024", "HIPS028", "HIPS030", "HIPS035", "HIPS036", "HIPS036", "HIPS039", "HIPS044", "HIPS047", "HIPS051", "HIPS056", "HIPS058", "HIPS058", "HIPS059", "HIPS059", "HIPS062", "HIPS062", "HIPS062", "HIPS069", "HIPS069", "HIPS071", "HIPS074", "HIPS079", "HIPS084", "HIPS084", "HIPS085", "HIPS089", "HIPS090", "HIPS091", "HIPS091", "HIPS091", "HIPS092", "HIPS092", "HIPS093"), StepHeight = c(0.005, 0.008, 0.072, 0.003, 0.014, 0.01, 0.027, 0.074, 0.128, 0.048, 0.036, 0.024, 0.021, 0.026, 0.03, 0.004, 0.006, 0.006, 0.011, 0.006, 0.053, 0.028, 0.073, 0.041, 0.005, 0.007, 0.013, 0.012, 0.021, 0.053, 0.013, 0.071, 0.012, 0.016, 0.023, 0.024, 0.011, 0.019, 0.014, 0.022, 0.011, 0.129, 0.03, 0.012, 0.062, 0.145, 0.077, 0.028, 0.006, 0.019, 0.008, 0.006, 0.034, 0.109, 0.09, 0.005, 0.016, 0.005, 0.257, 0.011, 0.205, 0.01, 0.017, 0.039, 0.01, 0.016, 0.043, 0.004, 0.008, 0.04, 0.068, 0.006, 0.008, 0.005, 0.097, 0.015, 0.016, 0.01, 0.021, 0.008, 0.01, 0.006, 0.016, 0.021, 0.012, 0.009, 0.032, 0.055, 0.006, 0.066, 0.018, 0.01, 0.018, 0.017, 0.015, 0.01, 0.017, 0.02, 0.022)), class = "data.frame", row.names = c(4L, 5L, 6L,7L, 8L, 10L, 12L, 14L, 19L, 29L, 30L, 31L, 33L, 41L, 43L, 44L, 45L, 46L, 47L, 48L, 51L, 52L, 53L, 58L, 62L, 65L, 67L, 70L, 72L, 74L, 75L, 77L, 79L, 82L, 83L, 86L, 88L, 89L, 90L, 93L, 109L, 114L, 117L, 129L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 155L, 165L, 167L, 172L, 173L, 174L, 176L, 178L, 179L, 185L, 186L, 188L, 192L, 193L, 195L, 197L, 199L, 202L, 203L, 204L, 214L, 216L, 221L, 225L, 234L, 236L, 237L, 238L, 250L, 252L, 255L, 256L, 257L, 258L, 260L, 261L)) datashort # This does not work: fitgee <- gee(HipFlex ~ StepHeight,data=datashort,id=PID,corstr="exchangeable",na.action=na.omit) summary(fitgee) # This works. fitlm <- lm(HipFlex ~ StepHeight,data=datashort) summary(fitlm) John David Sorkin M.D., Ph.D. Profess
Re: [R] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run
I don't see it documented, but it appears that the gee() function assumes the id variable can be coerced to a number. Your ids are in PID, and are strings like "HIPS004", etc. Change that to "004" or a numeric 4 and the error goes away. Duncan Murdoch On 25/10/2023 3:23 p.m., Sorkin, John wrote: Colleagues, I am receiving several error messages from the gee function. I don't understand the ides the error messages are trying to impart, and I don't know how to debug or correct the error. The error messages follow: fitgee <- gee(HipFlex ~ StepHeight,data=datashort,id=PID,corstr="exchangeable",na.action=na.omit) Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27 running glm to get initial regression estimate (Intercept) StepHeight 1.400319 58.570236 Error in gee(HipFlex ~ StepHeight, data = datashort, id = PID, corstr = "exchangeable", : NA/NaN/Inf in foreign function call (arg 3) In addition: Warning message: In gee(HipFlex ~ StepHeight, data = datashort, id = PID, corstr = "exchangeable", : NAs introduced by coercion Of note, when the analysis is run using lm, there is no problem. My fully data and code follow: Thank you, John CODE: if (!require(gee)) {install.packages("gee")} library(gee) datashort <- structure(list(HipFlex = c(1.95, 2.07, 1.55, 0.44, 0.23, 0.41, 0.22, 4.61, 10.02, 1.08, 1.43, 1.82, 0.34, 0.77, 0.22, 1.06, 0.13, 0.36, 2.84, 5.2, 12.27, 1.37, 2.33, 3.48, 4.76, 1.92, 2.09, 4.67, 2.94, 0.75, 0.11, 3.56, 1.63, 0.8, 1.54, 5.06, NA,5.41, 6.18, 3.75, 3.12, 17.43, 3.18, 0.85, 14.54, 14.34, 21.92, 4.91, 1.52, 0.38, 0.43, 0.47, 0.56, 6.4, 12.4, 3.98, 0.57, 1.84, 12.06, 0.45, 8.16, 0.02, 0,0.05, 0.52, 0.11, 0.48, 1.5, 3.29, 2.58, 2.07, 6.06, 1.46, 1.06, 3.82, 1.09, 2.86, 3.47, 2.22, 1.89, NA, 3.48, 6.38, 3.58, 1.83, 2.8, 8.28, 7.15, 4.77, 4.93, 0, 0.11, 1.99, 2.01, 2.3, 1.24, 1.33, 2, 1.01), PID = c("HIPS004", "HIPS004", "HIPS005", "HIPS005", "HIPS005", "HIPS006", "HIPS006", "HIPS008", "HIPS010", "HIPS024", "HIPS024", "HIPS024", "HIPS025", "HIPS028", "HIPS028", "HIPS030", "HIPS030", "HIPS030", "HIPS035", "HIPS035", "HIPS035", "HIPS036", "HIPS036", "HIPS037", "HIPS044", "HIPS047", "HIPS047", "HIPS056", "HIPS056", "HIPS057", "HIPS057", "HIPS057", "HIPS058", "HIPS059", "HIPS059", "HIPS061", "HIPS062", "HIPS062", "HIPS062", "HIPS064", "HIPS074", "HIPS079", "HIPS084", "HIPS089", "HIPS090", "HIPS090", "HIPS090", "HIPS091", "HIPS091", "HIPS092", "HIPS092", "HIPS092", "HIPS001", "HIPS001", "HIPS001", "HIPS004", "HIPS004", "HIPS004", "HIPS005", "HIPS005", "HIPS005", "HIPS006", "HIPS006", "HIPS008", "HIPS022", "HIPS024", "HIPS028", "HIPS030", "HIPS035", "HIPS036", "HIPS036", "HIPS039", "HIPS044", "HIPS047", "HIPS051", "HIPS056", "HIPS058", "HIPS058", "HIPS059", "HIPS059", "HIPS062", "HIPS062", "HIPS062", "HIPS069", "HIPS069", "HIPS071", "HIPS074", "HIPS079", "HIPS084", "HIPS084", "HIPS085", "HIPS089", "HIPS090", "HIPS091", "HIPS091", "HIPS091", "HIPS092", "HIPS092", "HIPS093"), StepHeight = c(0.005, 0.008, 0.072, 0.003, 0.014, 0.01, 0.027, 0.074, 0.128, 0.048, 0.036, 0.024, 0.021, 0.026, 0.03, 0.004, 0.006, 0.006, 0.011, 0.006, 0.053, 0.028, 0.073, 0.041, 0.005, 0.007, 0.013, 0.012, 0.021, 0.053, 0.013, 0.071, 0.012, 0.016, 0.023, 0.024, 0.011, 0.019, 0.014, 0.022, 0.011, 0.129, 0.03, 0.012, 0.062, 0.145, 0.077, 0.028, 0.006, 0.019, 0.008, 0.006, 0.034, 0.109, 0.09, 0.005, 0.016, 0.005, 0.257, 0.011, 0.205, 0.01, 0.017, 0.039, 0.01, 0.016, 0.043, 0.004, 0.008, 0.04, 0.068, 0.006, 0.008, 0.005, 0.097, 0.015, 0.016, 0.01, 0.021, 0.008, 0.01, 0.006, 0.016, 0.021, 0.012, 0.009, 0.032, 0.055, 0.006, 0.066, 0.018, 0.01, 0.018, 0.017, 0.015, 0.01, 0.017, 0.02, 0.022)), class = "data.frame", row.names = c(4L, 5L, 6L,7L, 8L, 10L, 12L, 14L, 19L, 29L, 30L, 31L, 33L, 41L, 43L, 44L, 45L, 46L, 47L, 48L, 51L, 52L, 53L, 58L, 62L, 65L, 67L, 70L, 72L, 74L, 75L, 77L, 79L, 82L, 83L, 86L, 88L, 89L, 90L, 93L, 109L, 114L, 117L, 129L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 155L, 165L, 167L, 172L, 173L, 174L, 176L, 178L, 179L, 185L, 186L, 188L, 192L, 193L, 195L, 197L, 199L, 202L, 203L, 204L, 214L, 216L, 221L, 225L, 234L, 236L, 237L, 238L, 250L, 252L, 255L, 256L, 257L, 258L, 260L, 261L)) datashort # This does not work: fitgee <- gee(HipFlex ~ StepHeight,data=datashort,id=PID,corstr="exchangeable",na.action=na.omit) summary(fitgee) # This works. fitlm <- lm(HipFlex ~ StepHeight,data=datashort) summary(fitlm) John David Sorkin M.D., Ph.D. Professor of Medicine, University of Maryland School of Medicine; Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, and Clinical Center; PI Biostatistics and Informatics Core, University of Maryland Sch
[R] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run
Colleagues, I am receiving several error messages from the gee function. I don't understand the ides the error messages are trying to impart, and I don't know how to debug or correct the error. The error messages follow: > fitgee <- gee(HipFlex ~ > StepHeight,data=datashort,id=PID,corstr="exchangeable",na.action=na.omit) Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27 running glm to get initial regression estimate (Intercept) StepHeight 1.400319 58.570236 Error in gee(HipFlex ~ StepHeight, data = datashort, id = PID, corstr = "exchangeable", : NA/NaN/Inf in foreign function call (arg 3) In addition: Warning message: In gee(HipFlex ~ StepHeight, data = datashort, id = PID, corstr = "exchangeable", : NAs introduced by coercion Of note, when the analysis is run using lm, there is no problem. My fully data and code follow: Thank you, John CODE: if (!require(gee)) {install.packages("gee")} library(gee) datashort <- structure(list(HipFlex = c(1.95, 2.07, 1.55, 0.44, 0.23, 0.41, 0.22, 4.61, 10.02, 1.08, 1.43, 1.82, 0.34, 0.77, 0.22, 1.06, 0.13, 0.36, 2.84, 5.2, 12.27, 1.37, 2.33, 3.48, 4.76, 1.92, 2.09, 4.67, 2.94, 0.75, 0.11, 3.56, 1.63, 0.8, 1.54, 5.06, NA,5.41, 6.18, 3.75, 3.12, 17.43, 3.18, 0.85, 14.54, 14.34, 21.92, 4.91, 1.52, 0.38, 0.43, 0.47, 0.56, 6.4, 12.4, 3.98, 0.57, 1.84, 12.06, 0.45, 8.16, 0.02, 0,0.05, 0.52, 0.11, 0.48, 1.5, 3.29, 2.58, 2.07, 6.06, 1.46, 1.06, 3.82, 1.09, 2.86, 3.47, 2.22, 1.89, NA, 3.48, 6.38, 3.58, 1.83, 2.8, 8.28, 7.15, 4.77, 4.93, 0, 0.11, 1.99, 2.01, 2.3, 1.24, 1.33, 2, 1.01), PID = c("HIPS004", "HIPS004", "HIPS005", "HIPS005", "HIPS005", "HIPS006", "HIPS006", "HIPS008", "HIPS010", "HIPS024", "HIPS024", "HIPS024", "HIPS025", "HIPS028", "HIPS028", "HIPS030", "HIPS030", "HIPS030", "HIPS035", "HIPS035", "HIPS035", "HIPS036", "HIPS036", "HIPS037", "HIPS044", "HIPS047", "HIPS047", "HIPS056", "HIPS056", "HIPS057", "HIPS057", "HIPS057", "HIPS058", "HIPS059", "HIPS059", "HIPS061", "HIPS062", "HIPS062", "HIPS062", "HIPS064", "HIPS074", "HIPS079", "HIPS084", "HIPS089", "HIPS090", "HIPS090", "HIPS090", "HIPS091", "HIPS091", "HIPS092", "HIPS092", "HIPS092", "HIPS001", "HIPS001", "HIPS001", "HIPS004", "HIPS004", "HIPS004", "HIPS005", "HIPS005", "HIPS005", "HIPS006", "HIPS006", "HIPS008", "HIPS022", "HIPS024", "HIPS028", "HIPS030", "HIPS035", "HIPS036", "HIPS036", "HIPS039", "HIPS044", "HIPS047", "HIPS051", "HIPS056", "HIPS058", "HIPS058", "HIPS059", "HIPS059", "HIPS062", "HIPS062", "HIPS062", "HIPS069", "HIPS069", "HIPS071", "HIPS074", "HIPS079", "HIPS084", "HIPS084", "HIPS085", "HIPS089", "HIPS090", "HIPS091", "HIPS091", "HIPS091", "HIPS092", "HIPS092", "HIPS093"), StepHeight = c(0.005, 0.008, 0.072, 0.003, 0.014, 0.01, 0.027, 0.074, 0.128, 0.048, 0.036, 0.024, 0.021, 0.026, 0.03, 0.004, 0.006, 0.006, 0.011, 0.006, 0.053, 0.028, 0.073, 0.041, 0.005, 0.007, 0.013, 0.012, 0.021, 0.053, 0.013, 0.071, 0.012, 0.016, 0.023, 0.024, 0.011, 0.019, 0.014, 0.022, 0.011, 0.129, 0.03, 0.012, 0.062, 0.145, 0.077, 0.028, 0.006, 0.019, 0.008, 0.006, 0.034, 0.109, 0.09, 0.005, 0.016, 0.005, 0.257, 0.011, 0.205, 0.01, 0.017, 0.039, 0.01, 0.016, 0.043, 0.004, 0.008, 0.04, 0.068, 0.006, 0.008, 0.005, 0.097, 0.015, 0.016, 0.01, 0.021, 0.008, 0.01, 0.006, 0.016, 0.021, 0.012, 0.009, 0.032, 0.055, 0.006, 0.066, 0.018, 0.01, 0.018, 0.017, 0.015, 0.01, 0.017, 0.02, 0.022)), class = "data.frame", row.names = c(4L, 5L, 6L,7L, 8L, 10L, 12L, 14L, 19L, 29L, 30L, 31L, 33L, 41L, 43L, 44L, 45L, 46L, 47L, 48L, 51L, 52L, 53L, 58L, 62L, 65L, 67L, 70L, 72L, 74L, 75L, 77L, 79L, 82L, 83L, 86L, 88L, 89L, 90L, 93L, 109L, 114L, 117L, 129L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 155L, 165L, 167L, 172L, 173L, 174L, 176L, 178L, 179L, 185L, 186L, 188L, 192L, 193L, 195L, 197L, 199L, 202L, 203L, 204L, 214L, 216L, 221L, 225L, 234L, 236L, 237L, 238L, 250L, 252L, 255L, 256L, 257L, 258L, 260L, 261L)) datashort # This does not work: fitgee <- gee(HipFlex ~ StepHeight,data=datashort,id=PID,corstr="exchangeable",na.action=na.omit) summary(fitgee) # This works. fitlm <- lm(HipFlex ~ StepHeight,data=datashort) summary(fitlm) John David Sorkin M.D., Ph.D. Professor of Medicine, University of Maryland School of Medicine; Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, and Clinical Center; PI Biostatistics and Informatics Core, University of Maryland School of Medicine Claude D. Pepper Older Americans Independence Center; Senior Statistician University of Maryland Center for Vascular Research; Division of Gerontology and Paliative Care, 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 Cell phone 443-418-5382 [[alternative HTML version deleted]] __
[R] Error in finding factor scores/ person ability in item response theory
Dear R users, I have encountered some error in finding factor scores/ person ability in item response theory. I tried a few times using ltm and mirt package but it still gave me error. #TRY #1 - Fit GPCM model using ltm > irt_model <- gpcm(response_matrix) > irt_person_abilities <- fscores(irt_model) *Error in object@Model : * * no applicable method for `@` applied to an object of class "gpcm"* #TRY #2 - Fit GPCM model using ltm > irt_model <- gpcm(data = HT, constraint = "1PL") > irt_person_abilities <- factor.scores(irt_model) *Error in factor.scores(irt_model) : * * argument "f" is missing, with no default* #TRY #3 - Fit GPCM model using mirt > irt_model <- mirt(data = HT, model = "gpcm", itemtype = "graded") *Error in model$x[i, "Type"] : subscript out of bounds* *In addition: Warning message:* *In cbind(model$x, OptionalGroups = "") :* * number of rows of result is not a multiple of vector length (arg 2)* > irt_person_abilities_dim1 <- fscores(gpcm_model, method = "EAP", dims = 1) *Error in object@Model : * * no applicable method for `@` applied to an object of class "gpcm"* I am not sure which package is suitable with my data (Polytomous - Partial Credit Model) and why it always turns out to be an error. Thank you very much for any help given. Azila. [[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] Error in analysis of arguments of Rasch
Dear R users, I am using ltm and eRm package in analysing my polytomous data for fitting item response theory and Rasch model, respectively. I'm having a problem with the error as below; > library(eRm) > library(ltm) > HT <- read.csv("C:/Dropbox/Analysis R_2023/HT.csv") > response_columns <- HT[, 1:ncol(HT)] > response_matrix <- as.matrix(response_columns) > irt_model <- grm(response_matrix) > rasch_model <- Rasch(response_matrix) Error in Rasch(response_matrix) : could not find function "Rasch" Then I changed the arguments of Rasch to RM, but it also turns out an error as below; > rasch_model <- RM(response_matrix) Error in datcheck(X, W, mpoints, groupvec, model) : Dichotomous data matrix required! Is there any problem with the arguments or any other problem with my coding since errors keep occurring when I want to run Rasch. Thank you very much for any help given. Azi. [[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 "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
Fascinating and, as ever, extremely helpful Ivan. Duncan Murdoch nudged me in the right direction and for now the solution for me is that if I don't have the lines: description: | CE's pages "blog posts" about using R in _site.yaml that have been there for ages, then everything works. If I put _anything_ in there, including two lines copied and pasted from a brand new distill site instead of those two lines then the error returns so I think something else is awry in my main distill site that has rendered the knitting of the site allergic to having a description in _site.yaml. I should probably go further to try to debug this but across this and the trouble I was having with the mirror.infomaniak.ch ubuntu mirror (R-sig-Debian thread, another you helped with, has details of that!) I have lost too much time debugging in the last week and desperately need to get back to my main work (and work I'm more competent to do!) Many thanks again, Chris On 25/08/2023 15:48, Ivan Krylov wrote: В Fri, 25 Aug 2023 11:49:03 +0200 Chris Evans via R-help пишет: Hm. I tried that butI really don't know what to make of what it's telling me. It seemed to me that I was just stepping through the same bits of code (with the warning that the debugger didn't have the source so I'm not really sure what it was showing me!) write_feed_xml is an internal function in the "distill" package. It's supposed to create the RSS feed for a whole set of web pages. Somehow it ends up trying to assign a list to xml2::xml_text(some_xml_node), where only assigning a character string would make sense. The function contains quite a lot of assignments like this. Some of them come from site_config (which comes from _site.yml?), others are taken from the article contents and metadata. If you run options(error = recover) in a fresh R session before knitting your website, you should get a debugger menu right at the point where the code crashes. Try to find out what is the XML node where the text is being assigned and what is the list that ends up being assigned into it. You will also get the option to see the variables in the callers of the failing function, which may shed some light on the situation too. -- Chris Evans (he/him) Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, University of Roehampton, London, UK. Work web site: https://www.psyctc.org/psyctc/ CORE site: http://www.coresystemtrust.org.uk/ Personal site: https://www.psyctc.org/pelerinage2016/ __ 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 "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
В Fri, 25 Aug 2023 11:49:03 +0200 Chris Evans via R-help пишет: > Hm. I tried that butI really don't know what to make of what it's > telling me. It seemed to me that I was just stepping through the > same bits of code (with the warning that the debugger didn't > have the source so I'm not really sure what it was showing me!) write_feed_xml is an internal function in the "distill" package. It's supposed to create the RSS feed for a whole set of web pages. Somehow it ends up trying to assign a list to xml2::xml_text(some_xml_node), where only assigning a character string would make sense. The function contains quite a lot of assignments like this. Some of them come from site_config (which comes from _site.yml?), others are taken from the article contents and metadata. If you run options(error = recover) in a fresh R session before knitting your website, you should get a debugger menu right at the point where the code crashes. Try to find out what is the XML node where the text is being assigned and what is the list that ends up being assigned into it. You will also get the option to see the variables in the callers of the failing function, which may shed some light on the situation too. -- Best regards, Ivan __ 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 "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
On 24/08/2023 21:05, Duncan Murdoch wrote: On 24/08/2023 1:58 p.m., Chris Evans via R-help wrote: I have an Rmarkdown file which is part of my distill "Rblog" (https://www.psyctc.org/Rblog/). It was knitting fine until last week, now knitting terminates with this: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/Rtmp7WHAIE/fileb39b179ffd801html --include-in-header /tmp/Rtmp7WHAIE/fileb39b15b1e3532html --include-in-header /tmp/Rtmp7WHAIE/fileb39b13239652chtml --include-in-header /tmp/Rtmp7WHAIE/fileb39b1581627e8html --include-in-header /tmp/Rtmp7WHAIE/fileb39b12850a405html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16f8d72a6html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16ce17d77html --include-before-body /tmp/Rtmp7WHAIE/fileb39b12f851f86html --include-after-body /tmp/Rtmp7WHAIE/fileb39b14447b7b1html --include-after-body /tmp/Rtmp7WHAIE/fileb39b143ff6632html --include-after-body /tmp/Rtmp7WHAIE/fileb39b1345b1dddhtml --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/Rtmp7WHAIE/rmarkdown-strb39b160f391de.html --include-in-header /tmp/Rtmp7WHAIE/fileb39b164361476html Error in `xml_text<-.xml_node`(`*tmp*`, value = text) : STRING_ELT() can only be applied to a 'character vector', not a 'list' Calls: ... write_feed_xml -> add_child -> -> xml_text<-.xml_node In addition: There were 20 warnings (use warnings() to see them) Execution halted That function `xml_text<-.xml_node` is in the xml2 package, which was updated in early July. Do you think the error has been happening since you updated your copy, or did something else trigger it? I wish I had good clues from that. Everything with the "blog" was working fine until the 21st. Since then (yesterday) I have fixed an issue (down to the mirror.infomaniak.ch server I was using) that had meant a lot of my Ubuntu packages were out of date but this problem started before I fixed that, by the 23rd. I update the OS daily (but that wasn't working for deb packages until yesterday because of the mirror problem) and I also R packages daily but I don't watch what updates and what doesn't. I guess I could put that on a cron job with an Email to self to keep track of it in future. One way to debug this is as follows. With the file in the directory where the error occurs, start R (or RStudio, it shouldn't matter), and run debug(xml2:::`xml_text<-.xml_node`) rmarkdown::render("creating-a-shiny-server.Rmd") If you're lucky, the error will happen on the first call to that function, and you can trace into it to see what's so weird. If you're unlucky, it will happen after many calls. Then you'll probably have to use trace() to identify which call causes problems (increment and print a counter on each call), then break just before the bad call and try to see what went wrong. Hm. I tried that butI really don't know what to make of what it's telling me. It seemed to me that I was just stepping through the same bits of code (with the warning that the debugger didn't have the source so I'm not really sure what it was showing me!) Sorry, showing my ignorance of that level of R debugging. Can you give me any more advice about that? Or perhaps _if_ the code does give the same error for you, you'd be able to see quickly what I can't? Deeply grateful for the help and sorry I'm not up to scratch on my side. I'd really appreciate any other thoughts as I'm stuck with the blog for now! Chris Duncan Murdoch [rest snipped] -- Chris Evans (he/him) Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, University of Roehampton, London, UK. Work web site: https://www.psyctc.org/psyctc/ CORE site: http://www.coresystemtrust.org.uk/ Personal site: https://www.psyctc.org/pelerinage2016/ __ 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,
Re: [R] Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
Thanks Duncan. I've pushed the whole collection to: https://github.com/cpsyctc/Rblog On 24/08/2023 20:54, Duncan Murdoch wrote: Could you post a link to the source for that Rmd file? Duncan Murdoch [rest snipped] __ 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 "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
On 24/08/2023 1:58 p.m., Chris Evans via R-help wrote: I have an Rmarkdown file which is part of my distill "Rblog" (https://www.psyctc.org/Rblog/). It was knitting fine until last week, now knitting terminates with this: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/Rtmp7WHAIE/fileb39b179ffd801html --include-in-header /tmp/Rtmp7WHAIE/fileb39b15b1e3532html --include-in-header /tmp/Rtmp7WHAIE/fileb39b13239652chtml --include-in-header /tmp/Rtmp7WHAIE/fileb39b1581627e8html --include-in-header /tmp/Rtmp7WHAIE/fileb39b12850a405html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16f8d72a6html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16ce17d77html --include-before-body /tmp/Rtmp7WHAIE/fileb39b12f851f86html --include-after-body /tmp/Rtmp7WHAIE/fileb39b14447b7b1html --include-after-body /tmp/Rtmp7WHAIE/fileb39b143ff6632html --include-after-body /tmp/Rtmp7WHAIE/fileb39b1345b1dddhtml --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/Rtmp7WHAIE/rmarkdown-strb39b160f391de.html --include-in-header /tmp/Rtmp7WHAIE/fileb39b164361476html Error in `xml_text<-.xml_node`(`*tmp*`, value = text) : STRING_ELT() can only be applied to a 'character vector', not a 'list' Calls: ... write_feed_xml -> add_child -> -> xml_text<-.xml_node In addition: There were 20 warnings (use warnings() to see them) Execution halted That function `xml_text<-.xml_node` is in the xml2 package, which was updated in early July. Do you think the error has been happening since you updated your copy, or did something else trigger it? One way to debug this is as follows. With the file in the directory where the error occurs, start R (or RStudio, it shouldn't matter), and run debug(xml2:::`xml_text<-.xml_node`) rmarkdown::render("creating-a-shiny-server.Rmd") If you're lucky, the error will happen on the first call to that function, and you can trace into it to see what's so weird. If you're unlucky, it will happen after many calls. Then you'll probably have to use trace() to identify which call causes problems (increment and print a counter on each call), then break just before the bad call and try to see what went wrong. Duncan Murdoch It's the same if I do it in Rstudio or from the command line like that so I think I can safely say it's not an Rstudio issue. The same happens with other Rmd files in the distill _posts directory. The really weird aspects are: 1) the html _is_ created fine (but if running in Rstudio it doesn't transfer to showing you the html) 2) the error message is only there if I run the Rmd in that directory, i.e. the 2023-08-19-creating-a-shiny-server directory in _posts or in _posts above that, but I move it up againif I move it to higher or other directories it works fine: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/RtmpGMqTCm/fileb43a436c6281fhtml --include-in-header /tmp/RtmpGMqTCm/fileb43a455b7e5bdhtml --include-in-header /tmp/RtmpGMqTCm/fileb43a461db1ea1html --include-in-header /tmp/RtmpGMqTCm/fileb43a474a6e703html --include-before-body /tmp/RtmpGMqTCm/fileb43a494bd34html --include-before-body /tmp/RtmpGMqTCm/fileb43a42fbfec67html --include-before-body /tmp/RtmpGMqTCm/fileb43a427
Re: [R] Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
Could you post a link to the source for that Rmd file? Duncan Murdoch On 24/08/2023 1:58 p.m., Chris Evans via R-help wrote: I have an Rmarkdown file which is part of my distill "Rblog" (https://www.psyctc.org/Rblog/). It was knitting fine until last week, now knitting terminates with this: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/Rtmp7WHAIE/fileb39b179ffd801html --include-in-header /tmp/Rtmp7WHAIE/fileb39b15b1e3532html --include-in-header /tmp/Rtmp7WHAIE/fileb39b13239652chtml --include-in-header /tmp/Rtmp7WHAIE/fileb39b1581627e8html --include-in-header /tmp/Rtmp7WHAIE/fileb39b12850a405html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16f8d72a6html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16ce17d77html --include-before-body /tmp/Rtmp7WHAIE/fileb39b12f851f86html --include-after-body /tmp/Rtmp7WHAIE/fileb39b14447b7b1html --include-after-body /tmp/Rtmp7WHAIE/fileb39b143ff6632html --include-after-body /tmp/Rtmp7WHAIE/fileb39b1345b1dddhtml --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/Rtmp7WHAIE/rmarkdown-strb39b160f391de.html --include-in-header /tmp/Rtmp7WHAIE/fileb39b164361476html Error in `xml_text<-.xml_node`(`*tmp*`, value = text) : STRING_ELT() can only be applied to a 'character vector', not a 'list' Calls: ... write_feed_xml -> add_child -> -> xml_text<-.xml_node In addition: There were 20 warnings (use warnings() to see them) Execution halted It's the same if I do it in Rstudio or from the command line like that so I think I can safely say it's not an Rstudio issue. The same happens with other Rmd files in the distill _posts directory. The really weird aspects are: 1) the html _is_ created fine (but if running in Rstudio it doesn't transfer to showing you the html) 2) the error message is only there if I run the Rmd in that directory, i.e. the 2023-08-19-creating-a-shiny-server directory in _posts or in _posts above that, but I move it up againif I move it to higher or other directories it works fine: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/RtmpGMqTCm/fileb43a436c6281fhtml --include-in-header /tmp/RtmpGMqTCm/fileb43a455b7e5bdhtml --include-in-header /tmp/RtmpGMqTCm/fileb43a461db1ea1html --include-in-header /tmp/RtmpGMqTCm/fileb43a474a6e703html --include-before-body /tmp/RtmpGMqTCm/fileb43a494bd34html --include-before-body /tmp/RtmpGMqTCm/fileb43a42fbfec67html --include-before-body /tmp/RtmpGMqTCm/fileb43a4273d84ebhtml --include-after-body /tmp/RtmpGMqTCm/fileb43a4725e33cahtml --include-after-body /tmp/RtmpGMqTCm/fileb43a43d386888html --include-after-body /tmp/RtmpGMqTCm/fileb43a43f19b459html --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/RtmpGMqTCm/rmarkdown-strb43a43033daa0.html --include-in-header /tmp/RtmpGMqTCm/fileb43a42807e405html Output created: creating-a-shiny-server.html Warning message: In as.character.POSIXt(as.POSIXlt(x), ...) : as.character(td, ..) no longer obeys a 'format' argument; use format(td, ..) ? The 20 warnings are: > warnings() Warning messages: 1: In as.character.POSIXt(as.POSIXlt(x), ...) : as.character(td, ..) no longer obeys a 'form
[R] Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
I have an Rmarkdown file which is part of my distill "Rblog" (https://www.psyctc.org/Rblog/). It was knitting fine until last week, now knitting terminates with this: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/Rtmp7WHAIE/fileb39b179ffd801html --include-in-header /tmp/Rtmp7WHAIE/fileb39b15b1e3532html --include-in-header /tmp/Rtmp7WHAIE/fileb39b13239652chtml --include-in-header /tmp/Rtmp7WHAIE/fileb39b1581627e8html --include-in-header /tmp/Rtmp7WHAIE/fileb39b12850a405html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16f8d72a6html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16ce17d77html --include-before-body /tmp/Rtmp7WHAIE/fileb39b12f851f86html --include-after-body /tmp/Rtmp7WHAIE/fileb39b14447b7b1html --include-after-body /tmp/Rtmp7WHAIE/fileb39b143ff6632html --include-after-body /tmp/Rtmp7WHAIE/fileb39b1345b1dddhtml --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/Rtmp7WHAIE/rmarkdown-strb39b160f391de.html --include-in-header /tmp/Rtmp7WHAIE/fileb39b164361476html Error in `xml_text<-.xml_node`(`*tmp*`, value = text) : STRING_ELT() can only be applied to a 'character vector', not a 'list' Calls: ... write_feed_xml -> add_child -> -> xml_text<-.xml_node In addition: There were 20 warnings (use warnings() to see them) Execution halted It's the same if I do it in Rstudio or from the command line like that so I think I can safely say it's not an Rstudio issue. The same happens with other Rmd files in the distill _posts directory. The really weird aspects are: 1) the html _is_ created fine (but if running in Rstudio it doesn't transfer to showing you the html) 2) the error message is only there if I run the Rmd in that directory, i.e. the 2023-08-19-creating-a-shiny-server directory in _posts or in _posts above that, but I move it up againif I move it to higher or other directories it works fine: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/RtmpGMqTCm/fileb43a436c6281fhtml --include-in-header /tmp/RtmpGMqTCm/fileb43a455b7e5bdhtml --include-in-header /tmp/RtmpGMqTCm/fileb43a461db1ea1html --include-in-header /tmp/RtmpGMqTCm/fileb43a474a6e703html --include-before-body /tmp/RtmpGMqTCm/fileb43a494bd34html --include-before-body /tmp/RtmpGMqTCm/fileb43a42fbfec67html --include-before-body /tmp/RtmpGMqTCm/fileb43a4273d84ebhtml --include-after-body /tmp/RtmpGMqTCm/fileb43a4725e33cahtml --include-after-body /tmp/RtmpGMqTCm/fileb43a43d386888html --include-after-body /tmp/RtmpGMqTCm/fileb43a43f19b459html --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/RtmpGMqTCm/rmarkdown-strb43a43033daa0.html --include-in-header /tmp/RtmpGMqTCm/fileb43a42807e405html Output created: creating-a-shiny-server.html Warning message: In as.character.POSIXt(as.POSIXlt(x), ...) : as.character(td, ..) no longer obeys a 'format' argument; use format(td, ..) ? The 20 warnings are: > warnings() Warning messages: 1: In as.character.POSIXt(as.POSIXlt(x), ...) : as.character(td, ..) no longer obeys a 'format' argument; use format(td, ..) ? 2: In as.character.POSIXt(as.POSIXlt
Re: [R] Error in analysis of Rasch using eRm package.
Às 16:49 de 21/08/2023, nor azila escreveu: Dear R users, I am using eRm package in analysing my polytomous data as below Respondents = 277 people Item = 30 questions The data consists of 0,1,2,3 responses/answers. I'm having a problem in writing coding as below because I do not know what I should replace in each of the arguments. data.frame(..., row.names = NULL, check.rows = FALSE, check.names = TRUE, fix.empty.names = TRUE, stringsAsFactors = FALSE) Thank you very much for any help given. Azi. [[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. Hello, It seems that you have data that in tabular form is one column per answer, so you would end up with 30 columns, maybe an extra id column. Can you post sample data? If not, make up the answers and post the answers of the first 6 individuals or so. Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in analysis of Rasch using eRm package.
Dear R users, I am using eRm package in analysing my polytomous data as below Respondents = 277 people Item = 30 questions The data consists of 0,1,2,3 responses/answers. I'm having a problem in writing coding as below because I do not know what I should replace in each of the arguments. data.frame(..., row.names = NULL, check.rows = FALSE, check.names = TRUE, fix.empty.names = TRUE, stringsAsFactors = FALSE) Thank you very much for any help given. Azi. [[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: promise already under evaluation
Fixed! I was not passing a tol value from the outer function to the inner qnbinom() function. Because the scope of tol in qbinom() was confined to the outer function, qnbinom was not accessing the globally defined tol value. Furthermore, because the outer function itself was embedded in integrate(), the standard nonstandard scoping didn't enable access to the global value. I hope this makes sense. In any case, the problem has been solved. Thanks. On Tue, Jul 18, 2023, 10:38 AM Ivan Krylov wrote: > В Tue, 18 Jul 2023 09:28:30 -0400 > Joseph Lucke пишет: > > > Error in qnbinom(1 - tol, size = q, prob = r) : > > > pRsq.Rhosq <- function(x, n, p, Rhosq,tol=tol){ > > It looks like you're not passing the `tol` parameter, and its default > value unfortunately refers to itself: > > (function(x = x) x)() > # Error in (function(x = x) x)() : > # promise already under evaluation: recursive default argument > # reference or earlier problems? > > -- > Best regards, > Ivan > [[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: promise already under evaluation
В Tue, 18 Jul 2023 09:28:30 -0400 Joseph Lucke пишет: > Error in qnbinom(1 - tol, size = q, prob = r) : > pRsq.Rhosq <- function(x, n, p, Rhosq,tol=tol){ It looks like you're not passing the `tol` parameter, and its default value unfortunately refers to itself: (function(x = x) x)() # Error in (function(x = x) x)() : # promise already under evaluation: recursive default argument # reference or earlier problems? -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error: promise already under evaluation
A repost. R gurus: I have a 10 or so functions that use R’s qnbinom() function. Until now, they have worked without any problems whatsoever. I created a new function, which involved the integration, using R’s integrate(), of a function that in turn uses the qnbinom() function. The function failed because of my programming stupidity. It has been deleted from my source file. Now I cannot get any function using qnbinom() to work. I get the following error. Error in qnbinom(1 - tol, size = q, prob = r) : promise already under evaluation: recursive default argument reference or earlier problems? An example function that that used to work splendidly but now fails is #Distribution of R2: 0 to x pRsq.Rhosq <- function(x, n, p, Rhosq,tol=tol){ a <- p /2; b <- (n-p-1)/2; q <- (n-1)/2 r <- 1-Rhosq k <- 0:qnbinom(1-tol,size=q,prob=r) sum(dnbinom(k,size=q,prob=r)*pbeta(x,a+k,b)) } Tracebacks from more complicated functions, which have worked before, always return to the above error. When I re-source the source file without the offending function, I still get the error. How do I get rid of this error? What can I do to avoid it error in the future? TIA Joe Lucke [[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 in arfima...
>>>>> akshay kulkarni >>>>> on Mon, 5 Jun 2023 14:11:12 + writes: > Dear Martin, > Sad that the bug is beyond your ken... well, that's not exactly what I tried to say (and I did ask you for more output from your R session and also asked about what happens if you try things several time in a row, etc). At the moment, it looks to me that nobody can reproduce the problem with what you've given, and my personal guess is that something is "bad" only on your computer, i.e., your combination of hardware, software, your R installation, your installation of the forecast package and its many dependencies (other R packages), etc. .. > Fortunately, the error happens only rarely...The length of LYGH was 719 and there were only two such errors..I will just replace them with NA and make do. > By the by, what if I send LYGH as an attachment to your actual mail ( not the r-help mail)? Will it help? Can you then pinpoint the cause? Yes, please do that. Make the file "LYGH.rds" available (on the web or send to me) which you get after saveRDS(LYGH, file="LYGH.rds") > Or should I raise a bug report? If yes, how( I never raised one)? We don't know yet if there is any bug, see above. Martin > THanking you, > Yours sincerely, > AKSHAY M KULKARNI > > From: Martin Maechler > Sent: Monday, June 5, 2023 3:19 PM > To: akshay kulkarni > Cc: Martin Maechler ; R help Mailing list > Subject: Re: [R] error in arfima... >> Dear Martin, >> REgrets to reply this late >> I am staring at a conundrum never before encountered in my experience with R: >> LYGH[[201]] >> [1] 45.40 3.25 6.50 2.15 >> > arfima(LYGH[[201]]) >> Error in .fdcov(x, fdf$d, h, nar = nar, nma = nma, hess = hess, fdf.work = fdf$w) : >> NA/NaN/Inf in foreign function call (arg 5) >> > arfima(c(45.40,3.25,6.50,2.15)) >> Call: >> arfima(y = c(45.4, 3.25, 6.5, 2.15)) >> Coefficients: >> d >> 4.583013e-05 >> sigma[eps] = 18.01252 >> a list with components: >> [1] "log.likelihood" "n" "msg" "d" "ar" >> [6] "ma" "covariance.dpq" "fnormMin""sigma" "stderror.dpq" >> [11] "correlation.dpq" "h" "d.tol" "M" "hessian.dpq" >> [16] "length.w""residuals" "fitted" "call" "x" >> [21] "series" >> Please note that the index of LYGH has changed from 202 to 201 due to some randomness in one of my function. >> PLEASE HELP. >> Output of dput LYGH[[201]]: >> > dput(LYGH[[201]]) >> c(45.4, 3.25, 6.5, 2.149998) >> output of session info() >> sessionInfo() >> R version 4.1.2 (2021-11-01) >> Platform: x86_64-w64-mingw32/x64 (64-bit) >> Running under: Windows Server x64 (build 14393) >> Matrix products: default >> locale: >> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 >> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C >> [5] LC_TIME=English_United States.1252 >> attached base packages: >> [1] parallel stats graphics grDevices utils datasets methods base >> other attached packages: >> [1] pbmcapply_1.5.1 imputeTS_3.3forecast_8.17.0 >> loaded via a namespace (and not attached): >> [1] Rcpp_1.0.7urca_1.3-3pillar_1.9.0 compiler_4.1.2 tseries_0.10-51 >> [6] tools_4.1.2 xts_0.12.1nlme_3.1-153 lifecycle_1.0.3 tibble_3.2.1 >> [11] gtable_0.3.3 lattice_0.20-45 pkgconfig_2.0.3 rlang_1.1.0 cli_3.6.1 >> [16] rstudioapi_0.14 curl_4.3.2xml2_1.3.3dplyr_1.1.1 generics_0.1.3 >> [21] vctrs_0.6.1 gridtext_0.1.5ggtext_0.1.2 lmtest_0.9-40 grid_4.1.2 >> [26] nnet_7.3-16 tidyselect_1.2.0 glue_1.6.2R6_2.5.1 fansi_1.0.4 >> [31] ggplot2_3.4.2 TTR_0.24.3magrittr_2.0.3scales_1.2.1 quantmod_0.4.20 >> [36] timeDate_4021.106 colorspace_2.1-0 fracdiff_1.5-1 quadprog_1.5-8utf8_1.2.3 >> [41] stinepack_1.4 munsell_0.5.0 zoo_1.8-10 >> PLease Also note: >> arfima
Re: [R] error in arfima...
Dear Martin, Sad that the bug is beyond your ken... Fortunately, the error happens only rarely...The length of LYGH was 719 and there were only two such errors..I will just replace them with NA and make do. By the by, what if I send LYGH as an attachment to your actual mail ( not the r-help mail)? Will it help? Can you then pinpoint the cause? Or should I raise a bug report? If yes, how( I never raised one)? THanking you, Yours sincerely, AKSHAY M KULKARNI From: Martin Maechler Sent: Monday, June 5, 2023 3:19 PM To: akshay kulkarni Cc: Martin Maechler ; R help Mailing list Subject: Re: [R] error in arfima... > Dear Martin, > REgrets to reply this late > I am staring at a conundrum never before encountered in my experience with R: > LYGH[[201]] > [1] 45.40 3.25 6.50 2.15 > > arfima(LYGH[[201]]) > Error in .fdcov(x, fdf$d, h, nar = nar, nma = nma, hess = hess, fdf.work = > fdf$w) : > NA/NaN/Inf in foreign function call (arg 5) > > arfima(c(45.40,3.25,6.50,2.15)) > Call: > arfima(y = c(45.4, 3.25, 6.5, 2.15)) > Coefficients: >d > 4.583013e-05 > sigma[eps] = 18.01252 > a list with components: > [1] "log.likelihood" "n" "msg" "d" > "ar" > [6] "ma" "covariance.dpq" "fnormMin""sigma" > "stderror.dpq" > [11] "correlation.dpq" "h" "d.tol" "M" > "hessian.dpq" > [16] "length.w""residuals" "fitted" "call" > "x" > [21] "series" > Please note that the index of LYGH has changed from 202 to 201 due to some > randomness in one of my function. > PLEASE HELP. > Output of dput LYGH[[201]]: > > dput(LYGH[[201]]) > c(45.4, 3.25, 6.5, 2.149998) > output of session info() > sessionInfo() > R version 4.1.2 (2021-11-01) > Platform: x86_64-w64-mingw32/x64 (64-bit) > Matrix products: default > locale: > [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > attached base packages: > [1] parallel stats graphics grDevices utils datasets methods base > other attached packages: > [1] pbmcapply_1.5.1 imputeTS_3.3forecast_8.17.0 > loaded via a namespace (and not attached): > [1] Rcpp_1.0.7urca_1.3-3pillar_1.9.0 compiler_4.1.2 > tseries_0.10-51 > [6] tools_4.1.2 xts_0.12.1nlme_3.1-153 lifecycle_1.0.3 > tibble_3.2.1 > [11] gtable_0.3.3 lattice_0.20-45 pkgconfig_2.0.3 rlang_1.1.0 > cli_3.6.1 > [16] rstudioapi_0.14 curl_4.3.2xml2_1.3.3dplyr_1.1.1 > generics_0.1.3 > [21] vctrs_0.6.1 gridtext_0.1.5ggtext_0.1.2 lmtest_0.9-40 > grid_4.1.2 > [26] nnet_7.3-16 tidyselect_1.2.0 glue_1.6.2R6_2.5.1 > fansi_1.0.4 > [31] ggplot2_3.4.2 TTR_0.24.3magrittr_2.0.3scales_1.2.1 > quantmod_0.4.20 > [36] timeDate_4021.106 colorspace_2.1-0 fracdiff_1.5-1quadprog_1.5-8 > utf8_1.2.3 > [41] stinepack_1.4 munsell_0.5.0 zoo_1.8-10 > PLease Also note: > arfima(c(45.4, 3.25, 6.5, 2.149998)) > Call: > arfima(y = c(45.4, 3.25, 6.5, 2.149998)) > Coefficients: >d > 4.583013e-05 > sigma[eps] = 18.01252 > a list with components: > [1] "log.likelihood" "n" "msg" "d" > "ar" > [6] "ma" "covariance.dpq" "fnormMin""sigma" > "stderror.dpq" > [11] "correlation.dpq" "h" "d.tol" "M" > "hessian.dpq" > [16] "length.w""residuals" "fitted" "call" > "x" > [21] "series" > Many thanks in advance > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI Hmm... indeed, "conundrum" may be a euphemism for the situation. which clearly points to a bug *somewhere*. As your dput() shows, the argument *is* a simple vector .. and even if the default dput() may loose a few bits in precison... you did show that with (possibly only almost) identical argument, the error did not happen. I really have no idea what's going on, So
Re: [R] error in arfima...
he difference. I think you should consider let your 'Windows Server' provider update R on that server. Notably the Windows version of R has had problems fixed in the mean time .. and at least there's a hope the problem disappears. Lastly (but probably not helping more), you could use dput() with control="digits" and even .Internal(inspect( * )) magic on your LYGH[[201]] When I use simple numeric vectors "like" your LYGH[..], I get > dput(c(45.4, 3.25, 6.5, 2.15), control="digits") c(45.399, 3.25, 6.5, 2.1499) > .Internal(inspect(c(45.4, 3.25, 6.5, 2.15)) + ) @9874728 14 REALSXP g0c3 [] (len=4, tl=0) 45.4,3.25,6.5,2.15 > Martin > > From: Martin Maechler > Sent: Thursday, June 1, 2023 1:28 PM > To: akshay kulkarni > Cc: R help Mailing list > Subject: Re: [R] error in arfima... > >>>>> akshay kulkarni > >>>>> on Wed, 31 May 2023 20:55:33 + writes: > > dear members, > > I am using arfima() from forecast package to model a time > > series. The following is the code: > >> LYGH[[202]] > > [1] 45.40 3.25 6.50 2.15 > >> arfima(LYGH[[202]]) > > Error in .fdcov(x, fdf$d, h, nar = nar, nma = nma, hess = hess, > fdf.work = fdf$w) : > > NA/NaN/Inf in foreign function call (arg 5) > > I tried viewing .fdcov() with the following code: > > View(environment(fracdiff)$.fdcov) > > but I see no stop() with the above mentioned error message. > > Can you please help? > Well, as I am the maintainer of the *fracdiff* package, > I'm trying. OTOH, as we will see below, you did not give us enough > information to really help you... > > THanking you, > > Yours sincerely, > > AKSHAY M KULKARNI > Your problem is not (yet) reproducible (*) > I've done the following in an "empty" (i.e. freshly started) R > session, R 4.3.0: > begin_R_transcript___save_as__arfima-ex.Rout__-- > > > > lN <- loadedNamespaces() > > library(forecast) > Registered S3 method overwritten by 'quantmod': > methodfrom > as.zoo.data.frame zoo > > options(width=75) > > setdiff(loadedNamespaces(), lN) # -- see all the *!^@...! forecast loads: > [1] "gtable" "dplyr" "tidyselect" "Rcpp" "parallel" > [6] "scales" "lattice""ggplot2""R6" "generics" > [11] "curl" "lmtest" "tibble" "munsell""nnet" > [16] "forecast" "timeDate" "pillar" "rlang" "quantmod" > [21] "utf8" "urca" "quadprog" "cli""magrittr" > [26] "xts""grid" "nlme" "lifecycle" "fracdiff" > [31] "vctrs" "glue" "tseries""zoo""fansi" > [36] "colorspace" "TTR""pkgconfig" > > arfima(c(45.40, 3.25, 6.50, 2.15)) > Call: > arfima(y = c(45.4, 3.25, 6.5, 2.15)) > Coefficients: >d > 4.583013e-05 > sigma[eps] = 18.01252 > a list with components: > [1] "log.likelihood" "n" "msg" > [4] "d" "ar" "ma" > [7] "covariance.dpq" "fnormMin""sigma" > [10] "stderror.dpq""correlation.dpq" "h" > [13] "d.tol" "M" "hessian.dpq" > [16] "length.w""residuals" "fitted" > [19] "call""x" "series" > > > > sessionInfo() > R version 4.3.0 (2023-04-21) > Platform: x86_64-pc-linux-gnu (64-bit) > Running under: Fedora Linux 36 (Thirty Six) > Matrix products: default > BLAS: /usr/local64.sfs/app/R/R-4.3.0-inst/lib/libRblas.so > LAPACK: /usr/lib64/liblapack.so.3.10.1 > locale: > [1] LC_CTYPE=de_CH.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8LC_COLLATE=de_CH.UTF-8 > [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=de_CH.UTF-8 > [7] LC_PAPER=de_CH.UTF-8 LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C > time zone: Europe/Zurich > tzcode source: system (glibc) > attached base packages: >
Re: [R] error in arfima...
Dear Martin, REgrets to reply this late I am staring at a conundrum never before encountered in my experience with R: LYGH[[201]] [1] 45.40 3.25 6.50 2.15 > arfima(LYGH[[201]]) Error in .fdcov(x, fdf$d, h, nar = nar, nma = nma, hess = hess, fdf.work = fdf$w) : NA/NaN/Inf in foreign function call (arg 5) > arfima(c(45.40,3.25,6.50,2.15)) Call: arfima(y = c(45.4, 3.25, 6.5, 2.15)) Coefficients: d 4.583013e-05 sigma[eps] = 18.01252 a list with components: [1] "log.likelihood" "n" "msg" "d" "ar" [6] "ma" "covariance.dpq" "fnormMin""sigma" "stderror.dpq" [11] "correlation.dpq" "h" "d.tol" "M" "hessian.dpq" [16] "length.w""residuals" "fitted" "call""x" [21] "series" Please note that the index of LYGH has changed from 202 to 201 due to some randomness in one of my function. PLEASE HELP. Output of dput LYGH[[201]]: > dput(LYGH[[201]]) c(45.4, 3.25, 6.5, 2.149998) output of session info() sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows Server x64 (build 14393) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] parallel stats graphics grDevices utils datasets methods base other attached packages: [1] pbmcapply_1.5.1 imputeTS_3.3forecast_8.17.0 loaded via a namespace (and not attached): [1] Rcpp_1.0.7urca_1.3-3pillar_1.9.0 compiler_4.1.2 tseries_0.10-51 [6] tools_4.1.2 xts_0.12.1nlme_3.1-153 lifecycle_1.0.3 tibble_3.2.1 [11] gtable_0.3.3 lattice_0.20-45 pkgconfig_2.0.3 rlang_1.1.0 cli_3.6.1 [16] rstudioapi_0.14 curl_4.3.2xml2_1.3.3dplyr_1.1.1 generics_0.1.3 [21] vctrs_0.6.1 gridtext_0.1.5ggtext_0.1.2 lmtest_0.9-40 grid_4.1.2 [26] nnet_7.3-16 tidyselect_1.2.0 glue_1.6.2R6_2.5.1 fansi_1.0.4 [31] ggplot2_3.4.2 TTR_0.24.3magrittr_2.0.3scales_1.2.1 quantmod_0.4.20 [36] timeDate_4021.106 colorspace_2.1-0 fracdiff_1.5-1quadprog_1.5-8 utf8_1.2.3 [41] stinepack_1.4 munsell_0.5.0 zoo_1.8-10 PLease Also note: arfima(c(45.4, 3.25, 6.5, 2.149998)) Call: arfima(y = c(45.4, 3.25, 6.5, 2.149998)) Coefficients: d 4.583013e-05 sigma[eps] = 18.01252 a list with components: [1] "log.likelihood" "n" "msg" "d" "ar" [6] "ma" "covariance.dpq" "fnormMin""sigma" "stderror.dpq" [11] "correlation.dpq" "h" "d.tol" "M" "hessian.dpq" [16] "length.w""residuals" "fitted" "call""x" [21] "series" Many thanks in advance Thanking you, Yours sincerely, AKSHAY M KULKARNI From: Martin Maechler Sent: Thursday, June 1, 2023 1:28 PM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] error in arfima... >>>>> akshay kulkarni >>>>> on Wed, 31 May 2023 20:55:33 + writes: > dear members, > I am using arfima() from forecast package to model a time > series. The following is the code: >> LYGH[[202]] > [1] 45.40 3.25 6.50 2.15 >> arfima(LYGH[[202]]) > Error in .fdcov(x, fdf$d, h, nar = nar, nma = nma, hess = hess, fdf.work = fdf$w) : > NA/NaN/Inf in foreign function call (arg 5) > I tried viewing .fdcov() with the following code: > View(environment(fracdiff)$.fdcov) > but I see no stop() with the above mentioned error message. > Can you please help? Well, as I am the maintainer of the *fracdiff* package, I'm trying. OTOH, as we will see below, you did not give us enough information to really help you... > THanking you, > Yours sincerely, > AKSHAY M KULKARNI Your problem is not (yet) reproducible (*) I've done the following in an "empty" (i.e. freshly started) R session, R 4.3.0: begin_R_transcript___save_as__arfima-ex.Rout__-- > > lN <- loadedNamespaces() > library(forecast) Registered S3 method overwritten by 'quantmod': method
Re: [R] error in arfima...
> akshay kulkarni > on Wed, 31 May 2023 20:55:33 + writes: > dear members, > I am using arfima() from forecast package to model a time > series. The following is the code: >> LYGH[[202]] > [1] 45.40 3.25 6.50 2.15 >> arfima(LYGH[[202]]) > Error in .fdcov(x, fdf$d, h, nar = nar, nma = nma, hess = hess, fdf.work = fdf$w) : > NA/NaN/Inf in foreign function call (arg 5) > I tried viewing .fdcov() with the following code: > View(environment(fracdiff)$.fdcov) > but I see no stop() with the above mentioned error message. > Can you please help? Well, as I am the maintainer of the *fracdiff* package, I'm trying. OTOH, as we will see below, you did not give us enough information to really help you... > THanking you, > Yours sincerely, > AKSHAY M KULKARNI Your problem is not (yet) reproducible (*) I've done the following in an "empty" (i.e. freshly started) R session, R 4.3.0: begin_R_transcript___save_as__arfima-ex.Rout__-- > > lN <- loadedNamespaces() > library(forecast) Registered S3 method overwritten by 'quantmod': methodfrom as.zoo.data.frame zoo > options(width=75) > setdiff(loadedNamespaces(), lN) # -- see all the *!^@...! forecast loads: [1] "gtable" "dplyr" "tidyselect" "Rcpp" "parallel" [6] "scales" "lattice""ggplot2""R6" "generics" [11] "curl" "lmtest" "tibble" "munsell""nnet" [16] "forecast" "timeDate" "pillar" "rlang" "quantmod" [21] "utf8" "urca" "quadprog" "cli""magrittr" [26] "xts""grid" "nlme" "lifecycle" "fracdiff" [31] "vctrs" "glue" "tseries""zoo""fansi" [36] "colorspace" "TTR""pkgconfig" > arfima(c(45.40, 3.25, 6.50, 2.15)) Call: arfima(y = c(45.4, 3.25, 6.5, 2.15)) Coefficients: d 4.583013e-05 sigma[eps] = 18.01252 a list with components: [1] "log.likelihood" "n" "msg" [4] "d" "ar" "ma" [7] "covariance.dpq" "fnormMin""sigma" [10] "stderror.dpq""correlation.dpq" "h" [13] "d.tol" "M" "hessian.dpq" [16] "length.w""residuals" "fitted" [19] "call""x" "series" > > sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Fedora Linux 36 (Thirty Six) Matrix products: default BLAS: /usr/local64.sfs/app/R/R-4.3.0-inst/lib/libRblas.so LAPACK: /usr/lib64/liblapack.so.3.10.1 locale: [1] LC_CTYPE=de_CH.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=de_CH.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=de_CH.UTF-8 [7] LC_PAPER=de_CH.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C time zone: Europe/Zurich tzcode source: system (glibc) attached base packages: [1] graphics grDevices datasets stats utils methods base other attached packages: [1] forecast_8.21 fortunes_1.5-4 sfsmisc_1.1-15 loaded via a namespace (and not attached): [1] gtable_0.3.3 dplyr_1.1.2 compiler_4.3.0 [4] tidyselect_1.2.0 Rcpp_1.0.10 parallel_4.3.0 [7] scales_1.2.1 lattice_0.21-8ggplot2_3.4.2 [10] R6_2.5.1 generics_0.1.3curl_5.0.0 [13] lmtest_0.9-40 tibble_3.2.1 munsell_0.5.0 [16] nnet_7.3-19 timeDate_4022.108 pillar_1.9.0 [19] rlang_1.1.1 quantmod_0.4.22 utf8_1.2.3 [22] urca_1.3-3quadprog_1.5-8cli_3.6.1 [25] magrittr_2.0.3xts_0.13.1grid_4.3.0 [28] nlme_3.1-162 lifecycle_1.0.3 fracdiff_1.5-2 [31] vctrs_0.6.2 glue_1.6.2tseries_0.10-54 [34] zoo_1.8-12fansi_1.0.4 colorspace_2.1-0 [37] TTR_0.24.3tools_4.3.0 pkgconfig_2.0.3 > ##---end__R_transcript--- Note that your error message pointed me to my (old, but still fine) package {fracdiff} with its principal function fracdiff() around which arfima() is a user-friendly and generalization wrapper. In other words arfima() calls fracdiff::fracdiff() and the error happens there --- for you, but not for me, if I try to use the same data as you. I see that you must have found that too, because you mentioned View(environment(fracdiff)$.fdcov) Maybe you need to update.packages() {which should re-install R packages you have installed but which have become outdated in the mean time} If the error persists, please send us the output of 1) dput(LYGH[[202]]) so we get your exact data 2) sessionInfo() so we get much info about your R "setup" last but not least: If you are really calling ar
[R] error in arfima...
dear members, I am using arfima() from forecast package to model a time series. The following is the code: > LYGH[[202]] [1] 45.40 3.25 6.50 2.15 > arfima(LYGH[[202]]) Error in .fdcov(x, fdf$d, h, nar = nar, nma = nma, hess = hess, fdf.work = fdf$w) : NA/NaN/Inf in foreign function call (arg 5) I tried viewing .fdcov() with the following code: View(environment(fracdiff)$.fdcov) but I see no stop() with the above mentioned error message. Can you please help? THanking you, Yours sincerely, AKSHAY M KULKARNI [[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 when using 'optim' for numerical maximum likelihood
Às 06:28 de 14/05/2023, iguodala edwin via R-help escreveu: Good morning, How can I resolved error message New_X with convergence 1.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. Hello, Please include data and the code you tried in your questions to R-Help. We'll be glad to help but like this it is not possible to do so. Rui Barradas __ 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 when using 'optim' for numerical maximum likelihood
Good morning, How can I resolved error message New_X with convergence 1.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.
Re: [R] Error in as.POSIXlt.character(x, tz, ...)
В Thu, 11 May 2023 17:51:33 +0800 Jinsong Zhao пишет: > Both codes do not return NA on FreeBSD: > > > strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '') > [1] "1970-01-01 CST" > > strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '') > [1] "1970-01-01 CST" I must have misread the code of as.POSIXlt.character then. > I do not know how to use R's debugger... In short, debugonce(as.POSIXlt.character) will prepare R to start the debugger once the function is called. The debugger prompt is described in ?browser; it's mostly like R's prompt (you can call print(variable) and other, more complicated expressions), but there are special commands like "n" (next statement), "s" (step inside the function call) and so on. Call: debugonce(as.POSIXlt.character) as.POSIXct("1970-01-01 00:00.00 UTC") Use n to step over function calls and s to step inside for loops. See what's returned by strptime() calls inside this function. It's raising an exception because all of them contain NAs somewhere; which element is NA? What are the exact arguments used to call strptime()? This doesn't seem to be due to differences in locale: both CentOS and FreeBSD use en_US.UTF-8. -- Best regards, Ivan __ 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 as.POSIXlt.character(x, tz, ...)
The origin of this problem is when I try to update rstan package in R 4.3.0 on FreeBSD. I get the same error as that https://github.com/stan-dev/rstan/issues/612 However, I did not encounter this problem when using R 4.2.x or 4.1.x on FreeBSD. Best, Jinsong On 2023/5/11 16:56, Jinsong Zhao wrote: Hi there, When I run the following code in R 4.3.0 on FreeBSD, I got error. > as.POSIXct("1970-01-01 00:00.00 UTC") Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2 on a old CentOS. > as.POSIXct("1970-01-01 00:00.00 UTC") [1] "1970-01-01 CST" I confirmed that all the 3 OSes give the same time zone: > Sys.timezone() [1] "Asia/Shanghai" What's wrong with the R on FreeBSD? Any hint? Thanks in advance. Best, Jinsong __ 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 as.POSIXlt.character(x, tz, ...)
On 2023/5/11 17:22, Ivan Krylov wrote: В Thu, 11 May 2023 16:56:41 +0800 Jinsong Zhao пишет: When I run the following code in R 4.3.0 on FreeBSD, I got error. > as.POSIXct("1970-01-01 00:00.00 UTC") Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format Do strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '') and strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '') both return NA for you on FreeBSD? If not, can you trace the execution using R's debugger to see which parts are returned as NA, failing the test in as.POSIXlt.character? Both codes do not return NA on FreeBSD: > strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '') [1] "1970-01-01 CST" > strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '') [1] "1970-01-01 CST" I do not know how to use R's debugger... I think that strptime() should have discarded the trailing parts of the string and matched at least the beginning (though not the ".00 UTC" part because it doesn't correspond to the formats tried by strptime()). Moreover, there shouldn't be significant difference between the platforms, because R seems to always use an internal implementation of strptime(). Are you using a multi-byte locale? (What's your sessionInfo() on both a system where it works and the system where it fails?) The sessionInfo on FreeBSD said: tzcode source: system (FreeBSD) But on Windows it said: tzcode source: internal Could it be because of this? The sessionInfo on FreeBSD is: > sessionInfo() R version 4.3.0 (2023-04-21) Platform: amd64-portbld-freebsd13.1 (64-bit) Running under: FreeBSD xw6600 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64 Matrix products: default LAPACK: /usr/local/lib/R/lib/libRlapack.so.4.3.0; LAPACK version 3.11.0 locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 time zone: Asia/Shanghai tzcode source: system (FreeBSD) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 The sessionInfo on Windows is: > sessionInfo() R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22621) Matrix products: default locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 [2] LC_CTYPE=Chinese (Simplified)_China.utf8 [3] LC_MONETARY=Chinese (Simplified)_China.utf8 [4] LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.utf8 time zone: Asia/Shanghai tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 > The sessionInfo on CentOS is: > sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core) Matrix products: default BLAS: /home/jszhao/software/lib64/R/lib/libRblas.so LAPACK: /home/jszhao/software/lib64/R/lib/libRlapack.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.1.2 > __ 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 as.POSIXlt.character(x, tz, ...)
On 2023/5/11 17:24, Jeff Newmiller wrote: I find your claim suspect... a period is not interchangeable with a colon. Good catching, but In R 4.3.0 on FreeBSD, the same error after changing the period to a colon: > as.POSIXct("1970-01-01 00:00:00 UTC") Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format I copy the code from a web page. It works in R 4.3.0 on Windows and R 4.1.2 on an old CentOS. Best, Jinsong On May 11, 2023 1:56:41 AM PDT, Jinsong Zhao wrote: Hi there, When I run the following code in R 4.3.0 on FreeBSD, I got error. as.POSIXct("1970-01-01 00:00.00 UTC") Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2 on a old CentOS. as.POSIXct("1970-01-01 00:00.00 UTC") [1] "1970-01-01 CST" I confirmed that all the 3 OSes give the same time zone: Sys.timezone() [1] "Asia/Shanghai" What's wrong with the R on FreeBSD? Any hint? Thanks in advance. Best, Jinsong __ 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] Error in as.POSIXlt.character(x, tz, ...)
I find your claim suspect... a period is not interchangeable with a colon. On May 11, 2023 1:56:41 AM PDT, Jinsong Zhao wrote: >Hi there, > >When I run the following code in R 4.3.0 on FreeBSD, I got error. > >> as.POSIXct("1970-01-01 00:00.00 UTC") >Error in as.POSIXlt.character(x, tz, ...) : > character string is not in a standard unambiguous format > >The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2 on >a old CentOS. > >> as.POSIXct("1970-01-01 00:00.00 UTC") >[1] "1970-01-01 CST" > >I confirmed that all the 3 OSes give the same time zone: >> Sys.timezone() >[1] "Asia/Shanghai" > >What's wrong with the R on FreeBSD? Any hint? Thanks in advance. > >Best, >Jinsong > >__ >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. -- Sent from my phone. Please excuse my brevity. __ 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 as.POSIXlt.character(x, tz, ...)
В Thu, 11 May 2023 16:56:41 +0800 Jinsong Zhao пишет: > When I run the following code in R 4.3.0 on FreeBSD, I got error. > > > as.POSIXct("1970-01-01 00:00.00 UTC") > Error in as.POSIXlt.character(x, tz, ...) : >character string is not in a standard unambiguous format Do strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d %H:%M", '') and strptime("1970-01-01 00:00.00 UTC", "%Y-%m-%d", '') both return NA for you on FreeBSD? If not, can you trace the execution using R's debugger to see which parts are returned as NA, failing the test in as.POSIXlt.character? I think that strptime() should have discarded the trailing parts of the string and matched at least the beginning (though not the ".00 UTC" part because it doesn't correspond to the formats tried by strptime()). Moreover, there shouldn't be significant difference between the platforms, because R seems to always use an internal implementation of strptime(). Are you using a multi-byte locale? (What's your sessionInfo() on both a system where it works and the system where it fails?) -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in as.POSIXlt.character(x, tz, ...)
Hi there, When I run the following code in R 4.3.0 on FreeBSD, I got error. > as.POSIXct("1970-01-01 00:00.00 UTC") Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2 on a old CentOS. > as.POSIXct("1970-01-01 00:00.00 UTC") [1] "1970-01-01 CST" I confirmed that all the 3 OSes give the same time zone: > Sys.timezone() [1] "Asia/Shanghai" What's wrong with the R on FreeBSD? Any hint? Thanks in advance. Best, Jinsong __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in percentage stacked barplot
Dear all, I am trying to plot the following table in stacked barplot in percentages and also horizontal. Component Sample 1 Sample 2 Sample 3CaO 45 52 48SiO2 25 22 18Al2O3 15 11 14TiO2 6 5 6 Na2O 5 4 5CuO 3 3 5 Cl 1 3 4 When I tried the following functionbarplot(data, + main = "Stacked bar chart", + sub = "Subtitle", + xlab = "X-lab", + ylab = "Y-lab", + axes = TRUE, horiz = TRUE) I got the following error Error in barplot.default(hellisheidi, main = "Stacked bar chart", sub = "Subtitle", : 'height' must be a vector or a matrix I also tried barplot(as.matrix(hellisheidi)) but what I was getting was the three stacked columns for Samples 1, 2 and 3 but I was getting an empty column for Component, instead of being the variable in the Samples. I was hoping if you could help me on that. Thank you very much in advance. Kind regards,Maria __ 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 on using Confint function to calculate 95% CI
Thanks a lot for your response I managed to figure out the solution. There were some variables in my data which were not a part of the model but were interfering with the function. I removed those from my database and got the results Thanks! Sent from Yahoo Mail for iPhone On Wednesday, April 26, 2023, 5:14 AM, Michael Dewey wrote: I am afraid your post is more or less unreadable since you posted in HTML and this is a plain text list. It might also help if you gave more context like the full results of your model. There is a list dedicated to mixed models https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models which may be able to help you better. Michael On 26/04/2023 02:37, bharat rawlley via R-help wrote: > Hello, > > I am trying to estimate 95% CI using the confint function for a generalized > liner model. While I am able to estimate Odds ratio using the coef function > but on using the confint function, I get the message " Error in approx(sp$y, > sp$x, xout = cutoff) : need at least two non-NA values to interpolate" > The following are the Coefficients for which I am trying to calculate 95% CI. > The original data has no NA values so I am not sure why this error is showing > up > Estimate Std. Error z value Pr(>|z|)1.05649 0.30658 3.446 0.000569 > ***-0.58348 0.49948 -1.168 0.242744-0.77959 1.47292 -0.529 0.596609-18.50414 > 6522.63862 -0.003 0.997736-0.82328 0.49102 -1.677 0.093608 .-13.95852 > 4036.00271 -0.003 0.9972410.53909 0.83073 0.649 0.516376-0.55514 0.46189 > -1.202 0.22940817.75434 6522.63863 0.003 0.997828-15.97188 1051.20492 -0.015 > 0.987878-0.16589 0.43172 -0.384 0.70079231.60387 1459.11421 0.022 > 0.982719-0.42616 0.43637 -0.977 0.3287661.10179 1.19697 0.920 0.3573210.52345 > 1.23113 0.425 0.6707050.50791 1.54670 0.328 0.7426210.19881 0.34945 0.569 > 0.569403-0.07887 0.49769 -0.158 0.8740850.05958 0.36780 0.162 > 0.871306-0.61339 0.38503 -1.593 0.42 > I tried to compute 95% CI using the above coefficients using the cofit > function > Thank you! > > > > [[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. > -- Michael http://www.dewey.myzen.co.uk/home.html [[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 on using Confint function to calculate 95% CI
Are the numbers you provided multiple estimates of one coefficient or are they one estimate each of over 20 coefficients? -Original Message- From: R-help On Behalf Of Michael Dewey Sent: Wednesday, April 26, 2023 5:14 AM To: bharat rawlley ; r-help@R-project.org Subject: Re: [R] Error on using Confint function to calculate 95% CI [External Email] I am afraid your post is more or less unreadable since you posted in HTML and this is a plain text list. It might also help if you gave more context like the full results of your model. There is a list dedicated to mixed models https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models which may be able to help you better. Michael On 26/04/2023 02:37, bharat rawlley via R-help wrote: > Hello, > > I am trying to estimate 95% CI using the confint function for a generalized > liner model. While I am able to estimate Odds ratio using the coef function > but on using the confint function, I get the message " Error in approx(sp$y, > sp$x, xout = cutoff) : need at least two non-NA values to interpolate" > The following are the Coefficients for which I am trying to calculate 95% CI. > The original data has no NA values so I am not sure why this error is > showing up Estimate Std. Error z value Pr(>|z|)1.05649 0.30658 3.446 > 0.000569 ***-0.58348 0.49948 -1.168 0.242744-0.77959 1.47292 -0.529 > 0.596609-18.50414 6522.63862 -0.003 0.997736-0.82328 0.49102 -1.677 0.093608 > .-13.95852 4036.00271 -0.003 0.9972410.53909 0.83073 0.649 0.516376-0.55514 > 0.46189 -1.202 0.22940817.75434 6522.63863 0.003 0.997828-15.97188 1051.20492 > -0.015 0.987878-0.16589 0.43172 -0.384 0.70079231.60387 1459.11421 0.022 > 0.982719-0.42616 0.43637 -0.977 0.3287661.10179 1.19697 0.920 0.3573210.52345 > 1.23113 0.425 0.6707050.50791 1.54670 0.328 0.7426210.19881 0.34945 0.569 > 0.569403-0.07887 0.49769 -0.158 0.8740850.05958 0.36780 0.162 > 0.871306-0.61339 0.38503 -1.593 0.42 I tried to compute 95% CI using the > above coefficients using the cofit function Thank you! > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat/ > .ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C01%7Ctebert%40ufl.edu > %7Cf739f8c53ddd437c07ee08db46369b80%7C0d4da0f84a314d76ace60a62331e1b84 > %7C0%7C0%7C638180972584973688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sda > ta=puiwfHLnklY%2BasBERzyePEfX5DFw9Lsu1D5XmidwGlY%3D&reserved=0 > PLEASE do read the posting guide > http://www.r/ > -project.org%2Fposting-guide.html&data=05%7C01%7Ctebert%40ufl.edu%7Cf7 > 39f8c53ddd437c07ee08db46369b80%7C0d4da0f84a314d76ace60a62331e1b84%7C0% > 7C0%7C638180972584973688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL > CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=uh > Wtrk9PjUcZYY%2BOiVMIdjcpcIzBNwFgahW%2Bv2BfEuI%3D&reserved=0 > and provide commented, minimal, self-contained, reproducible code. > -- Michael http://www.dewey.myzen.co.uk/home.html __ 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] Error on using Confint function to calculate 95% CI
I am afraid your post is more or less unreadable since you posted in HTML and this is a plain text list. It might also help if you gave more context like the full results of your model. There is a list dedicated to mixed models https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models which may be able to help you better. Michael On 26/04/2023 02:37, bharat rawlley via R-help wrote: Hello, I am trying to estimate 95% CI using the confint function for a generalized liner model. While I am able to estimate Odds ratio using the coef function but on using the confint function, I get the message " Error in approx(sp$y, sp$x, xout = cutoff) : need at least two non-NA values to interpolate" The following are the Coefficients for which I am trying to calculate 95% CI. The original data has no NA values so I am not sure why this error is showing up Estimate Std. Error z value Pr(>|z|)1.05649 0.30658 3.446 0.000569 ***-0.58348 0.49948 -1.168 0.242744-0.77959 1.47292 -0.529 0.596609-18.50414 6522.63862 -0.003 0.997736-0.82328 0.49102 -1.677 0.093608 .-13.95852 4036.00271 -0.003 0.9972410.53909 0.83073 0.649 0.516376-0.55514 0.46189 -1.202 0.22940817.75434 6522.63863 0.003 0.997828-15.97188 1051.20492 -0.015 0.987878-0.16589 0.43172 -0.384 0.70079231.60387 1459.11421 0.022 0.982719-0.42616 0.43637 -0.977 0.3287661.10179 1.19697 0.920 0.3573210.52345 1.23113 0.425 0.6707050.50791 1.54670 0.328 0.7426210.19881 0.34945 0.569 0.569403-0.07887 0.49769 -0.158 0.8740850.05958 0.36780 0.162 0.871306-0.61339 0.38503 -1.593 0.42 I tried to compute 95% CI using the above coefficients using the cofit function Thank you! [[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. -- Michael http://www.dewey.myzen.co.uk/home.html __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error on using Confint function to calculate 95% CI
Hello, I am trying to estimate 95% CI using the confint function for a generalized liner model. While I am able to estimate Odds ratio using the coef function but on using the confint function, I get the message " Error in approx(sp$y, sp$x, xout = cutoff) : need at least two non-NA values to interpolate" The following are the Coefficients for which I am trying to calculate 95% CI. The original data has no NA values so I am not sure why this error is showing up Estimate Std. Error z value Pr(>|z|)1.05649 0.30658 3.446 0.000569 ***-0.58348 0.49948 -1.168 0.242744-0.77959 1.47292 -0.529 0.596609-18.50414 6522.63862 -0.003 0.997736-0.82328 0.49102 -1.677 0.093608 .-13.95852 4036.00271 -0.003 0.9972410.53909 0.83073 0.649 0.516376-0.55514 0.46189 -1.202 0.22940817.75434 6522.63863 0.003 0.997828-15.97188 1051.20492 -0.015 0.987878-0.16589 0.43172 -0.384 0.70079231.60387 1459.11421 0.022 0.982719-0.42616 0.43637 -0.977 0.3287661.10179 1.19697 0.920 0.3573210.52345 1.23113 0.425 0.6707050.50791 1.54670 0.328 0.7426210.19881 0.34945 0.569 0.569403-0.07887 0.49769 -0.158 0.8740850.05958 0.36780 0.162 0.871306-0.61339 0.38503 -1.593 0.42 I tried to compute 95% CI using the above coefficients using the cofit function Thank you! [[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] R-error
Please keep R-help in the "Copy" list. Please compose your messages in plain text, not HTML. On Thu, 13 Apr 2023 15:59:49 +0800 (GMT+08:00) "Dezhi Wang" wrote: > This is my config.log Please don't send any more screenshots. They are needlessly large and impossible to copy text from. You could have fit more than forty two thousand ASCII symbols in the space occupied by that 17 lines, and it would have been easier to work with. I cannot help you further without at least the backtrace, but it looks like you have a defect in your NSS installation. You need help from a CentOS expert or an NSS expert; there's nothing that can be fixed in R to make it work, short of getting a custom build of a different TLS library and a custom build of libcurl linked against said library, then linking your custom R build against this libcurl. (But then you're on the hook for updating both libraries when the inevitable security fixes start rolling in.) For RedHat-related problems, try r-sig-fed...@r-project.org, but if you don't give them enough information, they won't help you either. -- Best regards, Ivan __ 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-error
On Thu, 13 Apr 2023 14:53:14 +0800 (GMT+08:00) "Dezhi Wang" wrote: > [New Thread 0x7fffe660a700 (LWP 3791)] > [Thread 0x7fffe660a700 (LWP 3791) exited] > Program received signal SIGSEGV, Segmentation fault. > 0x7fffe50c0fe5 in intel_aes_gcmAAD () from > /lib64/libfreeblpriv3.so You didn't post the backtrace, so I don't have the full picture, but the crash seems to be happening in your TLS implementation (NSS), most likely because the AES GCM context pointer somehow turned out to be NULL. Is there a way to install a libcurl build linked with a different TLS back-end (e.g. OpenSSL)? How exactly did you install R? Please keep the Cc: r-help@R-project.org header in your e-mails (in order to let others find their solutions through the publicly available R-help archive). Please post in plain text, not HTML: https://www.r-project.org/mail.html#general-instructions -- Best regards, Ivan __ 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-error
On Wed, 12 Apr 2023 16:04:55 +0800 (GMT+08:00) "Dezhi Wang" wrote: > I run R 4.2.2 on CentOS-7.6. Thank you for this useful information. Could you tell us how this build of R was installed on this machine? > > install.packages('sf') > --- Please select a CRAN mirror for use in this session --- > *** caught segfault *** > address 0x60, cause 'memory not mapped' > Traceback: > 1: download.file(url, destfile = f, quiet = TRUE) The text error is fine, there's no need for an additional screenshot. Can you install the R development files (in particular, I'm interested in the debugging symbols, which must live in the R-debuginfo package, assuming you have installed R from a package) and the GNU debugger (gdb) on this machine? Once you have done that, run R using the command R -d gdb, start R using the "r" command, reproduce the crash and then post the backtrace that results from the "bt" command. -- Best regards, Ivan __ 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-error
Hello, I run R 4.2.2 on CentOS-7.6. I install package through install.packages("sf").It threw the above error: > install.packages('sf') --- Please select a CRAN mirror for use in this session --- *** caught segfault *** address 0x60, cause 'memory not mapped' Traceback: 1: download.file(url, destfile = f, quiet = TRUE) 2: doTryCatch(return(expr), name, parentenv, handler) 3: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 4: tryCatchList(expr, classes, parentenv, handlers) 5: tryCatch({ m <- download.file(url, destfile = f, quiet = TRUE) if (m != 0L) stop(gettextf("'download.file()' error code '%d'", m)) read.csv(f, as.is = TRUE, encoding = "UTF-8")}, error = function(err) { warning(gettextf("failed to download mirrors file (%s); using local file '%s'", conditionMessage(err), local.file), call. = FALSE, immediate. = TRUE) NULL}) 6: .getMirrors("https://cran.r-project.org/CRAN_mirrors.csv";, file.path(R.home("doc"), "CRAN_mirrors.csv"), all = all, local.only = local.only) 7: getCRANmirrors(all = FALSE, local.only = local.only) 8: chooseCRANmirror() 9: contrib.url(repos, type) 10: startsWith(contriburl, "file:") 11: install.packages("sf") Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: | | Dezhi Wang | | wangdezhist...@163.com |__ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: 'format_glimpse' is not an exported object from 'namespace:pillar'
Something in the code you're trying to run attempted to call pillar::format_glimpse [1]. The problem is, there's no format_glimpse in the version of pillar installed on your computer. The format_glimpse function appeared in pillar 1.5.1 [2]. Can you install a newer version of pillar? -- Best regards, Ivan [1] https://search.r-project.org/CRAN/refmans/pillar/html/format_glimpse.html [2] https://cran.r-project.org/web/packages/pillar/news/news.html __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error: 'format_glimpse' is not an exported object from 'namespace:pillar'
I am receiving the following error message. I don't understand what it means, and I don't know how to fix it. I am running my code in R studio. I do not know if the error comes from R or RStudio. Please see session data below, Thank you, John version data: platform x86_64-w64-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 3 minor 6.1 year 2019 month 07 day05 svn rev76782 language R version.string R version 3.6.1 (2019-07-05) nickname Action of the Toes Rstudio.version() $mode [1] "desktop" $version [1] ‘2023.3.0.386’ $long_version [1] "2023.03.0+386" $release_name [1] "Cherry Blossom" __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error: Invalid parent values
Hi, I hope that you are doing well. I am Md Hossain, trying to fit the ARIMAX model in RJAGS. However, I got an error message while I ran the code. Initially, I am using data obtained from R-package then I will implement it into real data. The code and error message are given below. library(rjags) load the data data("mtcars") select the response and predictor variables y <- mtcars$mpg x <- mtcars[,c("wt","qsec")] ### write the JAGS model code jags_arimax_model <- " model { beta0 ~ dnorm(0,0.0001) beta1 ~ dnorm(0,0.0001) beta2 ~ dnorm(0,0.0001) phi ~ dnorm(0,0.0001) tau ~ dgamma(0.001,0.001) # beta0a[1] <- beta0 beta1a[1] <- beta1 beta2a[1] <- beta2 phia[1] <- phi mu[1] <- beta0a + beta1a * x[1,1] + beta2a * x[1,2] + phia * y[2] ypred[1] ~ dnorm(mu[1], tau) ## for (i in 2:length(y)) { mu[i] <- beta0 + beta1 * x[i,1] + beta2 * x[i,2] + phi * y[i-1] ypred[i] ~ dnorm(mu[i], tau) } } " Fit the Bayesian ARIMAX model using JAGS: jags_arimax_fit <- jags.model(textConnection(jags_arimax_model), data = list(y = y, x = x) ) update(jags_arimax_fit, n.iter=2000, thin=1) output_arimax=coda.samples(model=jags_arimax_fit, variable.names="ypred", n.iter=2000, thin=5) However, I got the following error message. *Error in update.jags(model, n.iter, ...) : Error in node ypred[1]Invalid parent values* Please help me in this regard. Thanks in advance. Hossain [[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 in exists.....
Dear Bert, Thanks for sharing your views... THanking you, Yours sincerely, AKSHAY M KULKARNI From: Bert Gunter Sent: Wednesday, December 28, 2022 12:28 AM To: akshay kulkarni Cc: Sarah Goslee ; R help Mailing list Subject: Re: [R] error in exists. There is no substitute for experience/knowledge; nor any universally optimal strategy for debugging. But using the debugging tools that R provides -- ?debug, ?traceback, ?recover (e.g. in the form of options(error = utils::recover) ) -- should always be the first goto (or maybe the second after carefully re-reading relevant Help docs). However, the debugging tools would not have helped here afaics. -- Bert On Tue, Dec 27, 2022 at 10:22 AM akshay kulkarni wrote: > > Dear Bert, >Yeah, it's workingSometimes (only sometimes) I feel > that I am troubling this list with very simple questions the answer to which > I always happen to find myself a little after...any solutions for that (you > seem to be an omniscient person)!? > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > > From: Bert Gunter > Sent: Tuesday, December 27, 2022 11:39 PM > To: akshay kulkarni > Cc: Sarah Goslee ; R help Mailing list > > Subject: Re: [R] error in exists. > > You are confused about the list hierarchy. Perhaps this will explain: > > i <- 1 > > E <- new.env() > > E$L <- list() ## L is an empty list in E > > i <- 1 > >E$L[[i]]$T1A1 <- Sys.time() > Error in `*tmp*`[[i]] : subscript out of bounds > ## L is empty, so L[[1]] does not exist; is not a list; > ## cannot have a value assigned to a component > ## The following works: > ## Create an empty list as a sublist of L > > E$L[[1]] <- list() > ## Now create and assign to a component of the empty list > > E$L[[i]]$T1A1 <- Sys.time() > > E$L ## a list > [[1]] ## whose first component is a list > [[1]]$T1A1 ## T1A1 named component of L[[1]] > [1] "2022-12-27 10:00:10 PST" > > ergo, no conundra... (assuming I've understood you correctly) > > Cheers, > Bert > > On Tue, Dec 27, 2022 at 9:57 AM akshay kulkarni wrote: > > > > Dear Sarah, > > I had this also before the assignment of Sys.time(): > > > > > E$L[[i]] <- i > > > > After assignment of Sys.time(): > > > > > E$L > > [[1]] > > [[1]][[1]] > > [1] 1 > > > > [[1]]$T1A1 > > [1] "2022-12-27 22:40:02 IST" > > > > regrets for not sharing this ..Can you reproduce it now? > > > > Thanking you, > > Yours sincerely, > > AKSHAY M KULKARNI > > > > From: Sarah Goslee > > Sent: Tuesday, December 27, 2022 11:20 PM > > To: akshay kulkarni > > Cc: R help Mailing list > > Subject: Re: [R] error in exists. > > > > Hi, > > > > I can't create the desired object using the code you provided, but if > > I create it in two steps so that E$L[[i]]$T1A1 does exist, exist() > > returns TRUE. > > > > E <- new.env() > > E$L <- list() > > i <- 1 > > E$L[[i]]$T1A1 <- Sys.time() > > > > # returns: Error in `*tmp*`[[i]] : subscript out of bounds > > > > E$L[[i]] <- list() > > E$L[[i]]$T1A1 <- Sys.time() > > > > > > exists("T1A1", where = E$L[[i]]) > > # returns: [1] TRUE > > > > > > > str(E$L) > > List of 1 > > $ :List of 1 > > ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26" > > > > Sarah > > > > On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni > > wrote: > > > > > > Dear members, > > > I have the following code: > > > > E <- new.env() > > > > E$L <- list() > > > > i <- 1 > > > > E$L[[i]]$T1A1 <- Sys.time() > > > > exists("T1A1", where = E$L[[i]]) > > > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > > > attempt to use zero-length variable name > > > > > > I want the output of the exists() function to be TRUE. In any case: > > > > > > > E$L[[1]]$T1A1 > > > [1] "2022-12-27 22:40:02 IST" > > > > > > Please help me solve this conundrum > > > > > > Thanking you, > > > Yours sincerely, > > > AKSHAY M KULKARNI > > > > > > > > > [[alterna
Re: [R] error in exists.....
There is no substitute for experience/knowledge; nor any universally optimal strategy for debugging. But using the debugging tools that R provides -- ?debug, ?traceback, ?recover (e.g. in the form of options(error = utils::recover) ) -- should always be the first goto (or maybe the second after carefully re-reading relevant Help docs). However, the debugging tools would not have helped here afaics. -- Bert On Tue, Dec 27, 2022 at 10:22 AM akshay kulkarni wrote: > > Dear Bert, >Yeah, it's workingSometimes (only sometimes) I feel > that I am troubling this list with very simple questions the answer to which > I always happen to find myself a little after...any solutions for that (you > seem to be an omniscient person)!? > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > > From: Bert Gunter > Sent: Tuesday, December 27, 2022 11:39 PM > To: akshay kulkarni > Cc: Sarah Goslee ; R help Mailing list > > Subject: Re: [R] error in exists. > > You are confused about the list hierarchy. Perhaps this will explain: > > i <- 1 > > E <- new.env() > > E$L <- list() ## L is an empty list in E > > i <- 1 > >E$L[[i]]$T1A1 <- Sys.time() > Error in `*tmp*`[[i]] : subscript out of bounds > ## L is empty, so L[[1]] does not exist; is not a list; > ## cannot have a value assigned to a component > ## The following works: > ## Create an empty list as a sublist of L > > E$L[[1]] <- list() > ## Now create and assign to a component of the empty list > > E$L[[i]]$T1A1 <- Sys.time() > > E$L ## a list > [[1]] ## whose first component is a list > [[1]]$T1A1 ## T1A1 named component of L[[1]] > [1] "2022-12-27 10:00:10 PST" > > ergo, no conundra... (assuming I've understood you correctly) > > Cheers, > Bert > > On Tue, Dec 27, 2022 at 9:57 AM akshay kulkarni wrote: > > > > Dear Sarah, > > I had this also before the assignment of Sys.time(): > > > > > E$L[[i]] <- i > > > > After assignment of Sys.time(): > > > > > E$L > > [[1]] > > [[1]][[1]] > > [1] 1 > > > > [[1]]$T1A1 > > [1] "2022-12-27 22:40:02 IST" > > > > regrets for not sharing this ..Can you reproduce it now? > > > > Thanking you, > > Yours sincerely, > > AKSHAY M KULKARNI > > > > From: Sarah Goslee > > Sent: Tuesday, December 27, 2022 11:20 PM > > To: akshay kulkarni > > Cc: R help Mailing list > > Subject: Re: [R] error in exists. > > > > Hi, > > > > I can't create the desired object using the code you provided, but if > > I create it in two steps so that E$L[[i]]$T1A1 does exist, exist() > > returns TRUE. > > > > E <- new.env() > > E$L <- list() > > i <- 1 > > E$L[[i]]$T1A1 <- Sys.time() > > > > # returns: Error in `*tmp*`[[i]] : subscript out of bounds > > > > E$L[[i]] <- list() > > E$L[[i]]$T1A1 <- Sys.time() > > > > > > exists("T1A1", where = E$L[[i]]) > > # returns: [1] TRUE > > > > > > > str(E$L) > > List of 1 > > $ :List of 1 > > ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26" > > > > Sarah > > > > On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni > > wrote: > > > > > > Dear members, > > > I have the following code: > > > > E <- new.env() > > > > E$L <- list() > > > > i <- 1 > > > > E$L[[i]]$T1A1 <- Sys.time() > > > > exists("T1A1", where = E$L[[i]]) > > > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > > > attempt to use zero-length variable name > > > > > > I want the output of the exists() function to be TRUE. In any case: > > > > > > > E$L[[1]]$T1A1 > > > [1] "2022-12-27 22:40:02 IST" > > > > > > Please help me solve this conundrum > > > > > > Thanking you, > > > Yours sincerely, > > > AKSHAY M KULKARNI > > > > > > > > > [[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. > > > > > > > > -- > > Sarah Goslee (she/her) > > http://www.numberwright.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. __ 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 exists.....
Dear Bert, Yeah, it's workingSometimes (only sometimes) I feel that I am troubling this list with very simple questions the answer to which I always happen to find myself a little after...any solutions for that (you seem to be an omniscient person)!? Thanking you, Yours sincerely, AKSHAY M KULKARNI From: Bert Gunter Sent: Tuesday, December 27, 2022 11:39 PM To: akshay kulkarni Cc: Sarah Goslee ; R help Mailing list Subject: Re: [R] error in exists. You are confused about the list hierarchy. Perhaps this will explain: > i <- 1 > E <- new.env() > E$L <- list() ## L is an empty list in E > i <- 1 >E$L[[i]]$T1A1 <- Sys.time() Error in `*tmp*`[[i]] : subscript out of bounds ## L is empty, so L[[1]] does not exist; is not a list; ## cannot have a value assigned to a component ## The following works: ## Create an empty list as a sublist of L > E$L[[1]] <- list() ## Now create and assign to a component of the empty list > E$L[[i]]$T1A1 <- Sys.time() > E$L ## a list [[1]] ## whose first component is a list [[1]]$T1A1 ## T1A1 named component of L[[1]] [1] "2022-12-27 10:00:10 PST" ergo, no conundra... (assuming I've understood you correctly) Cheers, Bert On Tue, Dec 27, 2022 at 9:57 AM akshay kulkarni wrote: > > Dear Sarah, > I had this also before the assignment of Sys.time(): > > > E$L[[i]] <- i > > After assignment of Sys.time(): > > > E$L > [[1]] > [[1]][[1]] > [1] 1 > > [[1]]$T1A1 > [1] "2022-12-27 22:40:02 IST" > > regrets for not sharing this ..Can you reproduce it now? > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > ________ > From: Sarah Goslee > Sent: Tuesday, December 27, 2022 11:20 PM > To: akshay kulkarni > Cc: R help Mailing list > Subject: Re: [R] error in exists. > > Hi, > > I can't create the desired object using the code you provided, but if > I create it in two steps so that E$L[[i]]$T1A1 does exist, exist() > returns TRUE. > > E <- new.env() > E$L <- list() > i <- 1 > E$L[[i]]$T1A1 <- Sys.time() > > # returns: Error in `*tmp*`[[i]] : subscript out of bounds > > E$L[[i]] <- list() > E$L[[i]]$T1A1 <- Sys.time() > > > exists("T1A1", where = E$L[[i]]) > # returns: [1] TRUE > > > > str(E$L) > List of 1 > $ :List of 1 > ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26" > > Sarah > > On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni > wrote: > > > > Dear members, > > I have the following code: > > > E <- new.env() > > > E$L <- list() > > > i <- 1 > > > E$L[[i]]$T1A1 <- Sys.time() > > > exists("T1A1", where = E$L[[i]]) > > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > > attempt to use zero-length variable name > > > > I want the output of the exists() function to be TRUE. In any case: > > > > > E$L[[1]]$T1A1 > > [1] "2022-12-27 22:40:02 IST" > > > > Please help me solve this conundrum > > > > Thanking you, > > Yours sincerely, > > AKSHAY M KULKARNI > > > > > > [[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. > > > > -- > Sarah Goslee (she/her) > http://www.numberwright.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. [[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 in exists.....
You are confused about the list hierarchy. Perhaps this will explain: > i <- 1 > E <- new.env() > E$L <- list() ## L is an empty list in E > i <- 1 >E$L[[i]]$T1A1 <- Sys.time() Error in `*tmp*`[[i]] : subscript out of bounds ## L is empty, so L[[1]] does not exist; is not a list; ## cannot have a value assigned to a component ## The following works: ## Create an empty list as a sublist of L > E$L[[1]] <- list() ## Now create and assign to a component of the empty list > E$L[[i]]$T1A1 <- Sys.time() > E$L ## a list [[1]] ## whose first component is a list [[1]]$T1A1 ## T1A1 named component of L[[1]] [1] "2022-12-27 10:00:10 PST" ergo, no conundra... (assuming I've understood you correctly) Cheers, Bert On Tue, Dec 27, 2022 at 9:57 AM akshay kulkarni wrote: > > Dear Sarah, > I had this also before the assignment of Sys.time(): > > > E$L[[i]] <- i > > After assignment of Sys.time(): > > > E$L > [[1]] > [[1]][[1]] > [1] 1 > > [[1]]$T1A1 > [1] "2022-12-27 22:40:02 IST" > > regrets for not sharing this ..Can you reproduce it now? > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > ____ > From: Sarah Goslee > Sent: Tuesday, December 27, 2022 11:20 PM > To: akshay kulkarni > Cc: R help Mailing list > Subject: Re: [R] error in exists. > > Hi, > > I can't create the desired object using the code you provided, but if > I create it in two steps so that E$L[[i]]$T1A1 does exist, exist() > returns TRUE. > > E <- new.env() > E$L <- list() > i <- 1 > E$L[[i]]$T1A1 <- Sys.time() > > # returns: Error in `*tmp*`[[i]] : subscript out of bounds > > E$L[[i]] <- list() > E$L[[i]]$T1A1 <- Sys.time() > > > exists("T1A1", where = E$L[[i]]) > # returns: [1] TRUE > > > > str(E$L) > List of 1 > $ :List of 1 > ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26" > > Sarah > > On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni > wrote: > > > > Dear members, > > I have the following code: > > > E <- new.env() > > > E$L <- list() > > > i <- 1 > > > E$L[[i]]$T1A1 <- Sys.time() > > > exists("T1A1", where = E$L[[i]]) > > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > > attempt to use zero-length variable name > > > > I want the output of the exists() function to be TRUE. In any case: > > > > > E$L[[1]]$T1A1 > > [1] "2022-12-27 22:40:02 IST" > > > > Please help me solve this conundrum > > > > Thanking you, > > Yours sincerely, > > AKSHAY M KULKARNI > > > > > > [[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. > > > > -- > Sarah Goslee (she/her) > http://www.numberwright.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. __ 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 exists.....
You might try `hasName` instead of `exists` since `exists` is designed for environments and `hasName` for objects (like lists). Note that the order of the arguments is switched between the 2 functions. This does the same thing as Andrew Simmons' answer, but is a little bit shorter. On Tue, Dec 27, 2022 at 10:36 AM akshay kulkarni wrote: > > Dear members, > I have the following code: > > E <- new.env() > > E$L <- list() > > i <- 1 > > E$L[[i]]$T1A1 <- Sys.time() > > exists("T1A1", where = E$L[[i]]) > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > attempt to use zero-length variable name > > I want the output of the exists() function to be TRUE. In any case: > > > E$L[[1]]$T1A1 > [1] "2022-12-27 22:40:02 IST" > > Please help me solve this conundrum > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > > > [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@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.
Re: [R] error in exists.....
Dear Sarah, I had this also before the assignment of Sys.time(): > E$L[[i]] <- i After assignment of Sys.time(): > E$L [[1]] [[1]][[1]] [1] 1 [[1]]$T1A1 [1] "2022-12-27 22:40:02 IST" regrets for not sharing this ..Can you reproduce it now? Thanking you, Yours sincerely, AKSHAY M KULKARNI From: Sarah Goslee Sent: Tuesday, December 27, 2022 11:20 PM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] error in exists. Hi, I can't create the desired object using the code you provided, but if I create it in two steps so that E$L[[i]]$T1A1 does exist, exist() returns TRUE. E <- new.env() E$L <- list() i <- 1 E$L[[i]]$T1A1 <- Sys.time() # returns: Error in `*tmp*`[[i]] : subscript out of bounds E$L[[i]] <- list() E$L[[i]]$T1A1 <- Sys.time() exists("T1A1", where = E$L[[i]]) # returns: [1] TRUE > str(E$L) List of 1 $ :List of 1 ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26" Sarah On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni wrote: > > Dear members, > I have the following code: > > E <- new.env() > > E$L <- list() > > i <- 1 > > E$L[[i]]$T1A1 <- Sys.time() > > exists("T1A1", where = E$L[[i]]) > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > attempt to use zero-length variable name > > I want the output of the exists() function to be TRUE. In any case: > > > E$L[[1]]$T1A1 > [1] "2022-12-27 22:40:02 IST" > > Please help me solve this conundrum > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > > > [[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. -- Sarah Goslee (she/her) http://www.numberwright.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.
Re: [R] error in exists.....
Hi, I can't create the desired object using the code you provided, but if I create it in two steps so that E$L[[i]]$T1A1 does exist, exist() returns TRUE. E <- new.env() E$L <- list() i <- 1 E$L[[i]]$T1A1 <- Sys.time() # returns: Error in `*tmp*`[[i]] : subscript out of bounds E$L[[i]] <- list() E$L[[i]]$T1A1 <- Sys.time() exists("T1A1", where = E$L[[i]]) # returns: [1] TRUE > str(E$L) List of 1 $ :List of 1 ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26" Sarah On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni wrote: > > Dear members, > I have the following code: > > E <- new.env() > > E$L <- list() > > i <- 1 > > E$L[[i]]$T1A1 <- Sys.time() > > exists("T1A1", where = E$L[[i]]) > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > attempt to use zero-length variable name > > I want the output of the exists() function to be TRUE. In any case: > > > E$L[[1]]$T1A1 > [1] "2022-12-27 22:40:02 IST" > > Please help me solve this conundrum > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > > > [[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. -- Sarah Goslee (she/her) http://www.numberwright.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error in exists.....
exists() is for bindings in an environment, not for names in a list. try "T1A1" %in% names(E$L[[i]]) instead On Tue, Dec 27, 2022, 12:36 akshay kulkarni wrote: > Dear members, > I have the following code: > > E <- new.env() > > E$L <- list() > > i <- 1 > > E$L[[i]]$T1A1 <- Sys.time() > > exists("T1A1", where = E$L[[i]]) > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : > attempt to use zero-length variable name > > I want the output of the exists() function to be TRUE. In any case: > > > E$L[[1]]$T1A1 > [1] "2022-12-27 22:40:02 IST" > > Please help me solve this conundrum > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error in exists.....
Dear members, I have the following code: > E <- new.env() > E$L <- list() > i <- 1 > E$L[[i]]$T1A1 <- Sys.time() > exists("T1A1", where = E$L[[i]]) Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) : attempt to use zero-length variable name I want the output of the exists() function to be TRUE. In any case: > E$L[[1]]$T1A1 [1] "2022-12-27 22:40:02 IST" Please help me solve this conundrum Thanking you, Yours sincerely, AKSHAY M KULKARNI [[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 3221226505
Note that 3221226505 in base 10 is C409 in hexadecimal. You may have better luck looking for causes of this by googling the hex representation. -Bill On Sun, Dec 18, 2022 at 3:56 PM Mathurin, Gottfried via R-help < r-help@r-project.org> wrote: > Hello, > I currently face the issue of Windows 10 throwing a code 3221226505 > whenever I try to use R-4.1.3. > Is this issue known and could you possibly share a fix? > > Thank you in advance, > > *Gottfried* > > -- > > > This > > e-mail transmission (message and any attached files) may contain > information that is proprietary, privileged and/or confidential to Veolia > Environnement and/or its affiliates and is intended exclusively for the > person(s) to whom it is addressed. If you are not the intended recipient, > please notify the sender by return e-mail and delete all copies of this > e-mail, including all attachments. Unless expressly authorized, any use, > disclosure, publication, retransmission or dissemination of this e-mail > and/or of its attachments is strictly prohibited. > > > Ce message > electronique et ses fichiers attaches sont strictement confidentiels et > peuvent contenir des elements dont Veolia Environnement et/ou l'une de ses > entites affiliees sont proprietaires. Ils sont donc destines a l'usage de > leurs seuls destinataires. Si vous avez recu ce message par erreur, merci > de le retourner a son emetteur et de le detruire ainsi que toutes les > pieces attachees. L'utilisation, la divulgation, la publication, la > distribution, ou la reproduction non expressement autorisees de ce message > et de ses pieces attachees sont interdites. > > > > [[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] Error 3221226505
I cannot tell whether it would happen to me for two reasons: I don't use Windows anymore and R's current version is 4.2.1. You can determine whether it is the core packages that are throwing the error (rather unlikely) or perhaps something you have in your (invisible) .Rdata file. You should probably update your installation of R and throw away the .Rdata file that I suspect has gotten corrupted or is loading a flaky package. If you don't want to update R, then you should at the very least try to run R from a command line with > R --vanilla At least that's I what I remember from my Windows daze. You should also review the Win-R-FAQ which I think has similar advice. -- David On 12/18/22 16:20, Jeff Newmiller wrote: Doesn't happen to me. On December 16, 2022 12:44:17 AM PST, "Mathurin, Gottfried via R-help" wrote: Hello, I currently face the issue of Windows 10 throwing a code 3221226505 whenever I try to use R-4.1.3. Is this issue known and could you possibly share a fix? Thank you in advance, *Gottfried* __ 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 3221226505
Doesn't happen to me. On December 16, 2022 12:44:17 AM PST, "Mathurin, Gottfried via R-help" wrote: >Hello, >I currently face the issue of Windows 10 throwing a code 3221226505 >whenever I try to use R-4.1.3. >Is this issue known and could you possibly share a fix? > >Thank you in advance, > >*Gottfried* > -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error 3221226505
Hello, I currently face the issue of Windows 10 throwing a code 3221226505 whenever I try to use R-4.1.3. Is this issue known and could you possibly share a fix? Thank you in advance, *Gottfried* -- This e-mail transmission (message and any attached files) may contain information that is proprietary, privileged and/or confidential to Veolia Environnement and/or its affiliates and is intended exclusively for the person(s) to whom it is addressed. If you are not the intended recipient, please notify the sender by return e-mail and delete all copies of this e-mail, including all attachments. Unless expressly authorized, any use, disclosure, publication, retransmission or dissemination of this e-mail and/or of its attachments is strictly prohibited. Ce message electronique et ses fichiers attaches sont strictement confidentiels et peuvent contenir des elements dont Veolia Environnement et/ou l'une de ses entites affiliees sont proprietaires. Ils sont donc destines a l'usage de leurs seuls destinataires. Si vous avez recu ce message par erreur, merci de le retourner a son emetteur et de le detruire ainsi que toutes les pieces attachees. L'utilisation, la divulgation, la publication, la distribution, ou la reproduction non expressement autorisees de ce message et de ses pieces attachees sont interdites. [[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 in if (class(networks) == "matrix") from a function
Thank you Eric, Andrew, Rui and Martin for all your help and advice. I did learn some good practices under the new R version! Best, Chao On Thu, Sep 22, 2022 at 5:53 AM Martin Maechler wrote: > > Eric Berger > > on Wed, 21 Sep 2022 22:26:39 +0300 writes: > > > In R 4.2.0 there is a significant change. When you use an if() > statement > > with a condition of length > 1 this now reports an error. > > e.g. this link mentions it as a change > > https://www.jumpingrivers.com/blog/new-features-r420/ > > > In your case this is because class(obj) can return a character > vector of > > length > 1 (all the classes). > > One possible workaround would be: > > > if ( "matrix" %in% class(networks) ) ... > > Yes, however, in general, the recommendation in the related R > blog, > > would have been > > if(inherits(networks, "matrix")) > > which I consider better *correctly readable* (and also expect > to be more efficient). > > Lastly, in this special case, I'd try > > if(is.matrix(networks)) > > i.e., I'd try to see if the fast is.matrix(.) applies to your 'networks' > (and I'm guessing "yes" with high confidence ..). > > Martin > > > HTH, > > Eric > > > > On Wed, Sep 21, 2022 at 10:21 PM Chao Liu > wrote: > > >> Dear R-Help community, > >> > >> This is a crosspost on SO but I've had no luck so far. So I have a > function > >> which computes a centrality index for the nodes in a network or > matrix. > >> Here is the function: > >> > >> library(igraph) #load package igraph > >> centrality <- function (networks, type = c("indegree", "outdegree", > >> "freeman", > >> "betweenness", "flow", "closeness", "eigenvector", "information", > >> "load", "bonpow"), directed = TRUE, lag = 0, rescale = FALSE, > >> center = FALSE, coefname = NULL, ...) { > >> if (is.null(directed) || !is.logical(directed)) { > >> stop("'directed' must be TRUE or FALSE.") > >> } > >> else if (length(directed) != 1) { > >> stop("The 'directed' argument must contain a single logical > >> value only.") > >> } > >> else if (directed == FALSE) { > >> gmode <- "graph" > >> } > >> else { > >> gmode <- "digraph" > >> } > >> objects <- checkDataTypes(y = NULL, networks = networks, > >> lag = lag) > >> centlist <- list() > >> for (i in 1:objects$time.steps) { > >> if (type[1] == "indegree") { > >> cent <- degree(objects$networks[[i]], gmode = gmode, > >> cmode = "indegree", rescale = rescale, ...) > >> } > >> else if (type[1] == "outdegree") { > >> cent <- degree(objects$networks[[i]], gmode = gmode, > >> cmode = "outdegree", rescale = rescale, ...) > >> } > >> else if (type[1] == "freeman") { > >> cent <- degree(objects$networks[[i]], gmode = gmode, > >> cmode = "freeman", rescale = rescale, ...) > >> } > >> else if (type[1] == "betweenness") { > >> cent <- betweenness(objects$networks[[i]], gmode = gmode, > >> rescale = rescale, ...) > >> } > >> else if (type[1] == "flow") { > >> cent <- flowbet(objects$networks[[i]], gmode = gmode, > >> rescale = rescale, ...) > >> } > >> else if (type[1] == "closeness") { > >> cent <- closeness(objects$networks[[i]], gmode = gmode, > >> rescale = rescale, ...) > >> } > >> else if (type[1] == "eigenvector") { > >> cent <- evcent(objects$networks[[i]], gmode = gmode, > >> rescale = rescale, ...) > >> } > >> else if (type[1] == "information") { > >> cent <- infocent(objects$networks[[i]], gmode = gmode, > >> rescale = rescale, ...) > >> } > >> else if (type[1] == "load") { > >> cent <- loadcent(objects$networks[[i]], gmode = gmode, > >> rescale = rescale, ...) > >> } > >> else if (type[1] == "bonpow") { > >> cent <- bonpow(objects$networks[[i]], gmode = gmode, > >> rescale = rescale, tol = 1e-20, ...) > >> } > >> else { > >> stop("'type' argument was not recognized.") > >> } > >> centlist[[i]] <- cent > >> } > >> time <- numeric() > >> y <- numeric() > >> for (i in 1:objects$time.steps) { > >> time <- c(time, rep(i, objects$n[[i]])) > >> if (is.null(centlist[[i]])) { > >> y <- c(y, rep(NA, objects$n[[i]])) > >> } > >> else { > >> if (center == TRUE) { > >> centlist[[i]] <- centlist[[i]] - mean(centlist[[i]], > >> na.rm = TRUE) > >> } > >> y <- c(y, centlist[[i]]) > >> } > >> } > >> if (is.null(coefname) || !is.character(coefname) || > length(coefname) > > >> 1) { > >> coeflabel <- "" > >> } > >> else { > >> coeflabel <- paste0(".", coefname) > >> } > >> if (lag == 0) { > >> laglabel <- "" > >> } > >> else { > >> laglabel <- paste0(".lag", paste(lag, collapse = ".")) > >> } > >> label <- paste0(type[1], coeflabel, laglabel) > >> dat <- data.frame
Re: [R] Error in if (class(networks) == "matrix") from a function
> Eric Berger > on Wed, 21 Sep 2022 22:26:39 +0300 writes: > In R 4.2.0 there is a significant change. When you use an if() statement > with a condition of length > 1 this now reports an error. > e.g. this link mentions it as a change > https://www.jumpingrivers.com/blog/new-features-r420/ > In your case this is because class(obj) can return a character vector of > length > 1 (all the classes). > One possible workaround would be: > if ( "matrix" %in% class(networks) ) ... Yes, however, in general, the recommendation in the related R blog, would have been if(inherits(networks, "matrix")) which I consider better *correctly readable* (and also expect to be more efficient). Lastly, in this special case, I'd try if(is.matrix(networks)) i.e., I'd try to see if the fast is.matrix(.) applies to your 'networks' (and I'm guessing "yes" with high confidence ..). Martin > HTH, > Eric > On Wed, Sep 21, 2022 at 10:21 PM Chao Liu wrote: >> Dear R-Help community, >> >> This is a crosspost on SO but I've had no luck so far. So I have a function >> which computes a centrality index for the nodes in a network or matrix. >> Here is the function: >> >> library(igraph) #load package igraph >> centrality <- function (networks, type = c("indegree", "outdegree", >> "freeman", >> "betweenness", "flow", "closeness", "eigenvector", "information", >> "load", "bonpow"), directed = TRUE, lag = 0, rescale = FALSE, >> center = FALSE, coefname = NULL, ...) { >> if (is.null(directed) || !is.logical(directed)) { >> stop("'directed' must be TRUE or FALSE.") >> } >> else if (length(directed) != 1) { >> stop("The 'directed' argument must contain a single logical >> value only.") >> } >> else if (directed == FALSE) { >> gmode <- "graph" >> } >> else { >> gmode <- "digraph" >> } >> objects <- checkDataTypes(y = NULL, networks = networks, >> lag = lag) >> centlist <- list() >> for (i in 1:objects$time.steps) { >> if (type[1] == "indegree") { >> cent <- degree(objects$networks[[i]], gmode = gmode, >> cmode = "indegree", rescale = rescale, ...) >> } >> else if (type[1] == "outdegree") { >> cent <- degree(objects$networks[[i]], gmode = gmode, >> cmode = "outdegree", rescale = rescale, ...) >> } >> else if (type[1] == "freeman") { >> cent <- degree(objects$networks[[i]], gmode = gmode, >> cmode = "freeman", rescale = rescale, ...) >> } >> else if (type[1] == "betweenness") { >> cent <- betweenness(objects$networks[[i]], gmode = gmode, >> rescale = rescale, ...) >> } >> else if (type[1] == "flow") { >> cent <- flowbet(objects$networks[[i]], gmode = gmode, >> rescale = rescale, ...) >> } >> else if (type[1] == "closeness") { >> cent <- closeness(objects$networks[[i]], gmode = gmode, >> rescale = rescale, ...) >> } >> else if (type[1] == "eigenvector") { >> cent <- evcent(objects$networks[[i]], gmode = gmode, >> rescale = rescale, ...) >> } >> else if (type[1] == "information") { >> cent <- infocent(objects$networks[[i]], gmode = gmode, >> rescale = rescale, ...) >> } >> else if (type[1] == "load") { >> cent <- loadcent(objects$networks[[i]], gmode = gmode, >> rescale = rescale, ...) >> } >> else if (type[1] == "bonpow") { >> cent <- bonpow(objects$networks[[i]], gmode = gmode, >> rescale = rescale, tol = 1e-20, ...) >> } >> else { >> stop("'type' argument was not recognized.") >> } >> centlist[[i]] <- cent >> } >> time <- numeric() >> y <- numeric() >> for (i in 1:objects$time.steps) { >> time <- c(time, rep(i, objects$n[[i]])) >> if (is.null(centlist[[i]])) { >> y <- c(y, rep(NA, objects$n[[i]])) >> } >> else { >> if (center == TRUE) { >> centlist[[i]] <- centlist[[i]] - mean(centlist[[i]], >> na.rm = TRUE) >> } >> y <- c(y, centlist[[i]]) >> } >> } >> if (is.null(coefname) || !is.character(coefname) || length(coefname) > >> 1) { >> coeflabel <- "" >> } >> else { >> coeflabel <- paste0(".", coefname) >> } >> if (lag == 0) { >> laglabel <- "" >> } >> else { >> laglabel <- paste0(".lag", paste(lag, collapse = ".")) >> } >> label <- paste0(type[1], coeflabel, laglabel) >> dat <- data.frame(y, time = time, node = objects$nodelabels) >> dat$node <- as.character(dat$node) >> colnames(dat)[1] <- label >> attributes(dat)$lag <- lag >> return(dat)} >> >> Here is the matrix: >> >> dat <- read.table(text="A B #this is edgelist >> 1 2 >> 1 3 >> 1 2 >> 2 1 >> 2 3 >> 3 1 >> 3 2 >> 3 1", header=TRUE) >> datmat <- as.matrix(get.adjacency(graph.edgelist(as.matrix(dat), >> directed=TRUE))) #this is
Re: [R] Error in if (class(networks) == "matrix") from a function
Hello, In my previous I forgot that this, for matrices to have 2 classes , is relatively new. It was introduced in R 4.0.0. From the News file [1], point 2: R News [R logo] CHANGES IN 4.0.0 SIGNIFICANT USER-VISIBLE CHANGES matrix objects now also inherit from class "array", so e.g., class(diag(1)) is c("matrix", "array"). This invalidates code incorrectly assuming that class(matrix_obj)) has length one. So the R Core Team did an excelent job once again and warned R users. This was a major R version, where changes like this generally happen and are anounced with antecipation. (I remeber to have seen it but cannot place it.) Old code needs to be changed, it might break. [1] https://cran.r-project.org/bin/windows/base/old/4.0.0/NEWS.R-4.0.0.html Hope this helps, Rui Barradas Às 20:35 de 21/09/2022, Rui Barradas escreveu: Hello, Check what class(datmat) returns and use ?inherits instead. class(datmat) #[1] "matrix" "array" inherits(datmat, "matrix") #[1] TRUE Also, the error the posted code gives is centrality(datmat,type="flow",center=TRUE) Error in checkDataTypes(y = NULL, networks = networks, lag = lag) : could not find function "checkDataTypes" but I assume you have function checkDataTypes somewhere in your session, the problem should be solved with inherits(). Hope this helps, Rui Barradas Às 20:20 de 21/09/2022, Chao Liu escreveu: Dear R-Help community, This is a crosspost on SO but I've had no luck so far. So I have a function which computes a centrality index for the nodes in a network or matrix. Here is the function: library(igraph) #load package igraph centrality <- function (networks, type = c("indegree", "outdegree", "freeman", "betweenness", "flow", "closeness", "eigenvector", "information", "load", "bonpow"), directed = TRUE, lag = 0, rescale = FALSE, center = FALSE, coefname = NULL, ...) { if (is.null(directed) || !is.logical(directed)) { stop("'directed' must be TRUE or FALSE.") } else if (length(directed) != 1) { stop("The 'directed' argument must contain a single logical value only.") } else if (directed == FALSE) { gmode <- "graph" } else { gmode <- "digraph" } objects <- checkDataTypes(y = NULL, networks = networks, lag = lag) centlist <- list() for (i in 1:objects$time.steps) { if (type[1] == "indegree") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "indegree", rescale = rescale, ...) } else if (type[1] == "outdegree") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "outdegree", rescale = rescale, ...) } else if (type[1] == "freeman") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "freeman", rescale = rescale, ...) } else if (type[1] == "betweenness") { cent <- betweenness(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "flow") { cent <- flowbet(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "closeness") { cent <- closeness(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "eigenvector") { cent <- evcent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "information") { cent <- infocent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "load") { cent <- loadcent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "bonpow") { cent <- bonpow(objects$networks[[i]], gmode = gmode, rescale = rescale, tol = 1e-20, ...) } else { stop("'type' argument was not recognized.") } centlist[[i]] <- cent } time <- numeric() y <- numeric() for (i in 1:objects$time.steps) { time <- c(time, rep(i, objects$n[[i]])) if (is.null(centlist[[i]])) { y <- c(y, rep(NA, objects$n[[i]])) } else { if (center == TRUE) { centlist[[i]] <- centlist[[i]] - mean(centlist[[i]], na.rm = TRUE) } y <- c(y, centlist[[i]]) } } if (is.null(coefname) || !is.character(coefname) || length(coefname) > 1) { coeflabel <- "" } else { coeflabel <- paste0(".", coefname) } if (lag == 0) { laglabel <- "" } else { laglabel <- paste0(".lag", paste(lag, collapse = ".")) } label <- p
Re: [R] Error in if (class(networks) == "matrix") from a function
Hello, Check what class(datmat) returns and use ?inherits instead. class(datmat) #[1] "matrix" "array" inherits(datmat, "matrix") #[1] TRUE Also, the error the posted code gives is centrality(datmat,type="flow",center=TRUE) Error in checkDataTypes(y = NULL, networks = networks, lag = lag) : could not find function "checkDataTypes" but I assume you have function checkDataTypes somewhere in your session, the problem should be solved with inherits(). Hope this helps, Rui Barradas Às 20:20 de 21/09/2022, Chao Liu escreveu: Dear R-Help community, This is a crosspost on SO but I've had no luck so far. So I have a function which computes a centrality index for the nodes in a network or matrix. Here is the function: library(igraph) #load package igraph centrality <- function (networks, type = c("indegree", "outdegree", "freeman", "betweenness", "flow", "closeness", "eigenvector", "information", "load", "bonpow"), directed = TRUE, lag = 0, rescale = FALSE, center = FALSE, coefname = NULL, ...) { if (is.null(directed) || !is.logical(directed)) { stop("'directed' must be TRUE or FALSE.") } else if (length(directed) != 1) { stop("The 'directed' argument must contain a single logical value only.") } else if (directed == FALSE) { gmode <- "graph" } else { gmode <- "digraph" } objects <- checkDataTypes(y = NULL, networks = networks, lag = lag) centlist <- list() for (i in 1:objects$time.steps) { if (type[1] == "indegree") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "indegree", rescale = rescale, ...) } else if (type[1] == "outdegree") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "outdegree", rescale = rescale, ...) } else if (type[1] == "freeman") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "freeman", rescale = rescale, ...) } else if (type[1] == "betweenness") { cent <- betweenness(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "flow") { cent <- flowbet(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "closeness") { cent <- closeness(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "eigenvector") { cent <- evcent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "information") { cent <- infocent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "load") { cent <- loadcent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "bonpow") { cent <- bonpow(objects$networks[[i]], gmode = gmode, rescale = rescale, tol = 1e-20, ...) } else { stop("'type' argument was not recognized.") } centlist[[i]] <- cent } time <- numeric() y <- numeric() for (i in 1:objects$time.steps) { time <- c(time, rep(i, objects$n[[i]])) if (is.null(centlist[[i]])) { y <- c(y, rep(NA, objects$n[[i]])) } else { if (center == TRUE) { centlist[[i]] <- centlist[[i]] - mean(centlist[[i]], na.rm = TRUE) } y <- c(y, centlist[[i]]) } } if (is.null(coefname) || !is.character(coefname) || length(coefname) > 1) { coeflabel <- "" } else { coeflabel <- paste0(".", coefname) } if (lag == 0) { laglabel <- "" } else { laglabel <- paste0(".lag", paste(lag, collapse = ".")) } label <- paste0(type[1], coeflabel, laglabel) dat <- data.frame(y, time = time, node = objects$nodelabels) dat$node <- as.character(dat$node) colnames(dat)[1] <- label attributes(dat)$lag <- lag return(dat)} Here is the matrix: dat <- read.table(text="A B #this is edgelist 1 2 1 3 1 2 2 1 2 3 3 1 3 2 3 1", header=TRUE) datmat <- as.matrix(get.adjacency(graph.edgelist(as.matrix(dat), directed=TRUE))) #this is the matrix colnames(datmat) <- c("1", "2", "3") #rename the columns When I applied the function to a matrix centrality(datmat,type="flow",center=TRUE), it returns the error: Error in if (class(networks) == "matrix") { : the condition has length > 1 What is the cause of this error? How to fix it? Any help will be greatly appreciated! Best, Chao [[alternative HTML version deleted]]
Re: [R] Error in if (class(networks) == "matrix") from a function
In general, you should be using inherits(netwotks, "matrix") or is(networks, "matrix") instead of class() == Your function fails because your object has multiple classes so class== returns multiple logical values so if will fail. But inherits or is will return one logical value, so if will not raise an error. On Wed., Sep. 21, 2022, 15:21 Chao Liu, wrote: > Dear R-Help community, > > This is a crosspost on SO but I've had no luck so far. So I have a function > which computes a centrality index for the nodes in a network or matrix. > Here is the function: > > library(igraph) #load package igraph > centrality <- function (networks, type = c("indegree", "outdegree", > "freeman", > "betweenness", "flow", "closeness", "eigenvector", "information", > "load", "bonpow"), directed = TRUE, lag = 0, rescale = FALSE, > center = FALSE, coefname = NULL, ...) { > if (is.null(directed) || !is.logical(directed)) { > stop("'directed' must be TRUE or FALSE.") > } > else if (length(directed) != 1) { > stop("The 'directed' argument must contain a single logical > value only.") > } > else if (directed == FALSE) { > gmode <- "graph" > } > else { > gmode <- "digraph" > } > objects <- checkDataTypes(y = NULL, networks = networks, > lag = lag) > centlist <- list() > for (i in 1:objects$time.steps) { > if (type[1] == "indegree") { > cent <- degree(objects$networks[[i]], gmode = gmode, > cmode = "indegree", rescale = rescale, ...) > } > else if (type[1] == "outdegree") { > cent <- degree(objects$networks[[i]], gmode = gmode, > cmode = "outdegree", rescale = rescale, ...) > } > else if (type[1] == "freeman") { > cent <- degree(objects$networks[[i]], gmode = gmode, > cmode = "freeman", rescale = rescale, ...) > } > else if (type[1] == "betweenness") { > cent <- betweenness(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "flow") { > cent <- flowbet(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "closeness") { > cent <- closeness(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "eigenvector") { > cent <- evcent(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "information") { > cent <- infocent(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "load") { > cent <- loadcent(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "bonpow") { > cent <- bonpow(objects$networks[[i]], gmode = gmode, > rescale = rescale, tol = 1e-20, ...) > } > else { > stop("'type' argument was not recognized.") > } > centlist[[i]] <- cent > } > time <- numeric() > y <- numeric() > for (i in 1:objects$time.steps) { > time <- c(time, rep(i, objects$n[[i]])) > if (is.null(centlist[[i]])) { > y <- c(y, rep(NA, objects$n[[i]])) > } > else { > if (center == TRUE) { > centlist[[i]] <- centlist[[i]] - mean(centlist[[i]], > na.rm = TRUE) > } > y <- c(y, centlist[[i]]) > } > } > if (is.null(coefname) || !is.character(coefname) || length(coefname) > > 1) { > coeflabel <- "" > } > else { > coeflabel <- paste0(".", coefname) > } > if (lag == 0) { > laglabel <- "" > } > else { > laglabel <- paste0(".lag", paste(lag, collapse = ".")) > } > label <- paste0(type[1], coeflabel, laglabel) > dat <- data.frame(y, time = time, node = objects$nodelabels) > dat$node <- as.character(dat$node) > colnames(dat)[1] <- label > attributes(dat)$lag <- lag > return(dat)} > > Here is the matrix: > > dat <- read.table(text="A B #this is edgelist > 1 2 > 1 3 > 1 2 > 2 1 > 2 3 > 3 1 > 3 2 > 3 1", header=TRUE) > datmat <- as.matrix(get.adjacency(graph.edgelist(as.matrix(dat), > directed=TRUE))) #this is the matrix > colnames(datmat) <- c("1", "2", "3") #rename the columns > > When I applied the function to a matrix > centrality(datmat,type="flow",center=TRUE), it returns the error: > > Error in if (class(networks) == "matrix") { : > the condition has length > 1 > > What is the cause of this error? How to fix it? Any help will be greatly > appreciated! > > > Best, > > Chao > > [[alternative HTML version deleted]] > >
Re: [R] Error in if (class(networks) == "matrix") from a function
In R 4.2.0 there is a significant change. When you use an if() statement with a condition of length > 1 this now reports an error. e.g. this link mentions it as a change https://www.jumpingrivers.com/blog/new-features-r420/ In your case this is because class(obj) can return a character vector of length > 1 (all the classes). One possible workaround would be: if ( "matrix" %in% class(networks) ) ... HTH, Eric On Wed, Sep 21, 2022 at 10:21 PM Chao Liu wrote: > Dear R-Help community, > > This is a crosspost on SO but I've had no luck so far. So I have a function > which computes a centrality index for the nodes in a network or matrix. > Here is the function: > > library(igraph) #load package igraph > centrality <- function (networks, type = c("indegree", "outdegree", > "freeman", > "betweenness", "flow", "closeness", "eigenvector", "information", > "load", "bonpow"), directed = TRUE, lag = 0, rescale = FALSE, > center = FALSE, coefname = NULL, ...) { > if (is.null(directed) || !is.logical(directed)) { > stop("'directed' must be TRUE or FALSE.") > } > else if (length(directed) != 1) { > stop("The 'directed' argument must contain a single logical > value only.") > } > else if (directed == FALSE) { > gmode <- "graph" > } > else { > gmode <- "digraph" > } > objects <- checkDataTypes(y = NULL, networks = networks, > lag = lag) > centlist <- list() > for (i in 1:objects$time.steps) { > if (type[1] == "indegree") { > cent <- degree(objects$networks[[i]], gmode = gmode, > cmode = "indegree", rescale = rescale, ...) > } > else if (type[1] == "outdegree") { > cent <- degree(objects$networks[[i]], gmode = gmode, > cmode = "outdegree", rescale = rescale, ...) > } > else if (type[1] == "freeman") { > cent <- degree(objects$networks[[i]], gmode = gmode, > cmode = "freeman", rescale = rescale, ...) > } > else if (type[1] == "betweenness") { > cent <- betweenness(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "flow") { > cent <- flowbet(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "closeness") { > cent <- closeness(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "eigenvector") { > cent <- evcent(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "information") { > cent <- infocent(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "load") { > cent <- loadcent(objects$networks[[i]], gmode = gmode, > rescale = rescale, ...) > } > else if (type[1] == "bonpow") { > cent <- bonpow(objects$networks[[i]], gmode = gmode, > rescale = rescale, tol = 1e-20, ...) > } > else { > stop("'type' argument was not recognized.") > } > centlist[[i]] <- cent > } > time <- numeric() > y <- numeric() > for (i in 1:objects$time.steps) { > time <- c(time, rep(i, objects$n[[i]])) > if (is.null(centlist[[i]])) { > y <- c(y, rep(NA, objects$n[[i]])) > } > else { > if (center == TRUE) { > centlist[[i]] <- centlist[[i]] - mean(centlist[[i]], > na.rm = TRUE) > } > y <- c(y, centlist[[i]]) > } > } > if (is.null(coefname) || !is.character(coefname) || length(coefname) > > 1) { > coeflabel <- "" > } > else { > coeflabel <- paste0(".", coefname) > } > if (lag == 0) { > laglabel <- "" > } > else { > laglabel <- paste0(".lag", paste(lag, collapse = ".")) > } > label <- paste0(type[1], coeflabel, laglabel) > dat <- data.frame(y, time = time, node = objects$nodelabels) > dat$node <- as.character(dat$node) > colnames(dat)[1] <- label > attributes(dat)$lag <- lag > return(dat)} > > Here is the matrix: > > dat <- read.table(text="A B #this is edgelist > 1 2 > 1 3 > 1 2 > 2 1 > 2 3 > 3 1 > 3 2 > 3 1", header=TRUE) > datmat <- as.matrix(get.adjacency(graph.edgelist(as.matrix(dat), > directed=TRUE))) #this is the matrix > colnames(datmat) <- c("1", "2", "3") #rename the columns > > When I applied the function to a matrix > centrality(datmat,type="flow",center=TRUE), it returns the error: > > Error in if (class(networks) == "matrix") { : > the condition has length > 1 > > What is the cause of this error? How to fix it? Any help will be greatly > appreciated! > > >
[R] Error in if (class(networks) == "matrix") from a function
Dear R-Help community, This is a crosspost on SO but I've had no luck so far. So I have a function which computes a centrality index for the nodes in a network or matrix. Here is the function: library(igraph) #load package igraph centrality <- function (networks, type = c("indegree", "outdegree", "freeman", "betweenness", "flow", "closeness", "eigenvector", "information", "load", "bonpow"), directed = TRUE, lag = 0, rescale = FALSE, center = FALSE, coefname = NULL, ...) { if (is.null(directed) || !is.logical(directed)) { stop("'directed' must be TRUE or FALSE.") } else if (length(directed) != 1) { stop("The 'directed' argument must contain a single logical value only.") } else if (directed == FALSE) { gmode <- "graph" } else { gmode <- "digraph" } objects <- checkDataTypes(y = NULL, networks = networks, lag = lag) centlist <- list() for (i in 1:objects$time.steps) { if (type[1] == "indegree") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "indegree", rescale = rescale, ...) } else if (type[1] == "outdegree") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "outdegree", rescale = rescale, ...) } else if (type[1] == "freeman") { cent <- degree(objects$networks[[i]], gmode = gmode, cmode = "freeman", rescale = rescale, ...) } else if (type[1] == "betweenness") { cent <- betweenness(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "flow") { cent <- flowbet(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "closeness") { cent <- closeness(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "eigenvector") { cent <- evcent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "information") { cent <- infocent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "load") { cent <- loadcent(objects$networks[[i]], gmode = gmode, rescale = rescale, ...) } else if (type[1] == "bonpow") { cent <- bonpow(objects$networks[[i]], gmode = gmode, rescale = rescale, tol = 1e-20, ...) } else { stop("'type' argument was not recognized.") } centlist[[i]] <- cent } time <- numeric() y <- numeric() for (i in 1:objects$time.steps) { time <- c(time, rep(i, objects$n[[i]])) if (is.null(centlist[[i]])) { y <- c(y, rep(NA, objects$n[[i]])) } else { if (center == TRUE) { centlist[[i]] <- centlist[[i]] - mean(centlist[[i]], na.rm = TRUE) } y <- c(y, centlist[[i]]) } } if (is.null(coefname) || !is.character(coefname) || length(coefname) > 1) { coeflabel <- "" } else { coeflabel <- paste0(".", coefname) } if (lag == 0) { laglabel <- "" } else { laglabel <- paste0(".lag", paste(lag, collapse = ".")) } label <- paste0(type[1], coeflabel, laglabel) dat <- data.frame(y, time = time, node = objects$nodelabels) dat$node <- as.character(dat$node) colnames(dat)[1] <- label attributes(dat)$lag <- lag return(dat)} Here is the matrix: dat <- read.table(text="A B #this is edgelist 1 2 1 3 1 2 2 1 2 3 3 1 3 2 3 1", header=TRUE) datmat <- as.matrix(get.adjacency(graph.edgelist(as.matrix(dat), directed=TRUE))) #this is the matrix colnames(datmat) <- c("1", "2", "3") #rename the columns When I applied the function to a matrix centrality(datmat,type="flow",center=TRUE), it returns the error: Error in if (class(networks) == "matrix") { : the condition has length > 1 What is the cause of this error? How to fix it? Any help will be greatly appreciated! Best, Chao [[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 Running arules
Hello, Before removing all of R, why not run update.packages() ? Hope this helps, Rui Barradas Às 17:14 de 04/09/2022, Stephen H. Dawson, DSL via R-help escreveu: I contacted the arules package maintainer. He concluded the syntax I submitted to this original post is correct. The problem he estimates is a version mismatch within my R packages, although all packages I am using come from R repositories. Specifically, something is off on the r-base version I am running. I will remove all of R from my box and look to other repositories. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 12:50, Stephen H. Dawson, DSL via R-help wrote: Go it, thanks. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 12:46, Bert Gunter wrote: 1. I told you essentially everything there is to know. 2. Chapter 13.3 of "An Introduction to R" on 'namespaces'. 3. Search on "masking in R" Bert On Fri, Sep 2, 2022 at 9:01 AM Stephen H. Dawson, DSL wrote: Bert, Thanks for the guidance. Do you have a documentation URL I can review to research your suggestion? Ivan, Thanks for the guidance. The traceback() revealed the same results that I shared originally. This is a bigger problem than coding a command set to run against data. It does seem like a version problem with arules or how it leverages r-base. I will go to arules maintainer for further guidance. Kindest Regards, *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 03:09, Ivan Krylov wrote: В Thu, 1 Sep 2022 11:45:15 -0400 "Stephen H. Dawson, DSL via R-help" пишет: Error in eval(ei, envir) : object 'Insert' not found traceback() is invaluable when debugging errors like this. It might be a bug in one of the packages you're running. You might end up having to contact the maintainer (see the maintainer() function) of one of them to have it fixed. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error Running arules
I contacted the arules package maintainer. He concluded the syntax I submitted to this original post is correct. The problem he estimates is a version mismatch within my R packages, although all packages I am using come from R repositories. Specifically, something is off on the r-base version I am running. I will remove all of R from my box and look to other repositories. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 12:50, Stephen H. Dawson, DSL via R-help wrote: Go it, thanks. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 12:46, Bert Gunter wrote: 1. I told you essentially everything there is to know. 2. Chapter 13.3 of "An Introduction to R" on 'namespaces'. 3. Search on "masking in R" Bert On Fri, Sep 2, 2022 at 9:01 AM Stephen H. Dawson, DSL wrote: Bert, Thanks for the guidance. Do you have a documentation URL I can review to research your suggestion? Ivan, Thanks for the guidance. The traceback() revealed the same results that I shared originally. This is a bigger problem than coding a command set to run against data. It does seem like a version problem with arules or how it leverages r-base. I will go to arules maintainer for further guidance. Kindest Regards, *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 03:09, Ivan Krylov wrote: В Thu, 1 Sep 2022 11:45:15 -0400 "Stephen H. Dawson, DSL via R-help" пишет: Error in eval(ei, envir) : object 'Insert' not found traceback() is invaluable when debugging errors like this. It might be a bug in one of the packages you're running. You might end up having to contact the maintainer (see the maintainer() function) of one of them to have it fixed. __ 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] Error Running arules
Go it, thanks. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 12:46, Bert Gunter wrote: 1. I told you essentially everything there is to know. 2. Chapter 13.3 of "An Introduction to R" on 'namespaces'. 3. Search on "masking in R" Bert On Fri, Sep 2, 2022 at 9:01 AM Stephen H. Dawson, DSL wrote: Bert, Thanks for the guidance. Do you have a documentation URL I can review to research your suggestion? Ivan, Thanks for the guidance. The traceback() revealed the same results that I shared originally. This is a bigger problem than coding a command set to run against data. It does seem like a version problem with arules or how it leverages r-base. I will go to arules maintainer for further guidance. Kindest Regards, *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 9/2/22 03:09, Ivan Krylov wrote: В Thu, 1 Sep 2022 11:45:15 -0400 "Stephen H. Dawson, DSL via R-help" пишет: Error in eval(ei, envir) : object 'Insert' not found traceback() is invaluable when debugging errors like this. It might be a bug in one of the packages you're running. You might end up having to contact the maintainer (see the maintainer() function) of one of them to have it fixed. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error Running arules
Hi Everyone, I upgraded my box recently. I am now running R at version 4.2. I attempted to do association rules today using arules. I am getting two errors. My first guess is there is something in the build of the arules that is not found in r-base. My second guess is the script syntax needs further work. Anyone have an idea how to interpret these two errors, pls? *** stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-base | grep Version Version: 4.2.1-2.2204.0 stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-cran-arules | grep Version Version: 1.7-4-1cran1.2204.0 stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-cran-Matrix | grep Version Version: 1.4-1-1.2204.0 stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-cran-psych | grep Version Version: 2.2.5-1cran1.2204.0 stephen@LENOVO-SSD ~/Desktop $ *** setwd("/home/stephen/SHD-R") library(Matrix) library(arules) library(psych) Data <- read.csv("./input/DataSet.csv", header=T, colClasses='factor') Groups <- Data[6:12] Groups[Groups=="0"] <- NA View(Groups) rules <- apriori(Groups, parameter = list(ext = FALSE, minlen=2, supp=0.2, conf=0.5)) inspect(rules) *** ERROR ONE Attaching package: ‘arules’ The following objects are masked from ‘package:base’: abbreviate, write *** ERROR TWO Error in eval(ei, envir) : object 'Insert' not found *** Kindest Regards, -- *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error generated by nlme::gnls
> Bill Dunlap > on Sun, 24 Jul 2022 08:51:09 -0700 writes: > I think the intent of this code was to see if the formula > had solely a literal 1 on the right hand side. Then > !identical(pp[[3]], 1) would do it, avoiding the overhead > of calling deparse. Note that the 1 might be an integer, > which the current code would (erroneously) not catch, so > !identical(pp[[3]], 1) && !identical(pp[[3]], 1L) or > something equivalent would be better. > -Bill Thanks a lot, Bill, Ivan, Ben et al. ! This is indeed a very old coding bug triggered by the more strict checks in R 4.2.x. I will indeed try Bill's proposal rather than remaining with deparse by using deparse1(). "Of course", this should hopefully be fixed in the next release of nlme. Martin Maechler ETH Zurich and R Core team > On Sun, Jul 24, 2022 at 5:58 AM Ivan Krylov > wrote: >> Sorry for being too terse in my previous e-mail! >> >> On Sun, 24 Jul 2022 23:03:02 +1200 Rolf Turner >> wrote: >> >> > The maintainer of the nlme package (who is, according >> to maintainer(), > "R-core") could change the code so >> that it uses invokes deparse1() > rather than deparse, >> but the user cannot do so, not without in effect > >> re-creating the package. >> >> You're right. I think there's a buglet in nlme::gnls that >> nobody noticed until R 4.2.0 was released *and* Aaron >> Crowley used the function with a sufficiently long >> formula. >> >> > Also, the question remains: why did Aaron Crowley's >> code work in the > past, whereas now it throws an error? >> What changed? >> >> gnls() may have been performing the `if (deparse(...) != >> '1')` test for a long time, but never crashed before >> because it wasn't a fatal error until R >> 4.2.0. Previously, if() would issue a warning and use the >> first element of the boolean vector. >> >> R 4.2.0 was released this April, which was less than 6 >> months ago. I think it all fits. >> >> A temporary solution would be to make use of the fact >> that R is a very dynamic language and perform surgery on >> a live function inside a loaded package: >> >> library(codetools) >> >> nlme <- loadNamespace('nlme') unlockBinding('gnls', nlme) >> nlme$gnls <- `body<-`(fun = nlme$gnls, value = walkCode( >> body(nlme$gnls), makeCodeWalker( call = function(e, w) >> as.call(lapply(as.list(e), function(ee) if (!missing(ee)) >> walkCode(ee, w) )), leaf = function(e, w) if >> (is.symbol(e) && e == 'deparse') { as.name('deparse1') } >> else e ) )) lockBinding('gnls', nlme) rm(nlme) >> >> grep('deparse', deparse(nlme::gnls), value = TRUE) # [1] >> " deparse1(pp[[3]]), sep = \"~\"), collapse = \",\"), " # >> [2] " if (deparse1(params[[nm]][[3]]) != \"1\") {" # [3] >> " list(row.names(dataModShrunk), deparse1(form[[2]]))), " >> >> Aaron's example seems to work after this, modulo needing >> 12 starting values instead of 13. >> >> -- >> Best regards, Ivan >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and >> more, see https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html and provide >> commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and > more, see https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide > commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error generated by nlme::gnls
I think the intent of this code was to see if the formula had solely a literal 1 on the right hand side. Then !identical(pp[[3]], 1) would do it, avoiding the overhead of calling deparse. Note that the 1 might be an integer, which the current code would (erroneously) not catch, so !identical(pp[[3]], 1) && !identical(pp[[3]], 1L) or something equivalent would be better. -Bill On Sun, Jul 24, 2022 at 5:58 AM Ivan Krylov wrote: > Sorry for being too terse in my previous e-mail! > > On Sun, 24 Jul 2022 23:03:02 +1200 > Rolf Turner wrote: > > > The maintainer of the nlme package (who is, according to maintainer(), > > "R-core") could change the code so that it uses invokes deparse1() > > rather than deparse, but the user cannot do so, not without in effect > > re-creating the package. > > You're right. I think there's a buglet in nlme::gnls that nobody > noticed until R 4.2.0 was released *and* Aaron Crowley used the > function with a sufficiently long formula. > > > Also, the question remains: why did Aaron Crowley's code work in the > > past, whereas now it throws an error? What changed? > > gnls() may have been performing the `if (deparse(...) != '1')` test for > a long time, but never crashed before because it wasn't a fatal error > until R 4.2.0. Previously, if() would issue a warning and use the first > element of the boolean vector. > > R 4.2.0 was released this April, which was less than 6 months ago. I > think it all fits. > > A temporary solution would be to make use of the fact that R is a very > dynamic language and perform surgery on a live function inside a loaded > package: > > library(codetools) > > nlme <- loadNamespace('nlme') > unlockBinding('gnls', nlme) > nlme$gnls <- `body<-`(fun = nlme$gnls, value = walkCode( > body(nlme$gnls), makeCodeWalker( > call = function(e, w) > as.call(lapply(as.list(e), function(ee) > if (!missing(ee)) walkCode(ee, w) > )), > leaf = function(e, w) > if (is.symbol(e) && e == 'deparse') { > as.name('deparse1') > } else e > ) > )) > lockBinding('gnls', nlme) > rm(nlme) > > grep('deparse', deparse(nlme::gnls), value = TRUE) > # [1] "deparse1(pp[[3]]), sep = \"~\"), collapse = > \",\"), " # [2] "if (deparse1(params[[nm]][[3]]) != \"1\") {" > # [3] "list(row.names(dataModShrunk), deparse1(form[[2]]))), " > > Aaron's example seems to work after this, modulo needing 12 starting > values instead of 13. > > -- > Best regards, > Ivan > > __ > 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] Error generated by nlme::gnls
On Sun, 24 Jul 2022 16:03:24 +1200 Rolf Turner wrote: > My impression is that if the right hand side of a formula gets "too > long", then it gets split into parts --- which messes everything up. For new enough R (≥ 4.0), it's possible to use deparse1() [*], which guarantees to return a single string. Otherwise, the simplest workaround would be paste(deparse(...), collapse = ' '), which is similar to how deparse1 is defined. -- Best regards, Ivan [*] https://bugs.r-project.org/show_bug.cgi?id=17671#c1 __ 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 generated by nlme::gnls
On Sat, 23 Jul 2022 21:00:25 -0400 Ben Tupper wrote: > Could this be related to a new if() behavior introduced in v4.2.0 ? > See the "SIGNIFICANT USER-VISIBLE CHANGES" for v4.2.0 in the NEWS > > https://cloud.r-project.org/doc/manuals/r-release/NEWS.html No. What's going on is much weirder than that, and looks to me like a bug has been introduced in formula() or in something related. My impression is that if the right hand side of a formula gets "too long", then it gets split into parts --- which messes everything up. Consider: lhs1 <- paste(paste0("x",1:12),collapse=" + ") f1 <- as.formula(paste("x ~ -1 +",lhs1)) print(length(deparse(f1[[3]]))) You get the value 2. Note that deparse(f1[[3]]) gives [1] "-1 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + " [2] "x12" If we shorten the right hand side of the formula just a wee bit lhs2 <- paste(paste0("x",1:11),collapse=" + ") f2 <- as.formula(paste("x ~ -1 +",lhs2)) then deparse(f2[[3]]) is of length 1, as it should be: > > deparse(f2[[3]]) > [1] "-1 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11" I could of course be missing something, but it really looks to me as if something has gone up to Puttee here. Some input from someone in R-Core would be valuable here. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ 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 generated by nlme::gnls
Could this be related to a new if() behavior introduced in v4.2.0 ? See the "SIGNIFICANT USER-VISIBLE CHANGES" for v4.2.0 in the NEWS https://cloud.r-project.org/doc/manuals/r-release/NEWS.html On Sat, Jul 23, 2022 at 6:26 PM Aaron Crowley wrote: > > Approximately 6 months ago, I successfully performed a model-based > network meta-analysis using the gnls function from the nlme package in > R (nlme::gnls). In this analysis, a binary response is captured as a > non-linear non-parametric placebo response model combined with drug > effect as a function of dose and time and is fitted on aggregate data > from 57 trials and 13 treatments. > > I am now trying to rerun the analysis but the code no longer runs. An > error message is generated when trying to fit the model using > nlme::gnls. A reproducible example generating the same error message > is below. > > library(nlme) > > set.seed(548) > > df <- Soybean > df$x01 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x02 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x03 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x04 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x05 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x06 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x07 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x08 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x09 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x10 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x11 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > df$x12 <- sample(c(0, 1), size = nrow(df), replace = TRUE) > > gnls( > weight ~ x, > data = df, > params = (x ~ -1 + x01 + x02 + x03 + x04 + x05 + x06 + x07 + x08 + > x09 + x10 + x11 + x12), > start = rep(0, 13) > ) > # Error in if (deparse(params[[nm]][[3]]) != "1") { : > # the condition has length > 1 > > sessionInfo() > # R version 4.2.1 (2022-06-23 ucrt) > # Platform: x86_64-w64-mingw32/x64 (64-bit) > # Running under: Windows 10 x64 (build 22000) > # > # Matrix products: default > # > # locale: > # [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United > States.utf8 > # [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C > # [5] LC_TIME=English_United States.utf8 > # > # attached base packages: > # [1] stats graphics grDevices utils datasets methods base > # > # other attached packages: > # [1] nlme_3.1-157 > # > # loaded via a namespace (and not attached): > # [1] compiler_4.2.1 tools_4.2.1 grid_4.2.1 lattice_0.20-45 > > Aaron Crowley > Principal Scientist, Biostatistics > > e. aa...@genesisrg.com > w. genesisrg.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. -- Ben Tupper (he/him) Bigelow Laboratory for Ocean Science East Boothbay, Maine http://www.bigelow.org/ https://eco.bigelow.org __ 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 forest.meta : argument 3 matches multiple formal arguments
Thank you On Thu, May 26, 2022 at 12:38 PM Ivan Krylov wrote: > > В Thu, 26 May 2022 12:30:12 +0200 > Luigi Marongiu пишет: > > > > Error in forest.meta(m10, sortvar = TE, predict = TRUE, print.tau2 > > > = TRUE, : > > argument 3 matches multiple formal arguments > > Look at help(forest.meta). There are multiple possible parameters that > start with "predict" (prediction, prediction.subgroup), so they both > partially match your "predict" argument (which is the third one in the > call). R doesn't know which one you meant. > > -- > Best regards, > Ivan -- Best regards, Luigi __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in forest.meta : argument 3 matches multiple formal arguments
Hello, I am using the package meta to plot a forest plot. My data looks like this: ``` X Entry Cases Ca_pos Controls Co_pos Method Tissue Disease Virus Set 6 de Villiers, 200782 72 82 61PCR colon/rectum cancer TTV 3 7 de Villiers, 2002 162 380 0ISH colon/rectum cancer TTV 3 15 Li , 200737 35 37 25ISH colon/rectum cancer Parvo B19 3 19 Pironi, 2009 8 40 0PCR colon/rectum cancer Parvo B19 3 ``` but I get this error: ``` m10 = metabin(Ca_pos,Cases,Co_pos,Controls, sm="OR", method="MH", fixed=FALSE, studlab=Entry, data=X) forest(m10, sortvar = TE, predict = TRUE, print.tau2 = TRUE, allstudies = FALSE, layout = "RevMan5") > Error in forest.meta(m10, sortvar = TE, predict = TRUE, print.tau2 = TRUE, : argument 3 matches multiple formal arguments ``` What am I getting wrong? How can I solve it? -- Best regards, Luigi __ 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 when trying to install package tableHTML
On Tue, 17 May 2022 11:43:33 -0500 Paul Bernal wrote: > Could this be due to network restrictions? Yes, definitely. > URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'SSL > peer certificate or SSH remote key was not OK' Since most other people seem to be able to access this address, there must be something about your network connection. Most likely, this error message means that something is intercepting your connections to cran.r-project.org / mirrors.dotsrc.org, and your system (or at least the part of R which tries to connect there, which should be using the same certificate store) is not set up to trust that entity. Is there a network administrator you could contact with problems like this one? -- Best regards, Ivan __ 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 with text analysis data
be. >> >> -- >> >> David. >> >> > >> > Best regards >> > >> > On Wed, Apr 13, 2022 at 9:53 PM Ebert,Timothy Aaron >> wrote: >> > >> >> Is this a different question from the original post? It would be >> better to >> >> keep threads separate. >> >> >> >> Always pre-process the data. Clean the data of obvious mistakes. This >> can >> >> be simple typographical errors or complicated like an author that >> wrote too >> >> when they intended two or to. In old English texts spelling was not >> >> standardized and the same word could have multiple spellings within one >> >> book or chapter. Removing punctuation is probably a part of this, >> though a >> >> program like Grammarly would not work very well if it removed >> punctuation. >> >> >> >> >> >> >> >> After that it depends on what you are trying to accomplish. Are you >> >> interested in the number of times an author used the word “a” or “the” >> and >> >> is “The” different from “the?” Are you modeling word use frequency or >> >> comparing vocabulary between texts. >> >> >> >> >> >> >> >> Too many choices. >> >> >> >> >> >> >> >> Tim >> >> >> >> >> >> >> >> *From:* Neha gupta >> >> *Sent:* Wednesday, April 13, 2022 2:49 PM >> >> *To:* Bill Dunlap >> >> *Cc:* Ebert,Timothy Aaron ; r-help mailing list < >> >> r-help@r-project.org> >> >> *Subject:* Re: Error with text analysis data >> >> >> >> >> >> >> >> *[External Email]* >> >> >> >> Someone just told me that you need to pre process the data before model >> >> construction. For instance, make the text to lower case, remove >> >> punctuation, symbols etc and tokenize the text (give number to each >> word). >> >> Then create word of bags model (not sure about it), and then create a >> >> model. >> >> >> >> >> >> >> >> Is it true to perform all these steps? >> >> >> >> >> >> >> >> Best regards >> >> >> >> On Wednesday, April 13, 2022, Bill Dunlap >> >> wrote: >> >> >> >>> I would always suggest working until the model works, no errors and >> no >> >> NA values >> >> >> >> >> >> >> >> We agree on that. However, the error gives you no hint about which >> >> variables are causing the problem. If it did, then it could only tell >> >> about the first variable with the problem. I think you would get to >> your >> >> working model faster if you got NA's for the constant columns and then >> >> could drop them all at once (or otherwise deal with them). >> >> >> >> >> >> >> >> -Bill >> >> >> >> >> >> >> >> On Wed, Apr 13, 2022 at 9:40 AM Ebert,Timothy Aaron >> >> wrote: >> >> >> >> I suspect that it is because you are looking at two types of error, >> both >> >> telling you that the model was not appropriate. In the “error in >> contrasts” >> >> there is nothing to contrast in the model. For a numerical constant the >> >> program calculates the standard deviation and ends with a division by >> zero. >> >> Division by zero is undefined, or NA. >> >> >> >> >> >> >> >> I would always suggest working until the model works, no errors and no >> NA >> >> values. The reason is that I can get NA in several ways and I need to >> >> understand why. If I just ignore the NA in my model I may be assuming >> the >> >> wrong thing. >> >> >> >> >> >> >> >> Tim >> >> >> >> >> >> >> >> *From:* Bill Dunlap >> >> *Sent:* Wednesday, April 13, 2022 12:23 PM >> >> *To:* Ebert,Timothy Aaron >> >> *Cc:* Neha gupta ; r-help mailing list < >> >> r-help@r-project.org> >> >> *Subject:* Re: [R] Error with text analysis data >> >> >> >> >> >> >> >> *[External Email]* >> >> >> >> Constant columns can be th
Re: [R] Error with text analysis data
Is this a different question from the original post? It would be better to keep threads separate. Always pre-process the data. Clean the data of obvious mistakes. This can be simple typographical errors or complicated like an author that wrote too when they intended two or to. In old English texts spelling was not standardized and the same word could have multiple spellings within one book or chapter. Removing punctuation is probably a part of this, though a program like Grammarly would not work very well if it removed punctuation. After that it depends on what you are trying to accomplish. Are you interested in the number of times an author used the word “a” or “the” and is “The” different from “the?” Are you modeling word use frequency or comparing vocabulary between texts. Too many choices. Tim From: Neha gupta Sent: Wednesday, April 13, 2022 2:49 PM To: Bill Dunlap Cc: Ebert,Timothy Aaron ; r-help mailing list Subject: Re: Error with text analysis data [External Email] Someone just told me that you need to pre process the data before model construction. For instance, make the text to lower case, remove punctuation, symbols etc and tokenize the text (give number to each word). Then create word of bags model (not sure about it), and then create a model. Is it true to perform all these steps? Best regards On Wednesday, April 13, 2022, Bill Dunlap mailto:williamwdun...@gmail.com>> wrote: > I would always suggest working until the model works, no errors and no NA > values We agree on that. However, the error gives you no hint about which variables are causing the problem. If it did, then it could only tell about the first variable with the problem. I think you would get to your working model faster if you got NA's for the constant columns and then could drop them all at once (or otherwise deal with them). -Bill On Wed, Apr 13, 2022 at 9:40 AM Ebert,Timothy Aaron mailto:teb...@ufl.edu>> wrote: I suspect that it is because you are looking at two types of error, both telling you that the model was not appropriate. In the “error in contrasts” there is nothing to contrast in the model. For a numerical constant the program calculates the standard deviation and ends with a division by zero. Division by zero is undefined, or NA. I would always suggest working until the model works, no errors and no NA values. The reason is that I can get NA in several ways and I need to understand why. If I just ignore the NA in my model I may be assuming the wrong thing. Tim From: Bill Dunlap mailto:williamwdun...@gmail.com>> Sent: Wednesday, April 13, 2022 12:23 PM To: Ebert,Timothy Aaron mailto:teb...@ufl.edu>> Cc: Neha gupta mailto:neha.bologn...@gmail.com>>; r-help mailing list mailto:r-help@r-project.org>> Subject: Re: [R] Error with text analysis data [External Email] Constant columns can be the model when you do some subsetting or are exploring a new dataset. My objection is that constant columns of numbers and logicals are fine but those of characters and factors are not. -Bill On Wed, Apr 13, 2022 at 9:15 AM Ebert,Timothy Aaron mailto:teb...@ufl.edu>> wrote: What is the goal of having a constant in the model? To me that seems pointless. Also there is no variability in sexCode regardless of whether you call it integer or factor. So the model y ~ sexCode is just a strange way to look at the variability in y and it would be better to do something like summarize(y) or mean(y) if that was the goal. Tim -Original Message- From: R-help mailto:r-help-boun...@r-project.org>> On Behalf Of Bill Dunlap Sent: Wednesday, April 13, 2022 9:56 AM To: Neha gupta mailto:neha.bologn...@gmail.com>> Cc: r-help mailing list mailto:r-help@r-project.org>> Subject: Re: [R] Error with text analysis data [External Email] This sounds like what I think is a bug in stats::model.matrix.default(): a numeric column with all identical entries is fine but a constant character or factor column is not. > d <- data.frame(y=1:5, sex=rep("Female",5)) d$sexFactor <- > factor(d$sex, levels=c("Male","Female")) d$sexCode <- > as.integer(d$sexFactor) d ysex sexFactor sexCode 1 1 FemaleFemale 2 2 2 FemaleFemale 2 3 3 FemaleFemale 2 4 4 FemaleFemale 2 5 5 FemaleFemale 2 > lm(y~sex, data=d) Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels > lm(y~sexFactor, data=d) Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels > lm(y~sexCode, data=d) Call: lm(formula = y ~ sexCode, data = d) Coefficients: (Intercept) sexCode 3 NA Calling traceback() after the error would clarify this. -Bill On Tue, Apr 12, 2022 at 3:12 PM Neha
Re: [R] Error with text analysis data
> I would always suggest working until the model works, no errors and no NA values We agree on that. However, the error gives you no hint about which variables are causing the problem. If it did, then it could only tell about the first variable with the problem. I think you would get to your working model faster if you got NA's for the constant columns and then could drop them all at once (or otherwise deal with them). -Bill On Wed, Apr 13, 2022 at 9:40 AM Ebert,Timothy Aaron wrote: > I suspect that it is because you are looking at two types of error, both > telling you that the model was not appropriate. In the “error in contrasts” > there is nothing to contrast in the model. For a numerical constant the > program calculates the standard deviation and ends with a division by zero. > Division by zero is undefined, or NA. > > > > I would always suggest working until the model works, no errors and no NA > values. The reason is that I can get NA in several ways and I need to > understand why. If I just ignore the NA in my model I may be assuming the > wrong thing. > > > > Tim > > > > *From:* Bill Dunlap > *Sent:* Wednesday, April 13, 2022 12:23 PM > *To:* Ebert,Timothy Aaron > *Cc:* Neha gupta ; r-help mailing list < > r-help@r-project.org> > *Subject:* Re: [R] Error with text analysis data > > > > *[External Email]* > > Constant columns can be the model when you do some subsetting or are > exploring a new dataset. My objection is that constant columns of numbers > and logicals are fine but those of characters and factors are not. > > > > -Bill > > > > On Wed, Apr 13, 2022 at 9:15 AM Ebert,Timothy Aaron > wrote: > > What is the goal of having a constant in the model? To me that seems > pointless. Also there is no variability in sexCode regardless of whether > you call it integer or factor. So the model y ~ sexCode is just a strange > way to look at the variability in y and it would be better to do something > like summarize(y) or mean(y) if that was the goal. > > Tim > > -----Original Message- > From: R-help On Behalf Of Bill Dunlap > Sent: Wednesday, April 13, 2022 9:56 AM > To: Neha gupta > Cc: r-help mailing list > Subject: Re: [R] Error with text analysis data > > [External Email] > > This sounds like what I think is a bug in stats::model.matrix.default(): a > numeric column with all identical entries is fine but a constant character > or factor column is not. > > > d <- data.frame(y=1:5, sex=rep("Female",5)) d$sexFactor <- > > factor(d$sex, levels=c("Male","Female")) d$sexCode <- > > as.integer(d$sexFactor) d > ysex sexFactor sexCode > 1 1 FemaleFemale 2 > 2 2 FemaleFemale 2 > 3 3 FemaleFemale 2 > 4 4 FemaleFemale 2 > 5 5 FemaleFemale 2 > > lm(y~sex, data=d) > Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels > > lm(y~sexFactor, data=d) > Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels > > lm(y~sexCode, data=d) > > Call: > lm(formula = y ~ sexCode, data = d) > > Coefficients: > (Intercept) sexCode > 3 NA > > Calling traceback() after the error would clarify this. > > -Bill > > > On Tue, Apr 12, 2022 at 3:12 PM Neha gupta > wrote: > > > Hello everyone, I have text data with output variable have three > subgroups. > > I am using the following code but getting the error message (see error > > after the code). > > > > d=read.csv("SONAR_RULES.csv", stringsAsFactors = FALSE) > > d$REMEDIATION_FUNCTION=NULL d$DEF_REMEDIATION_GAP_MULT=NULL > > d$REMEDIATION_BASE_EFFORT=NULL > > > > index <- createDataPartition(d$TYPE, p = .70,list = FALSE) tr <- > > d[index, ] ts <- d[-index, ] > > > > ctrl <- trainControl(method = "cv",number=3, index = index, classProbs > > = TRUE, summaryFunction = multiClassSummary) > > > > ran <- train(TYPE ~ ., data = tr, > > method = "rpart", > > ## Will create 48 parameter combinations > > tuneLength = 3, > > na.action= na.pass, > > metric = "Accuracy", > > preProc = c("center", "scale", "nzv"), > > trControl = ctrl) > > getTrainPerf(ran) > > > > *It gives me error:* > > > >
Re: [R] Error with text analysis data
Constant columns can be the model when you do some subsetting or are exploring a new dataset. My objection is that constant columns of numbers and logicals are fine but those of characters and factors are not. -Bill On Wed, Apr 13, 2022 at 9:15 AM Ebert,Timothy Aaron wrote: > What is the goal of having a constant in the model? To me that seems > pointless. Also there is no variability in sexCode regardless of whether > you call it integer or factor. So the model y ~ sexCode is just a strange > way to look at the variability in y and it would be better to do something > like summarize(y) or mean(y) if that was the goal. > > Tim > > -Original Message- > From: R-help On Behalf Of Bill Dunlap > Sent: Wednesday, April 13, 2022 9:56 AM > To: Neha gupta > Cc: r-help mailing list > Subject: Re: [R] Error with text analysis data > > [External Email] > > This sounds like what I think is a bug in stats::model.matrix.default(): a > numeric column with all identical entries is fine but a constant character > or factor column is not. > > > d <- data.frame(y=1:5, sex=rep("Female",5)) d$sexFactor <- > > factor(d$sex, levels=c("Male","Female")) d$sexCode <- > > as.integer(d$sexFactor) d > ysex sexFactor sexCode > 1 1 FemaleFemale 2 > 2 2 FemaleFemale 2 > 3 3 FemaleFemale 2 > 4 4 FemaleFemale 2 > 5 5 FemaleFemale 2 > > lm(y~sex, data=d) > Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels > > lm(y~sexFactor, data=d) > Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels > > lm(y~sexCode, data=d) > > Call: > lm(formula = y ~ sexCode, data = d) > > Coefficients: > (Intercept) sexCode > 3 NA > > Calling traceback() after the error would clarify this. > > -Bill > > > On Tue, Apr 12, 2022 at 3:12 PM Neha gupta > wrote: > > > Hello everyone, I have text data with output variable have three > subgroups. > > I am using the following code but getting the error message (see error > > after the code). > > > > d=read.csv("SONAR_RULES.csv", stringsAsFactors = FALSE) > > d$REMEDIATION_FUNCTION=NULL d$DEF_REMEDIATION_GAP_MULT=NULL > > d$REMEDIATION_BASE_EFFORT=NULL > > > > index <- createDataPartition(d$TYPE, p = .70,list = FALSE) tr <- > > d[index, ] ts <- d[-index, ] > > > > ctrl <- trainControl(method = "cv",number=3, index = index, classProbs > > = TRUE, summaryFunction = multiClassSummary) > > > > ran <- train(TYPE ~ ., data = tr, > > method = "rpart", > > ## Will create 48 parameter combinations > > tuneLength = 3, > > na.action= na.pass, > > metric = "Accuracy", > > preProc = c("center", "scale", "nzv"), > > trControl = ctrl) > > getTrainPerf(ran) > > > > *It gives me error:* > > > > > > *Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > > contrasts can be applied only to factors with 2 or more levels* > > > > > > *My data is as follow* > > > > Rows: 1,819 > > Columns: 14 > > $ PLUGIN_RULE_KEY "InsufficientBranchCoverage", > > "InsufficientLin~ > > $ PLUGIN_CONFIG_KEY"", "", "", "", "", "", "", "", "", > "", > > "S1120~ > > $ PLUGIN_NAME "common-java", "common-java", > > "common-java", "~ > > $ DESCRIPTION "An issue is created on a file as > soon > > as the ~ > > $ SEVERITY "MAJOR", "MAJOR", "MAJOR", "MAJOR", > > "MAJOR", "~ > > $ NAME "Branches should have sufficient > > coverage by t~ > > $ DEF_REMEDIATION_FUNCTION "LINEAR", "LINEAR", "LINEAR", > > "LINEAR_OFFSET",~ > > $ REMEDIATION_GAP_MULT NA, NA, NA, NA, NA, NA, NA, NA, NA, > NA, > > NA, NA~ > > $ DEF_REMEDIATION_BASE_EFFORT "", "", "", "10min", "", "", > > "5min", "5min", "~ &
Re: [R] Error with text analysis data
This sounds like what I think is a bug in stats::model.matrix.default(): a numeric column with all identical entries is fine but a constant character or factor column is not. > d <- data.frame(y=1:5, sex=rep("Female",5)) > d$sexFactor <- factor(d$sex, levels=c("Male","Female")) > d$sexCode <- as.integer(d$sexFactor) > d ysex sexFactor sexCode 1 1 FemaleFemale 2 2 2 FemaleFemale 2 3 3 FemaleFemale 2 4 4 FemaleFemale 2 5 5 FemaleFemale 2 > lm(y~sex, data=d) Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels > lm(y~sexFactor, data=d) Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels > lm(y~sexCode, data=d) Call: lm(formula = y ~ sexCode, data = d) Coefficients: (Intercept) sexCode 3 NA Calling traceback() after the error would clarify this. -Bill On Tue, Apr 12, 2022 at 3:12 PM Neha gupta wrote: > Hello everyone, I have text data with output variable have three subgroups. > I am using the following code but getting the error message (see error > after the code). > > d=read.csv("SONAR_RULES.csv", stringsAsFactors = FALSE) > d$REMEDIATION_FUNCTION=NULL > d$DEF_REMEDIATION_GAP_MULT=NULL > d$REMEDIATION_BASE_EFFORT=NULL > > index <- createDataPartition(d$TYPE, p = .70,list = FALSE) > tr <- d[index, ] > ts <- d[-index, ] > > ctrl <- trainControl(method = "cv",number=3, index = index, classProbs = > TRUE, summaryFunction = multiClassSummary) > > ran <- train(TYPE ~ ., data = tr, > method = "rpart", > ## Will create 48 parameter combinations > tuneLength = 3, > na.action= na.pass, > metric = "Accuracy", > preProc = c("center", "scale", "nzv"), > trControl = ctrl) > getTrainPerf(ran) > > *It gives me error:* > > > *Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels* > > > *My data is as follow* > > Rows: 1,819 > Columns: 14 > $ PLUGIN_RULE_KEY "InsufficientBranchCoverage", > "InsufficientLin~ > $ PLUGIN_CONFIG_KEY"", "", "", "", "", "", "", "", "", "", > "S1120~ > $ PLUGIN_NAME "common-java", "common-java", > "common-java", "~ > $ DESCRIPTION "An issue is created on a file as soon > as the ~ > $ SEVERITY "MAJOR", "MAJOR", "MAJOR", "MAJOR", > "MAJOR", "~ > $ NAME "Branches should have sufficient > coverage by t~ > $ DEF_REMEDIATION_FUNCTION "LINEAR", "LINEAR", "LINEAR", > "LINEAR_OFFSET",~ > $ REMEDIATION_GAP_MULT NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, > NA, NA~ > $ DEF_REMEDIATION_BASE_EFFORT "", "", "", "10min", "", "", "5min", > "5min", "~ > $ GAP_DESCRIPTION "number of uncovered conditions", > "number of l~ > $ SYSTEM_TAGS "bad-practice", "bad-practice", > "convention", ~ > $ IS_TEMPLATE 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0~ > $ DESCRIPTION_FORMAT "HTML", "HTML", "HTML", "HTML", "HTML", > "HTML"~ > $ TYPE "CODE_SMELL", "CODE_SMELL", > "CODE_SMELL", "COD~ > > [[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] Error with text analysis data
Hi Neha, The error message is about not having _factors_ with two or more levels. Apart from using stringsAsFactors=FALSE (meaning that you probably won't get any factors in "d"), your sample data doesn't look like CSV format. Perhaps the lines have been truncated. You may get something with stringsAsFactors=TRUE, but I don't know whether it will be sensibler. Jim On Wed, Apr 13, 2022 at 8:12 AM Neha gupta wrote: > > Hello everyone, I have text data with output variable have three subgroups. > I am using the following code but getting the error message (see error > after the code). > > d=read.csv("SONAR_RULES.csv", stringsAsFactors = FALSE) > d$REMEDIATION_FUNCTION=NULL > d$DEF_REMEDIATION_GAP_MULT=NULL > d$REMEDIATION_BASE_EFFORT=NULL > > index <- createDataPartition(d$TYPE, p = .70,list = FALSE) > tr <- d[index, ] > ts <- d[-index, ] > > ctrl <- trainControl(method = "cv",number=3, index = index, classProbs = > TRUE, summaryFunction = multiClassSummary) > > ran <- train(TYPE ~ ., data = tr, > method = "rpart", > ## Will create 48 parameter combinations > tuneLength = 3, > na.action= na.pass, > metric = "Accuracy", > preProc = c("center", "scale", "nzv"), > trControl = ctrl) > getTrainPerf(ran) > > *It gives me error:* > > > *Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels* > > > *My data is as follow* > > Rows: 1,819 > Columns: 14 > $ PLUGIN_RULE_KEY "InsufficientBranchCoverage", > "InsufficientLin~ > $ PLUGIN_CONFIG_KEY"", "", "", "", "", "", "", "", "", "", > "S1120~ > $ PLUGIN_NAME "common-java", "common-java", > "common-java", "~ > $ DESCRIPTION "An issue is created on a file as soon > as the ~ > $ SEVERITY "MAJOR", "MAJOR", "MAJOR", "MAJOR", > "MAJOR", "~ > $ NAME "Branches should have sufficient > coverage by t~ > $ DEF_REMEDIATION_FUNCTION "LINEAR", "LINEAR", "LINEAR", > "LINEAR_OFFSET",~ > $ REMEDIATION_GAP_MULT NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, > NA, NA~ > $ DEF_REMEDIATION_BASE_EFFORT "", "", "", "10min", "", "", "5min", > "5min", "~ > $ GAP_DESCRIPTION "number of uncovered conditions", > "number of l~ > $ SYSTEM_TAGS "bad-practice", "bad-practice", > "convention", ~ > $ IS_TEMPLATE 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0~ > $ DESCRIPTION_FORMAT "HTML", "HTML", "HTML", "HTML", "HTML", > "HTML"~ > $ TYPE "CODE_SMELL", "CODE_SMELL", > "CODE_SMELL", "COD~ > > [[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] error with more 100 forked processes
The reason why you hit the limit already around 100 workers, could be because you already have other connections open, e.g. file connections, capture.output(), etc. If you want to use *forked* processing with more than 125 workers using bare-bone R, you can use parallel::mclapply() and friends, because they don't use sockets connections to communicate between the main process and the workers. If you don't need *forked* processing per se, there are other alternatives, as already pointed out above. As the author of the future framework (https://www.futureverse.org/), I obviously suggest you try that one. It's on CRAN and installs out of the box on all OSes. You get several alternatives for parallel backends. For *forked* processing, call plan(multicore) on top of your script, and it'll parallelize via the parallel::mclapply() framework internally, so you won't have the connection limitation to worry about(*). You can also use plan(future.callr::callr) to parallelize via the callr package, which also don't have the connection limitation. Your code will be the same regardless which you end up using. For the front end, there's future.apply::future_lapply() et al. (parallel version of base lapply functions), furrr::future_map() et al. (parallel version of purrr's map functions), foreach w/ doFuture if you like the y <- foreach(...) %dopar% { ... } style. (*) But there are other issues with forked processing, e.g. it might not be compatible with multi-threaded code used by some packages. This is a problem independent of futures per se. Hope this helps Henrik On Fri, Apr 8, 2022 at 2:19 PM Ivan Krylov wrote: > > On Fri, 8 Apr 2022 22:02:25 +0200 > Guido Kraemer via R-help wrote: > > > > cl <- makeForkCluster(128) > > Error in UseMethod("sendData") : > >no applicable method for 'sendData' applied to an object of class > > "NULL" > > In order to communicate with the workers, R creates connection objects. > Unfortunately, the memory for connection objects in R has a > statically-defined limit of 128. (A few connections are used by > default, and a few more will likely be used by user code during the > actual program run.) > > Try increasing the limit in #define NCONNECTIONS in > src/main/connections.c and re-compiling R. > > See also: https://github.com/HenrikBengtsson/Wishlist-for-R/issues/28 > According to Henrik Bengtsson, R should work well even with as many > as 16381 possible connections, but then you may run into OS limits on > file descriptors. > > > -- > Best regards, > Ivan > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error with more 100 forked processes
I am trying to run a parallel job on a computer with many CPUs and get the following error: > library(parallel) > cl <- makeForkCluster(128) Error in UseMethod("sendData") : no applicable method for 'sendData' applied to an object of class "NULL" If I scale down to 100 CPUs it doesn't produce an error. I can reproduce this with a self compiled R 4.1.3 on Ubuntu 20.04 and Manjaro, as well as the R binaries that come with both distributions. -- Guido Kraemer Max Planck Institute for Biogeochemistry Jena Department for Biogeochemical Integration Hans-Knöll-Str. 10 07745 Jena Germany phone: +49 3641 576293 e-mail: gkrae...@bgc-jena.mpg.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.
Re: [R] error as in unused argument of a new package
I took care of the issue by simply updating an already installed package. Really appreciate for the valuable feedback from R community. Glad to have such kind guidelines. On Sat, Feb 26, 2022 at 1:57 AM Ivan Krylov wrote: > On Fri, 25 Feb 2022 16:14:05 -0600 > Tariq Khasiri wrote: > > > CS_never_cond <- did::att_gt(yname="lemp", > > tname="year", > > idname="countyreal", > > gname="first.treat", > > #xformla=~1, > > xformla = xformla, > > control_group="nevertreated", > > data = min_wage, > > panel = TRUE, > > base_period="universal", # <-- here > > bstrap = TRUE, > > cband = TRUE) > > > Error in did::att_gt(yname = "lemp", tname = "year", idname = > > "countyreal", : > > unused argument (base_period = "universal") > > Does ?did::att_gt specify that the att_gt function accepts an > argument named "base_period" (marked by me with "# <-- here")? > If it does, it's a documentation error, contact maintainer('did') and > tell them about it. If it doesn't, you need to adjust your call to > did::att_gt to provide the correct arguments. > > -- > Best regards, > Ivan > [[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 in if (fraction <= 1) { : missing value where TRUE/FALSE needed
gt; result[1] FALSE TRUE FALSE TRUE FALSE TRUE FALSE> > as.integer(result)[1] 0 1 0 1 0 1 0> as.numeric(result)[1] 0 1 0 1 0 1 0> > result <- as.integer(1:7 %% 2 == 0)> result[1] 0 1 0 1 0 1 0 If for some reason the choice of 1 and 0 is the opposite of what you need, you can invert them several ways with the simplest being: as.integer(1:7 %% 2 != 0) or as.integer(!(1:7 %% 2 != 0)) The first negates the comparison and the second just flips every FALSE and TRUE to the other. Why are we talking about this? For many more interesting cases, ifelse() is great as you can replace one or both of the choices with anything. A very common case is replacing one choice with itself and changing the other, or nesting the comparisons in a sort of simulated tree as in ifelse(some_condition, ifelse(second_condition, result1, result2), ifelse(third_condition, result3, result4))) But you seem to want the simplest return of two values that also happen to be the underlying equivalent of TRUE and FALSE in many languages. In Python, anything that evaluates to zero (or the Boolean value FALSE) tends to be treated as FALSE, and anything else like a 1 or 666 is treated as TRUE, as shown below: > if (TRUE) print("TRUE") else print("FALSE")[1] "TRUE"> if (1) print("TRUE") > else print("FALSE")[1] "TRUE"> if (666) print("TRUE") else print("FALSE")[1] > "TRUE"> if (FALSE) print("TRUE") else print("FALSE")[1] "FALSE"> if (0) > print("TRUE") else print("FALSE")[1] "FALSE" This is why you are being told that for many purposes, the Boolean vector may work fine. But if you really want or need zero and one, that is a trivial transformation as shown. Feel free to use ifelse() and then figure out what went wrong with your code, but also to try the simpler version and see if the problem goes away. Avi -Original Message- From: javed khan To: Bert Gunter Cc: R-help Sent: Thu, Jan 27, 2022 1:15 pm Subject: Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Thank you Bert Gunter Do you mean I should do something like this: prot <- (as.numeric(ifelse(test$ operator == 'T13', 1, 0)) [[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 in if (fraction <= 1) { : missing value where TRUE/FALSE needed
gt; result[1] FALSE TRUE FALSE TRUE FALSE TRUE FALSE> > as.integer(result)[1] 0 1 0 1 0 1 0> as.numeric(result)[1] 0 1 0 1 0 1 0> > result <- as.integer(1:7 %% 2 == 0)> result[1] 0 1 0 1 0 1 0 If for some reason the choice of 1 and 0 is the opposite of what you need, you can invert them several ways with the simplest being: as.integer(1:7 %% 2 != 0) or as.integer(!(1:7 %% 2 != 0)) The first negates the comparison and the second just flips every FALSE and TRUE to the other. Why are we talking about this? For many more interesting cases, ifelse() is great as you can replace one or both of the choices with anything. A very common case is replacing one choice with itself and changing the other, or nesting the comparisons in a sort of simulated tree as in ifelse(some_condition, ifelse(second_condition, result1, result2), ifelse(third_condition, result3, result4))) But you seem to want the simplest return of two values that also happen to be the underlying equivalent of TRUE and FALSE in many languages. In Python, anything that evaluates to zero (or the Boolean value FALSE) tends to be treated as FALSE, and anything else like a 1 or 666 is treated as TRUE, as shown below: > if (TRUE) print("TRUE") else print("FALSE")[1] "TRUE"> if (1) print("TRUE") > else print("FALSE")[1] "TRUE"> if (666) print("TRUE") else print("FALSE")[1] > "TRUE"> if (FALSE) print("TRUE") else print("FALSE")[1] "FALSE"> if (0) > print("TRUE") else print("FALSE")[1] "FALSE" This is why you are being told that for many purposes, the Boolean vector may work fine. But if you really want or need zero and one, that is a trivial transformation as shown. Feel free to use ifelse() and then figure out what went wrong with your code, but also to try the simpler version and see if the problem goes away. Avi -Original Message- From: javed khan To: Bert Gunter Cc: R-help Sent: Thu, Jan 27, 2022 1:15 pm Subject: Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Thank you Bert Gunter Do you mean I should do something like this: prot <- (as.numeric(ifelse(test$ operator == 'T13', 1, 0)) [[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 in if (fraction <= 1) { : missing value where TRUE/FALSE needed
Timothy, In reply to what you wrote about a benchmark suggesting some storage formats may make the code run slower, it is not a surprise, given what you chose to benchmark. You are using a test of a logical variable in a numeric context when you have code like: log(a2+0.01) In order to do the calculation, depending on the internals, you need to convert a2 to at least an integer or perhaps a floating point value such as 1L or 1.0 before adding 0.01 to it. You are doing the equivalent of: log(as.integer(a2)+0.01) or perhaps: log(as.double(a2)+0.01) The result is some extra work in THAT context. Note I am NOT saying R calls one of those primitive functions, just that the final code does such conversions perhaps at the assembler level or lower. But consider the opposite context such as in a if(...) statement as in: if(a2) {do_this) else {do_that} If a2 is already a logical data form, it happens rapidly. If a2 is something more complex that can be evaluated in steps into a logical, it takes those steps. As I showed earlier, if a2 was 1 or 666 it would be evaluated to be non-zero and thus converted to TRUE and then the statement would choose do_this, else it would evaluate to FALSE and do do_that. So the right storage format depends on how you want to use it and how much storage space you are willing to use. On some machines and architectures, they may store a logical value in anything from a bit to a byte to multiple bytes, and on a lower level, it may be expanded as needed to fit into a fixed register on the CPU. In some cases, a natural storage format will be the one that can be used immediately with no boxing or unboxing. But as always, there are tradeoffs to be considered in terms of how many cycles are used (execution time) or other resources like memory in use. In a few cases, it may oddly pay to make two or more copies of a vector in different storage formats and then use the best one for subsequent calculations. Boolean might turn out to be a great choice for indexing into a list or vector or matrix or data.frame, while integer may be great if doing mathematics like multiplication into a structure that only contains integers, and a double version when interacting with such numbers and maybe even versions that are character or complex. But from a novice perspective, performance is not usually a big concern and especially not for small amounts of data. The only reason this is being discussed is that the question about what went wrong might be hard to figure out without lots more info, while the simple wrok-around might either work fine or tell us more about what might be wrong. -Original Message- From: Ebert,Timothy Aaron To: Bert Gunter Cc: R-help Sent: Thu, Jan 27, 2022 2:27 pm Subject: Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed You did not claim it is faster, but if one is writing large programs or has huge quantities of data then thinking about execution time could be useful. if(!require(microbenchmark)){install.packages("microbenchmark")} library(microbenchmark) a1<-c(1,1,0,1,0,0,0,1,1,0,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,0,1,0,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,1) a2=as.logical(a1) microbenchmark( { log(a1+0.01) }, { log(a2+0.01) }, times=10 ) On my system running the code shows that there is an overhead cost if the logical has to be converted. In this simple code it was a sometimes significant but always a trivial 0.1 microsecond cost. I tried a few other bits of code and the mean and minimum values were always smaller performing numeric operations on a numeric variable. However, it looks like the range in values for a numeric operation on a numeric variable is greater. I don't understand why. Tim -Original Message- From: Bert Gunter Sent: Thursday, January 27, 2022 1:17 PM To: Ebert,Timothy Aaron Cc: PIKAL Petr ; R-help Subject: Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed [External Email] I did not claim it is faster -- and in fact I doubt that it makes any real difference. Just simpler, imo. I also think that the logical vector would serve equally in any situation in most cases where arithmetic 0/1 coding is used -- even arithmetic ops and comparisons: > TRUE + 2 [1] 3 > TRUE > .5 [1] TRUE (?'+' has details) I would appreciate someone responding with a nontrivial counterexample to this claim if they have one, other than the sort of thing shown in the ?logical example involving conversion to character: ## logical interpretation of particular strings charvec <- c("FALSE", "F", "False", "false", "fAlse", "0", "TRUE", "T", "True", "true", "tRue", "1") as.logical(charvec) ## factors are converted via their levels, so string convers