search for: srcfilecopy

Displaying 20 results from an estimated 28 matches for "srcfilecopy".

2013 Jun 24
0
sys.source() does not provide the parsing info to eval()
...UT: Dotted pair list of 3 $ : language eval(parse(text = code)) $ : language eval(expr, envir, enclos) $ :length 1 (function() print(str(sys.calls())))() ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 1 1 42 1 42 1 1 .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x7f42951fc388> As you can see, when using eval() directly, the expression/call has the parsing information available in the "srcref" attribute, but not when using sys.source() Looking at sys.source() implementation, this seems to be caused by...
2012 May 25
4
Problem sourcing file
Hi all, I created a file to define some functions. When I try to source this file, sometimes it works but sometimes I get the following error: >Source(‘File.R’) Error in srcfilecopy(filename, lines, file.info(filename)[1, "mtime"]) : unused argument(s) (file.info(filename)[1, "mtime"]) It works when I just started the R session, but after using some libraries when I do the source of the file again, I get this error. I can not really follow what step...
2024 May 28
2
Segfault when parsing UTF-8 text with srcrefs
Hi all, When I run the following code, R segfaults: text <- "?" srcfile <- srcfilecopy("test.r", text) parse(textConnection(text), srcfile = srcfile) It doesn't segfault if text is ASCII, or it's not wrapped in textConnection, or srcfile isn't set. Hadley -- http://hadley.nz [[alternative HTML version deleted]]
2016 Mar 13
1
formals(x)<- drops attributes including class
...causes any attributes to be dropped: EXAMPLE: > fcn <- structure(function() {}, foo="foo", class=c("foo")) > str(fcn) function () - attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 18 1 30 18 30 1 1 .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x000 000000c00d128> - attr(*, "foo")= chr "foo" - attr(*, "class")= chr "foo" > formals(fcn) <- list(a=1) > str(fcn) function (a = 1) > attributes(fcn) NULL TROUBLESHOOTING: >From the definition...
2024 May 28
1
Segfault when parsing UTF-8 text with srcrefs
On 5/28/24 19:35, Hadley Wickham wrote: > Hi all, > > When I run the following code, R segfaults: > > text <- "?" > srcfile <- srcfilecopy("test.r", text) > parse(textConnection(text), srcfile = srcfile) > > It doesn't segfault if text is ASCII, or it's not wrapped in > textConnection, or srcfile isn't set. Thanks, this is because R parser doesn't support non-ASCII UTF-8 outside string literals...
2013 Dec 13
1
Proper way to drop 'srcref' from an expression created via substitute(function() ...)?
...itute(function(x) a*x, list(a=2)) > print(exprA) function(x) 2 * x > str(as.list(exprA)) List of 4 $ : symbol function $ :Dotted pair list of 1 ..$ x: symbol $ : language 2 * x $ :Class 'srcref' atomic [1:8] 1 20 1 34 20 34 1 1 .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x00000000111feaf8> whereas this does not: > exprB <- substitute(a*x, list(a=2)) > print(exprB) 2 * x > str(as.list(exprB)) List of 3 $ : symbol * $ : num 2 $ : symbol x Second, what is the proper way to drop that 'srcref' eleme...
2023 Mar 30
1
removeSource() vs. function literals
...expressions containing function definitions also contain the source references for the functions, not as an attribute, but as a separate argument to the `function` call: str(quote(function() NULL)[[4]]) # 'srcref' int [1:8] 1 11 1 25 11 25 1 1 # - attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' # <environment:0x55aba55a8a50> This means that removeSource() on an expression that would define a function when evaluated doesn't actually remove the source reference from the object. Do you think it would be appropriate to teach removeSource() to remove such...
2012 Jan 11
1
parse( connection) and source-keeping
...t; parse( textConnection( texto)) expression(function() { }) and yes I didn't bother closing any connections. My suspicion is that this change is unintentional, and it seems to me that the best option would be for 'connection' to work like 'text' does here, ie to attach a 'srcfilecopy' containing the contents. I didn't submit a bug report because the documentation (which hasn't changed in this respect) actually doesn't say what 'parse' should do with 'connection' (as opposed to 'text' or 'file') argument when 'getOption( keep....
2017 Aug 28
3
[bug report] Cyrillic letter "я" interrupts script execution via R source function
...## COMMENT THIS LINE ####* > > * if (isTRUE(keep.source)) {* > > * lines <- scan(file, what="character", encoding = encoding, sep >> = "\n")* > > * on.exit()* > > * close(file)* > > * srcfile <- srcfilecopy(filename, lines, >> file.mtime(filename)[1], * > > * isFile = TRUE)* > > * } * > > *...* > > I do not fully understand this weird behaviour, so I ask help of R Core developers to fix this annoying bug that prevents using unicode s...
2023 Mar 31
2
removeSource() vs. function literals
...;> contain the source references for the functions, not as an attribute, >> but as a separate argument to the `function` call: >> >> str(quote(function() NULL)[[4]]) >> # 'srcref' int [1:8] 1 11 1 25 11 25 1 1 >> # - attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' >> # <environment:0x55aba55a8a50> >> >> This means that removeSource() on an expression that would define a >> function when evaluated doesn't actually remove the source reference >> from the object. >> >> Do you think it...
2024 May 30
1
[External] Re: Segfault when parsing UTF-8 text with srcrefs
...gt; This email originated outside the University. Check before clicking links > or attachments. > > On 5/28/24 19:35, Hadley Wickham wrote: > > Hi all, > > > > When I run the following code, R segfaults: > > > > text <- "?" > > srcfile <- srcfilecopy("test.r", text) > > parse(textConnection(text), srcfile = srcfile) > > > > It doesn't segfault if text is ASCII, or it's not wrapped in > > textConnection, or srcfile isn't set. > > Thanks, this is because R parser doesn't support non-ASCII UT...
2023 Mar 30
2
removeSource() vs. function literals
...on definitions also > contain the source references for the functions, not as an attribute, > but as a separate argument to the `function` call: > > str(quote(function() NULL)[[4]]) > # 'srcref' int [1:8] 1 11 1 25 11 25 1 1 > # - attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' > # <environment:0x55aba55a8a50> > > This means that removeSource() on an expression that would define a > function when evaluated doesn't actually remove the source reference > from the object. > > Do you think it would be appropriate to t...
2016 Oct 12
2
How to assign NULL value to pairlist element while keeping it a pairlist?
...> expr <- quote(function(x = 1) x) >> str(as.list(expr)) > List of 4 > $ : symbol function > $ :Dotted pair list of 1 > ..$ x: num 1 > $ : symbol x > $ :Class 'srcref' atomic [1:8] 1 15 1 29 15 29 1 1 > .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' > <environment: 0x13918b8> > > Here the 2nd element is a pairlist: > >> str(expr[[2]]) > Dotted pair list of 1 > $ x: num 1 >> typeof(expr[[2]]) > [1] "pairlist" > > Now say that I want to update the default value of ar...
2016 Oct 12
2
How to assign NULL value to pairlist element while keeping it a pairlist?
Hi Henrik, It would help to understand your use case for pairlists. Thanks, Michael On Wed, Oct 12, 2016 at 9:40 AM, Michael Lawrence <michafla at gene.com> wrote: > The coercion is probably the most viable workaround for now, as it's > consistent with what happens internally for calls. All pairlists/calls > are converted to list for subassignment, but only calls are
2016 Oct 19
2
How to assign NULL value to pairlist element while keeping it a pairlist?
...; List of 4 > >> $ : symbol function > >> $ :Dotted pair list of 1 > >> ..$ x: num 1 > >> $ : symbol x > >> $ :Class 'srcref' atomic [1:8] 1 15 1 29 15 29 1 1 > >> .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' > >> <environment: 0x13918b8> > >> > >> Here the 2nd element is a pairlist: > >> > >>> str(expr[[2]]) > >> Dotted pair list of 1 > >> $ x: num 1 > >>> typeof(e...
2007 Jan 07
1
substitute creates an object whichprints incorrectly (PR#9427)
> I think we should get rid of source attributes completely, > since they are no longer needed, but your comment still > applies to source references. We should strip them when code > gets modified. > > Duncan Murdoch I would be very concerned about losing source attributes-- it would break a lot of my code :(! It's very useful to have a single portable R object that
2016 Oct 12
0
How to assign NULL value to pairlist element while keeping it a pairlist?
...epresent the arguments. For example, > expr <- quote(function(x = 1) x) > str(as.list(expr)) List of 4 $ : symbol function $ :Dotted pair list of 1 ..$ x: num 1 $ : symbol x $ :Class 'srcref' atomic [1:8] 1 15 1 29 15 29 1 1 .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x13918b8> Here the 2nd element is a pairlist: > str(expr[[2]]) Dotted pair list of 1 $ x: num 1 > typeof(expr[[2]]) [1] "pairlist" Now say that I want to update the default value of argument 'x', which is currently 1, to NULL....
2013 Oct 24
0
TR: problem with ecdf : "missing C_R_approxfun" message
...chr [1:3] "ecdf" "stepfun" "function" ..- attr(*, "call")=length 2 ecdf(test.moms[, "m.pxs"]) .. ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 12 1 12 36 1 36 12 12 .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x07d7b3b0> [skip following structure...] In September I upgraded to R.3.0.1 under the same OS I need to use my previously recorded ecdfs again, and try to plot one as in : > plot(first.list[[1]]$size.ecdf,col=couleurs[1],main="first ecdf&quot...
2017 Aug 28
0
[bug report] Cyrillic letter "я" interrupts script execution via R source function
.../>/ />/ * if (isTRUE(keep.source)) {* />/ />/ * lines<- scan(file, what="character", encoding = encoding, sep />>/ = "\n")* />/ />/ * on.exit()* />/ />/ * close(file)* />/ />/ * srcfile<- srcfilecopy(filename, lines, />>/ file.mtime(filename)[1], * />/ />/ * isFile = TRUE)* />/ />/ * } * />/ />/ *...* />/ />/ /I do not fully understand this weird behaviour, so I ask help of R Core developers to fix this annoying bug that p...
2016 Oct 15
0
How to assign NULL value to pairlist element while keeping it a pairlist?
...str(as.list(expr)) >> List of 4 >> $ : symbol function >> $ :Dotted pair list of 1 >> ..$ x: num 1 >> $ : symbol x >> $ :Class 'srcref' atomic [1:8] 1 15 1 29 15 29 1 1 >> .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' >> <environment: 0x13918b8> >> >> Here the 2nd element is a pairlist: >> >>> str(expr[[2]]) >> Dotted pair list of 1 >> $ x: num 1 >>> typeof(expr[[2]]) >> [1] "pairl...