Re: [R] return value of {....}

2023-01-15 Thread Sorkin, John
Avi, Please do not mistake my posting as being a BASHING of R. I greatly admire R and the progress it has made from its roots in S. I thank the may people who contribute to the development and growth of R. Just because a language allows a given syntax does not mean (1) that the language is

Re: [R] return value of {....}

2023-01-15 Thread avi.e.gross
Again, John, we are comparing different designs in languages that are often decades old and partially retrofitted selectively over the years. Is it poor form to use global variables? Many think so. Discussions have been had on how to use variables hidden in various ways that are not global, such

Re: [R] return value of {....}

2023-01-15 Thread avi.e.gross
Richard, I appreciate your observations. As regularly noted, there are many possible forks in the road to designing a language and it seems someone is determined to try every possible fork. Yes, some languages that are compiled, or like JavaScript, read the entire function before executing it

Re: [R] return value of {....}

2023-01-15 Thread Bert Gunter
Sorry, John. If I understand you correctly, R has no "Global Variables" in the sense that you seem to indicate. It does have a "Global environment", but variables referred to in a function but not found in the function environment are *not* necessarily searched for in the "Global Environment" --

Re: [R] return value of {....}

2023-01-15 Thread Sorkin, John
Richard, I sent my prior email too quickly: A slight addition to your code shows an important aspect of R, local vs. global variables: x <- 137 f <- function () { a <- x x <- 42 b <- x list(a=a, b=b) } f() print(x) When run the program produces the following: >

Re: [R] return value of {....}

2023-01-15 Thread Bert Gunter
Well, weirdness is in the eyes of the beholder, I think. In any case, R's scoping procedures are described in ?environment and ?assign and ?function, among other places; and in detail in the R Language Definition. So no matter the behavior, as long as it is clearly documented -- and consistent of

Re: [R] return value of {....}

2023-01-15 Thread Sorkin, John
Richard, A slight addition to your code shows an important aspect of R, local vs. global variables: x <- 137 f <- function () { a <- x x <- 42 b <- x list(a=a, b=b) } f() print(x) From: R-help on behalf of Richard O'Keefe

Re: [R] return value of {....}

2023-01-15 Thread Richard O'Keefe
I wonder if the real confusino is not R's scope rules? (begin .) is not Lisp, it's Scheme (a major Lisp dialect), and in Scheme, (begin (define x ...) (define y ...) ...) declares variables x and y that are local to the (begin ...) form, just like Algol 68. That's weirdness 1. Javascript had a

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread Rui Barradas
Às 16:54 de 15/01/2023, Sorkin, John escreveu: I am new to this thread. At the risk of presenting something that has been shown before, below I demonstrate how a column in a data frame can be dropped using a wild card, i.e. a column whose name starts with "th" using nothing more than base r

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread avi.e.gross
John, As you said, you are new to the discussion so let me catch you up. The original question was about removing many columns that shared a similar feature in the naming convention while leaving other columns in-place. Quite a few replies were given on how to do that including how to use a

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread Sorkin, John
I am new to this thread. At the risk of presenting something that has been shown before, below I demonstrate how a column in a data frame can be dropped using a wild card, i.e. a column whose name starts with "th" using nothing more than base r functions and base R syntax. While additions to R

Re: [R] return value of {....}

2023-01-15 Thread akshay kulkarni
Dear valentin, Thanks for a comprehensive background THanking you, Yours sincerely, AKSHAY M KULKARNI From: Valentin Petzel Sent: Friday, January 13, 2023 4:48 AM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] return

Re: [R] return value of {....}

2023-01-15 Thread akshay kulkarni
Dear Bill, Thanks for your reply. thanking you, Yours sincerely, AKSHAY M KULKARNI From: Bill Dunlap Sent: Friday, January 13, 2023 10:48 PM To: Valentin Petzel Cc: akshay kulkarni ; R help Mailing list Subject: Re: [R] return value of

Re: [R] return value of {....}

2023-01-15 Thread akshay kulkarni
dear Heinz, Thanks for your replyreason is as old as the Sun..! THanking you, Yours sincerely, AKSHAY M KULKARNI From: R-help on behalf of Heinz Tuechler Sent: Friday, January 13, 2023 4:30 PM To: r-help@r-project.org Subject: Re: [R]

Re: [R] return value of {....}

2023-01-15 Thread akshay kulkarni
Dear leonard, I think Avi's repsonse was best...it's just a design...as he said, there are other possibilities in other programming languages which augments this design...thanks anyways for your reply... THanking you, Yours sincerely, AKSHAY M KULKARNI

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread Valentin Petzel
Hello Avi, while something like d$something <- ... may seem like you're directly modifying the data it does not actually do so. Most R objects try to be immutable, that is, the object may not change after creation. This guarantees that if you have a binding for same object the object won't