Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Eric Berger
Definitely doable and you are on the right path and maybe even close. The error message you got showed your query as having the wrong info after the 'FROM' keyword ' SELECT * FROM c("BIODBX.MECCUNIQUE2", "BIODBX.QDATA_HTML_DUMMY", "BIODBX.SET_ITEMS", "BIODBX.SET_NAMES", "dbo.sysdiagrams", "GEMD.A

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Kai Yang via R-help
Hi Eric, Thank you spent time to help me for this. Here is the thing: I was requested to manage a sql server for my group. the server has many schemas and the tables (>200). I use ODBC to connect the server and get the schema name + table name into a data frame. For each of schema + table on s

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Jeff Newmiller
Not all advice received on the Internet is safe. https://xkcd.com/327 https://db.rstudio.com/best-practices/run-queries-safely It is not that much more difficult to do it right. On July 2, 2021 12:05:43 PM PDT, Eric Berger wrote: >Modify the summ() function to start like this > >summ <- functi

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Eric Berger
Hard for me to tell without more details but it looks like the following has several bugs for (i in dbtable$Tot_table) { Tabname <- as.character(sqldf(sprintf("SELECT Tot_table FROM dbtable", i))) summ(Tabname) } Your sprintf() statement seems to use 'i' but actually does not. You probably wa

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Kai Yang via R-help
Hello Eric, Following your suggestion, I modified the code as: summ <- function(Tabname){   query <- sprintf(" SELECT * FROM %s",Tabname)   res <- dbGetQuery(con, query)   view(dfSummary(res), file = "W:/project/_Joe.B/MSSQL/try/summarytools.Tabname.html")   rm(res) } for (i in dbtable$Tot_table

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Eric Berger
Modify the summ() function to start like this summ <- function(Tabname){ query <- sprintf(" SELECT * FROM %s",Tabname) res <- dbGetQuery(con, query) etc HTH, Eric On Fri, Jul 2, 2021 at 9:39 PM Kai Yang via R-help wrote: > Hello List, > > The previous post look massy. I repost my questio

[R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Kai Yang via R-help
Hello List, The previous post look massy. I repost my question. Sorry, I need to generate summary report for many tables (>200 tables). For each table, I can use the script to generate report: res <- dbGetQuery(con, "SELECT * FROM BIODBX.MECCUNIQUE2") view(dfSummary(res), file = "W:/project/_J

[R] R function question

2021-07-02 Thread Kai Yang via R-help
Hello List,I need to generate summary report for many tables (>200 tables). For each table, I can use the script to generate repost: res <- dbGetQuery(con, "SELECT * FROM BIODBX.MECCUNIQUE2")view(dfSummary(res), file = "W:/project/_Joe.B/MSSQL/try/summarytools.BIODBX.MECCUNIQUE2.html")rm(res) BI

Re: [R] Function question

2009-09-25 Thread Henrique Dallazuanna
Try this: foo <- function(expr, x){ eval(substitute(expr)) } foo(x^2, 4) foo(x^3-10, 2) On Fri, Sep 25, 2009 at 6:16 PM, njhuang86 wrote: > > Hi. I was wondering how I can write a function that generates the outcome > values for a user specified equation. For example, function(x^2, 4) w

[R] Function question

2009-09-25 Thread njhuang86
Hi. I was wondering how I can write a function that generates the outcome values for a user specified equation. For example, function(x^2, 4) will return back 16 and function(x^3 - 10, 2) will give back -2... I've been playing around with various lines of code but somehow, I just cannot get R to

Re: [R] function question

2009-03-20 Thread Wacek Kusnierczyk
ge- > From: Wacek Kusnierczyk [mailto:waclaw.marcin.kusnierc...@idi.ntnu.no] > Sent: Thursday, March 19, 2009 1:03 PM > To: Bert Gunter > Cc: Edna Bell; R help > Subject: Re: [R] function question > > Bert Gunter wrote: > >> Edna: >> >> Please make at le

Re: [R] function question

2009-03-19 Thread Bert Gunter
Not surprising at all -- expected! is.function(vector) ##TRUE -- Bert -Original Message- From: Wacek Kusnierczyk [mailto:waclaw.marcin.kusnierc...@idi.ntnu.no] Sent: Thursday, March 19, 2009 1:03 PM To: Bert Gunter Cc: Edna Bell; R help Subject: Re: [R] function question Bert Gunter

Re: [R] function question

2009-03-19 Thread Wacek Kusnierczyk
Bert Gunter wrote: > Edna: > > Please make at least a minimal effort to answer such questions before > posting. > > is.vector(function(x)x) ## FALSE > as.vector(function(x)x) ## try it > > or even > > is.vector(plot) > > ... or even the surprizing is.vector(vector) vQ ___

Re: [R] function question

2009-03-19 Thread Peter Dalgaard
Patrick Burns wrote: Duncan Murdoch wrote: On 3/19/2009 12:49 PM, Edna Bell wrote: Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? Your question is a little ambiguous (you probably did read that, and probably someone does consider them to be vect

Re: [R] function question

2009-03-19 Thread Gabor Grothendieck
In mathematics that is the case. That is vector v = (v_1, v_2, ..., v_n) can be considered to be the function which maps k to v_k but there is no real relation to this in terms of R classes and objects. On Thu, Mar 19, 2009 at 12:49 PM, Edna Bell wrote: > Dear R Gurus: > > I read somewhere that

Re: [R] function question

2009-03-19 Thread Patrick Burns
Duncan Murdoch wrote: On 3/19/2009 12:49 PM, Edna Bell wrote: Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? Your question is a little ambiguous (you probably did read that, and probably someone does consider them to be vectors), but I think the

Re: [R] function question

2009-03-19 Thread Bert Gunter
-project.org] On Behalf Of Edna Bell Sent: Thursday, March 19, 2009 9:50 AM To: r-h...@stat.math.ethz.ch Subject: [R] function question Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? thanks Edna Bell __ R

Re: [R] function question

2009-03-19 Thread Duncan Murdoch
On 3/19/2009 12:49 PM, Edna Bell wrote: Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? Your question is a little ambiguous (you probably did read that, and probably someone does consider them to be vectors), but I think the right answer is no: w

[R] function question

2009-03-19 Thread Edna Bell
Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? thanks Edna Bell __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/po

Re: [R] function question

2009-02-11 Thread jim holtman
Is this what you want: > x FL number 1 34 4 2 35 3 3 36 7 > cbind(rep(x$FL, x$number), 1) [,1] [,2] [1,] 341 [2,] 341 [3,] 341 [4,] 341 [5,] 351 [6,] 351 [7,] 351 [8,] 361 [9,] 361 [10,] 361 [11,] 361

[R] function question

2009-02-11 Thread Felipe Carrillo
Hi everyone: I did this before with R and I can't remember how. I got some fish forklength values FL number 344 353 367 I need to breakdown the FL by the number of fish with the same length like this: 34 1 34 1 34 1 34 1 35 1 35 1 35 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1

Re: [R] Function question

2008-10-17 Thread Dimitris Rizopoulos
try uniroot(), e.g., f <- function (x) x^2 uniroot(function(x, a) f(x) - a, c(0, 10), a = 4) I hope it helps. Best, Dimitris dennis11 wrote: Hi, Let's say very simply there is a function: f <- function (x) x^2 which is evaluated with : f(2) Now, I want to do the reverse so I want to no

[R] Function question

2008-10-17 Thread dennis11
Hi, Let's say very simply there is a function: f <- function (x) x^2 which is evaluated with : f(2) Now, I want to do the reverse so I want to now x for f(x) = 4 So, is there a way in R to solve x for some function f(x)=a? I hope I explained it clear. cheers, Dennis -- View this message