[R] approx with NAs
There is something I do not think is right in the approx() function in base R, with method="constant" and in the presence of NA values. I have 3.6.0, but the behavior seems to be the same in earlier versions. My suggested fix is to add an "na.rm" argument to approx(), as in mean(). If this argument is FALSE, then NA values should be propagated into the output rather than being removed. Details: The documentation says "f: for method = "constant" a number between 0 and 1 inclusive, indicating a compromise between left- and right-continuous step functions. If y0 and y1 are the values to the left and right of the point then the value is y0 if f == 0, y1 if f == 1, and y0*(1-f)+y1*f for intermediate values. In this way the result is right-continuous for f == 0 and left-continuous for f == 1, even for non-finite y values." This suggests to me that if the left value y0 is NA, and if f=0 (the default), then the interpolated value should be NA. (Regardless of the right value y1, see bug 15655 fixed in 2014.) The documentation further says, below under "Details", that "The inputs can contain missing values which are deleted." The question is what is the appropriate behavior if one of the input values y is NA. Currently, approx() seems to interpret NA values as faulty data points, which should be deleted and the previous values carried forward (example below). But in many applications, especially with "constant" interpolation, an NA value is intended to mean that we really do not know the value in the next interval, or explicitly that there is no value. Therefore the NA should not be removed, but should be propagated forward into the output within the corresponding interval. The situation is similar with functions like mean(). The presence of an NA value may mean either (a) we want to compute the mean without that value (na.rm=TRUE), or (b) we really are missing important information, we cannot determine the mean, and we should return NA (na.rm=FALSE). Therefore, I propose that approx() also be given an na.rm argument, indicating whether we wish to delete NA values, or treat them as actual values on the corresponding interval. That option makes even more sense for approx() than for mean(), since the NA values apply only on small regions of the data range. --Robert Almgren Example: : R --vanilla R version 3.6.0 (2019-04-26) -- "Planting of a Tree" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit) ... > t1 <- 1:5 > x1 <- c( 1, as.numeric(NA), 3, as.numeric(NA), 5 ) > print(data.frame(t1,x1)) t1 x1 1 1 1 2 2 NA <-- we do not know the value between t=2 and t=3 3 3 3 4 4 NA <-- we do not know the value between t=4 and t=5 5 5 5 > X <- approx( t1, x1, (1:4) + 0.5, method='constant', rule=c(1,2) ) > print(data.frame(X)) x y 1 1.5 1 2 2.5 1 < I believe that these two values should be NA 3 3.5 3 4 4.5 3 < I believe that these two values should be NA -- Quantitative Brokers http://www.quantitativebrokers.com -- CONFIDENTIALITY NOTICE: This e-mail and any attachments=...{{dropped:23}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Loading EDF files
Dear All, I have tried to load an EDF file using the code below and I received the following massage : Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] <- samples[[sn]] : replacement has length zero What this massage means? Is there any problem with the EDF file? Code used: hdr <- readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf"); df_id1 <- readEdfSignals(hdr, signals = "All", from = 0, till = Inf, physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals = TRUE, simplify = TRUE); Any help would be highly appreciated. Mariano > > [[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] One-way ANOVA with replicates
Hi All, I have a dataset (attached) with three groups (treatments) namely Neutral , Video, Audio and four output variables. I am planning to check the ANOVA results to show that is a difference in observations when treatment is changed. To generalize the conclusion, I did the same experiment for set of people (subjects in attached file). Now I am not sure whether I can use One-Way ANOVA for my dataset. Highly appreciate if somebody can explain me. I am using the R package to analyze data. 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] randomly sampling and visualizing 100 nodes in a citation network with igraph library
Hello, Maybe you can sample from the vertices subv <- sample(V(G), 100) and then use something like [1] (StackOverflow). [1]https://stackoverflow.com/questions/23682113/creating-subgraph-using-igraph-in-r Hope this helps, Rui Barradas Às 22:02 de 03/05/19, Drake Gossi escreveu: Hello everyone, How would I randomly select 100 nodes to look at out of these approx. 25,? I'm practicing constructing a citation network. edgeList below is an edge list. head (edgeList) tofrom [1,] "4US6""3US320" [2,] "4US6""4US1" [3,] "6US280" "1US393" [4,] "6US280" "1US53" [5,] "6US280" "3US133" [6,] "14US179" "5US321" G <- graph.edgelist(edgeList, directed=FALSE) G IGRAPH a473ce7 UN-- 25417 216738 -- + attr: name (v/c) + edges from a473ce7 (vertex names): [1] 4US6 --3US320 4US6 --4US16US280 --1US393 [4] 6US280 --1US53 6US280 --3US133 14US179--5US321 [7] 14US179--9US262 15US45 --3US384 15US45 --4US436 [10] 15US45 --4US441 15US45 --8US421 15US227--13US388 [13] 15US227--2US36 15US290--7US220 9US262 --15US290 [16] 15US369--11US504 15US369--11US577 15US369--5US137 [19] 15US369--9US115 15US396--1US371 15US396--4US450 [22] 15US396--6US358 15US396--7US73 16US1 --11US603 + ... omitted several edges Can I use the sample () function? I'm working with the text Humanities Data in R (Arnold & Tilton). I'm working within the igraph library. Drake __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] create a table for time difference (from t3 to t1, so on..)
Hi Marna, You can get the information you need with this: dAT$date<-as.Date(dAT$date,"%d-%b-%y") diffs<-function(x,maxn) return(diff(x)[1:maxn]) initdate<-function(x) return(min(x)) datediffs<-aggregate(dAT$date,list(dAT$Id),diffs,3) I can't do the manipulation of the resulting values at the moment, but can work it out later if necessary. Jim On Sat, May 4, 2019 at 5:24 AM Marna Wagley wrote: > > Hi R User. > I have a date set in which I wanted to find the duration (period) between > released time and detection time for each individual. Is there any simplest > way to create a matrix? > I appreciate your help. > > Thanks, > MW > -- > Here is the example data, > > dAT<-structure(list(Id = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 5L, 4L, > > 1L, 6L, 6L, 3L, 4L, 1L), .Label = c("a", "b", "c", "e", "f", > > "m"), class = "factor"), date = structure(c(1L, 1L, 1L, 5L, 4L, > > 1L, 5L, 5L, 3L, 1L, 2L, 7L, 6L, 8L), .Label = c("1-Jan-18", "1-Jul-18", > > "10-Mar-18", "15-Jan-18", "2-Jan-18", "27-Jan-18", "3-Jan-18", > > "7-Mar-19"), class = "factor")), .Names = c("Id", "date"), class = > "data.frame", row.names = c(NA, > > -14L)) > > > #and the results looks like > > > Result<-structure(list(Id = structure(1:6, .Label = c("a", "b", "c", > > "e", "f", "m"), class = "factor"), intial.released.date = structure(c(1L, > > 1L, 1L, 2L, 2L, 1L), .Label = c("1-Jan-18", "2-Jan-18"), class = "factor"), > > duration.between.t2.and.t1 = c(14L, 0L, 2L, 0L, NA, 181L), > > duration.between.t3.and.t1 = c(68L, NA, NA, 25L, NA, NA), > > duration.between.t4.and.t1 = c(430L, NA, NA, NA, NA, NA), > > duration.between.t3.and.t2 = c(54L, NA, NA, NA, NA, NA), > > duration.between.t4.and.t2 = c(416L, NA, NA, NA, NA, NA)), .Names = c( > "Id", > > "intial.released.date", "duration.between.t2.and.t1", > "duration.between.t3.and.t1", > > "duration.between.t4.and.t1", "duration.between.t3.and.t2", > "duration.between.t4.and.t2" > > ), class = "data.frame", row.names = c(NA, -6L)) > > [[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] stukel function unavailable for some odd reason
On 03/05/2019 4:49 p.m., Paul Bernal wrote: Dear friends, I have been fitting a logistic regression and wanted to try a couple of goodness of fit tests on the model. Doing some research, I came across Chris Dardi's stukel and logiGOF functions from package LogisticDx v0.1. The current version of LogisticDx is 0.2 from 2015, and it doesn't export those functions. Source for version 0.1 from 2014 is available, and it does contain those functions, but I wouldn't touch them with a ten foot pole unless I first heard from the author why he left them out of the next release. Duncan Murdoch I tried installing package LogisticDx in different R versions without any success. I first tried installing LogisticDx package in R version 3.5.3 (for windows 64-bit OS) and this is what happened: install.packages("LogisticDx") Installing package into 'C:/Users/PaulBernal/Documents/R/win-library/3.5' (as 'lib' is unspecified) --- Please select a CRAN mirror for use in this session --- also installing the dependencies 'polspline', 'rms', 'speedglm', 'aod' trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/polspline_1.1.14.zip' Content type 'application/zip' length 778099 bytes (759 KB) downloaded 759 KB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/rms_5.1-3.1.zip' Content type 'application/zip' length 2044689 bytes (1.9 MB) downloaded 1.9 MB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/speedglm_0.3-2.zip' Content type 'application/zip' length 187929 bytes (183 KB) downloaded 183 KB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/aod_1.3.1.zip' Content type 'application/zip' length 323652 bytes (316 KB) downloaded 316 KB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/LogisticDx_0.2.zip' Content type 'application/zip' length 931345 bytes (909 KB) downloaded 909 KB package 'polspline' successfully unpacked and MD5 sums checked package 'rms' successfully unpacked and MD5 sums checked package 'speedglm' successfully unpacked and MD5 sums checked package 'aod' successfully unpacked and MD5 sums checked package 'LogisticDx' successfully unpacked and MD5 sums checked stukel(RegGLM_Mod1) Error in stukel(RegGLM_Mod1) : could not find function "stukel" library(LogisticDx) Error: package or namespace load failed for 'LogisticDx': object 'plotp' not found whilst loading namespace 'rms' install.packages("plotp") Installing package into 'C:/Users/PaulBernal/Documents/R/win-library/3.5' (as 'lib' is unspecified) Warning: package 'plotp' is not available (for R version 3.5.3) After this, I installed R version 3.6.0 and tried again: install.packages("LogisticDx") Installing package into ‘C:/Users/PaulBernal/Documents/R/win-library/3.6’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL ' https://mirrors.dotsrc.org/cran/bin/windows/contrib/3.6/LogisticDx_0.2.zip' Content type 'application/zip' length 932914 bytes (911 KB) downloaded 911 KB package ‘LogisticDx’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\PaulBernal\AppData\Local\Temp\RtmpInhoDn\downloaded_packages library(LogisticDx) Registered S3 methods overwritten by 'ggplot2': method from [.quosures rlang c.quosures rlang print.quosures rlang stukel(GLM.1) Error in stukel(GLM.1) : could not find function "stukel" Anyone can give me some light on what could be happening here? Do I have to try with another R version? Is it something else? Thanks in advance, Paul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] randomly sampling and visualizing 100 nodes in a citation network with igraph library
Hello everyone, How would I randomly select 100 nodes to look at out of these approx. 25,? I'm practicing constructing a citation network. edgeList below is an edge list. > head (edgeList) tofrom [1,] "4US6""3US320" [2,] "4US6""4US1" [3,] "6US280" "1US393" [4,] "6US280" "1US53" [5,] "6US280" "3US133" [6,] "14US179" "5US321" > G <- graph.edgelist(edgeList, directed=FALSE) > G IGRAPH a473ce7 UN-- 25417 216738 -- + attr: name (v/c) + edges from a473ce7 (vertex names): [1] 4US6 --3US320 4US6 --4US16US280 --1US393 [4] 6US280 --1US53 6US280 --3US133 14US179--5US321 [7] 14US179--9US262 15US45 --3US384 15US45 --4US436 [10] 15US45 --4US441 15US45 --8US421 15US227--13US388 [13] 15US227--2US36 15US290--7US220 9US262 --15US290 [16] 15US369--11US504 15US369--11US577 15US369--5US137 [19] 15US369--9US115 15US396--1US371 15US396--4US450 [22] 15US396--6US358 15US396--7US73 16US1 --11US603 + ... omitted several edges Can I use the sample () function? I'm working with the text Humanities Data in R (Arnold & Tilton). I'm working within the igraph library. Drake __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] stukel function unavailable for some odd reason
Dear friends, I have been fitting a logistic regression and wanted to try a couple of goodness of fit tests on the model. Doing some research, I came across Chris Dardi's stukel and logiGOF functions from package LogisticDx v0.1. I tried installing package LogisticDx in different R versions without any success. I first tried installing LogisticDx package in R version 3.5.3 (for windows 64-bit OS) and this is what happened: > install.packages("LogisticDx") Installing package into 'C:/Users/PaulBernal/Documents/R/win-library/3.5' (as 'lib' is unspecified) --- Please select a CRAN mirror for use in this session --- also installing the dependencies 'polspline', 'rms', 'speedglm', 'aod' trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/polspline_1.1.14.zip' Content type 'application/zip' length 778099 bytes (759 KB) downloaded 759 KB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/rms_5.1-3.1.zip' Content type 'application/zip' length 2044689 bytes (1.9 MB) downloaded 1.9 MB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/speedglm_0.3-2.zip' Content type 'application/zip' length 187929 bytes (183 KB) downloaded 183 KB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/aod_1.3.1.zip' Content type 'application/zip' length 323652 bytes (316 KB) downloaded 316 KB trying URL ' https://cran.cnr.berkeley.edu/bin/windows/contrib/3.5/LogisticDx_0.2.zip' Content type 'application/zip' length 931345 bytes (909 KB) downloaded 909 KB package 'polspline' successfully unpacked and MD5 sums checked package 'rms' successfully unpacked and MD5 sums checked package 'speedglm' successfully unpacked and MD5 sums checked package 'aod' successfully unpacked and MD5 sums checked package 'LogisticDx' successfully unpacked and MD5 sums checked > stukel(RegGLM_Mod1) Error in stukel(RegGLM_Mod1) : could not find function "stukel" > library(LogisticDx) Error: package or namespace load failed for 'LogisticDx': object 'plotp' not found whilst loading namespace 'rms' > install.packages("plotp") Installing package into 'C:/Users/PaulBernal/Documents/R/win-library/3.5' (as 'lib' is unspecified) Warning: package 'plotp' is not available (for R version 3.5.3) After this, I installed R version 3.6.0 and tried again: > install.packages("LogisticDx") Installing package into ‘C:/Users/PaulBernal/Documents/R/win-library/3.6’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL ' https://mirrors.dotsrc.org/cran/bin/windows/contrib/3.6/LogisticDx_0.2.zip' Content type 'application/zip' length 932914 bytes (911 KB) downloaded 911 KB package ‘LogisticDx’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\PaulBernal\AppData\Local\Temp\RtmpInhoDn\downloaded_packages > library(LogisticDx) Registered S3 methods overwritten by 'ggplot2': method from [.quosures rlang c.quosures rlang print.quosures rlang > stukel(GLM.1) Error in stukel(GLM.1) : could not find function "stukel" Anyone can give me some light on what could be happening here? Do I have to try with another R version? Is it something else? Thanks in advance, Paul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [ESS] running R remotely via tramp
Hi Chris - I'm on my phone now so I haven't tried this, but I think changing ess-directory to default-directory should solve this issue. Alex On May 3, 2019 9:46:58 AM CDT, Chris Wallace via ESS-help wrote: >Dear ESS-help, > >I have just upgraded my ess via melpa, and my ability to run R remotely > >has stopped. > >I had been doing so via the function (after earlier help from this list > >https://stat.ethz.ch/pipermail/ess-help/2016-January/010863.html) > > (defun Rcpu () > "Run R on CSD3" > (interactive) > (let ((inferior-ess-r-program "/home/me/bin/R.csd3") > (ess-directory "/ssh:me@cpu:~/")) > (R))) > >R.csd3 is actually a bash script, that loads some modules required to >run R on the remote host before starting a recent version of R. It >worked this morning, then I did an update of packages, restarted emacs, > >and it broke. > > >Now when I M-x Rcpu I get the error > >Error (ess): /home/me/bin/R.csd3 could not be found on the system. Try >running `R-newest' instead, which searches your system for R. > >M-x R-newest starts /usr/bin/R on the remote system which is woefully >out of date and won't let me install many current packages. > >I have looked into R-newest and I wonder whether the change is this one > >https://github.com/emacs-ess/ESS/commit/7d49e421ca015c4e43688f4479860d1af8379c8d#diff-30e55f182c26885d03642d3872bfe26d > >- does > >(executable-find inferior-ess-r-program) > >know to look on the remote server? > >Thanks for any advice, > >Chris __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
[ESS] running R remotely via tramp
Dear ESS-help, I have just upgraded my ess via melpa, and my ability to run R remotely has stopped. I had been doing so via the function (after earlier help from this list https://stat.ethz.ch/pipermail/ess-help/2016-January/010863.html) (defun Rcpu () "Run R on CSD3" (interactive) (let ((inferior-ess-r-program "/home/me/bin/R.csd3") (ess-directory "/ssh:me@cpu:~/")) (R))) R.csd3 is actually a bash script, that loads some modules required to run R on the remote host before starting a recent version of R. It worked this morning, then I did an update of packages, restarted emacs, and it broke. Now when I M-x Rcpu I get the error Error (ess): /home/me/bin/R.csd3 could not be found on the system. Try running `R-newest' instead, which searches your system for R. M-x R-newest starts /usr/bin/R on the remote system which is woefully out of date and won't let me install many current packages. I have looked into R-newest and I wonder whether the change is this one https://github.com/emacs-ess/ESS/commit/7d49e421ca015c4e43688f4479860d1af8379c8d#diff-30e55f182c26885d03642d3872bfe26d - does (executable-find inferior-ess-r-program) know to look on the remote server? Thanks for any advice, Chris -- http://chr1swallace.github.io __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
[R] create a table for time difference (from t3 to t1, so on..)
Hi R User. I have a date set in which I wanted to find the duration (period) between released time and detection time for each individual. Is there any simplest way to create a matrix? I appreciate your help. Thanks, MW -- Here is the example data, dAT<-structure(list(Id = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 5L, 4L, 1L, 6L, 6L, 3L, 4L, 1L), .Label = c("a", "b", "c", "e", "f", "m"), class = "factor"), date = structure(c(1L, 1L, 1L, 5L, 4L, 1L, 5L, 5L, 3L, 1L, 2L, 7L, 6L, 8L), .Label = c("1-Jan-18", "1-Jul-18", "10-Mar-18", "15-Jan-18", "2-Jan-18", "27-Jan-18", "3-Jan-18", "7-Mar-19"), class = "factor")), .Names = c("Id", "date"), class = "data.frame", row.names = c(NA, -14L)) #and the results looks like Result<-structure(list(Id = structure(1:6, .Label = c("a", "b", "c", "e", "f", "m"), class = "factor"), intial.released.date = structure(c(1L, 1L, 1L, 2L, 2L, 1L), .Label = c("1-Jan-18", "2-Jan-18"), class = "factor"), duration.between.t2.and.t1 = c(14L, 0L, 2L, 0L, NA, 181L), duration.between.t3.and.t1 = c(68L, NA, NA, 25L, NA, NA), duration.between.t4.and.t1 = c(430L, NA, NA, NA, NA, NA), duration.between.t3.and.t2 = c(54L, NA, NA, NA, NA, NA), duration.between.t4.and.t2 = c(416L, NA, NA, NA, NA, NA)), .Names = c( "Id", "intial.released.date", "duration.between.t2.and.t1", "duration.between.t3.and.t1", "duration.between.t4.and.t1", "duration.between.t3.and.t2", "duration.between.t4.and.t2" ), class = "data.frame", row.names = c(NA, -6L)) [[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] Loading EDF files
Try samples[["sn"]] ? On Fri, May 3, 2019, 9:53 AM Eric Berger wrote: > Hi Mariano, > The problem appears to be that samples[[sn]] has zero length (or is NULL). > Consider the following code which gives the same error message. > > x <- 1:10 > x[1:5] <- as.numeric(NULL) > Error in x[1:5] <- as.numeric(NULL) : replacement has length zero > > HTH, > Eric > > On Fri, May 3, 2019 at 4:32 PM Marcelo Mariano Silva < > marcelomarianosi...@gmail.com> wrote: > > > Dear All, > > > > I have tried to load an EDF file using the code below and I received the > > following massage : > > > > Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] <- > samples[[sn]] : > > > > replacement has length zero > > > > What this massage means? > > Is there any problem with the EDF file? > > > > Code used: > > hdr <- readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf"); > > > > > > df_id1 <- readEdfSignals(hdr, signals = "All", from = 0, till = Inf, > > physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals = > > TRUE, simplify = TRUE); > > > > > > Any help would be highly appreciated. > > > > > > Mariano > > > > > > > > > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loading EDF files
Hi Mariano, The problem appears to be that samples[[sn]] has zero length (or is NULL). Consider the following code which gives the same error message. x <- 1:10 x[1:5] <- as.numeric(NULL) Error in x[1:5] <- as.numeric(NULL) : replacement has length zero HTH, Eric On Fri, May 3, 2019 at 4:32 PM Marcelo Mariano Silva < marcelomarianosi...@gmail.com> wrote: > Dear All, > > I have tried to load an EDF file using the code below and I received the > following massage : > > Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] <- samples[[sn]] : > > replacement has length zero > > What this massage means? > Is there any problem with the EDF file? > > Code used: > hdr <- readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf"); > > > df_id1 <- readEdfSignals(hdr, signals = "All", from = 0, till = Inf, > physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals = > TRUE, simplify = TRUE); > > > Any help would be highly appreciated. > > > Mariano > > > > > > > > [[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] Loading EDF files
Dear All, I have tried to load an EDF file using the code below and I received the following massage : Error in signals[[sn]]$signal[nextInCSignal[sn]:lastOne] <- samples[[sn]] : replacement has length zero What this massage means? Is there any problem with the EDF file? Code used: hdr <- readEdfHeader("/lasse/neurobit/edf/medidas/g1/G1medida1.edf"); df_id1 <- readEdfSignals(hdr, signals = "All", from = 0, till = Inf, physical = TRUE, fragments = TRUE, recordStarts = TRUE, mergeASignals = TRUE, simplify = TRUE); Any help would be highly appreciated. Mariano > > [[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.