Displaying 20 results from an estimated 200 matches similar to: "Paasing values to sqlQuery like SAS macro"
2013 Apr 03
5
Can package plyr also calculate the mode?
I am trying to replicate the SAS proc univariate in R. I got most of the
stats I needed for a by grouping in a data frame using:
all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
q75=quantile(COUNTS,.75),
q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
q99=quantile(COUNTS,.99) )
2013 Apr 05
2
How to perform a grouped shapiro wilk test on dataframe
Hello,
I was wandering if it is possible to perform on a dataframe called 'all' a
shapiro wilk normality test for COUNTS by variable Group
ACTIVITY? Could it be done using plyer? I saw an eg that applies to an
array but not to a dataframe:
lapply(split(dataset1$Height,dataset1$Group),shapiro.test)
Any thoughts would be much appreciated.
My dataframe is in shape:
dat ACTIVIT
2013 May 23
3
Removing rows w/ smaller value from data frame
Hello,
I have a column called max_date in my data frame and I only want to keep the
bigger values for the same activity. How can I do that?
data frame:
activity max_dt
A 2013-03-05
B 2013-03-28
A 2013-03-28
C 2013-03-28
B 2013-03-01
Thank you for your help
--
View this message in context:
2012 Nov 30
5
subset data frame by variable with missing value
Hello,
I have a variable in a data frame that contains NA values. I just want to
subset so that I get the obs where that variable is missing.
In SAS I would do:
data missing;
set test;
if myvalue=' ';
run;
How can I perform this simple task in R?
Thanks in advance for your help.
--
View this message in context:
2012 Oct 10
3
How to replicate SAS by group processing in R
Hello,
I am trying to re-code all my programs from SAS into R.
In SAS I use the following code:
proc sort data=upper;
by tdate stock_symbol expire strike;
run;
data upper1;
set upper;
by tdate stock_symbol expire strike;
if first.expire then output;
rename strike=astrike;
run;
on the following data set:
tdate stock_symbol expiration strike
9/11/2012 C 9/16/2012
2012 Sep 18
4
Conditional operations in R
Hello,
I am a newbie to R coming from SAS background. I am trying to program the
following:
I have a monthly data frame with 2 variables:
client pct_total
A 15%
B 10%
C 10%
D 9%
E 8%
F 6%
G 4%
I need to come up w/ a monthly list of clients that make 50% or just above
it every month so I can pass them to the rest of the program.
2012 Oct 19
4
Creating a new by variable in a dataframe
Hello,
I have a dataframe w/ 3 variables of interest: transaction,date(tdate) &
time(event_tim).
How could I create a 4th variable (last_trans) that would flag the last
transaction of the day for each day?
In SAS I use:
proc sort data=all6;
by tdate event_tim;
run;
/*Create last transaction flag per day*/
data all6;
set all6;
by tdate event_tim;
last_trans=last.tdate;
Thanks
2012 Nov 13
1
Using lubridate to increment date by business days only
Hello,
I know how to increment a date by calendar date:
ticker$ldate <- ticker$tdate + days(5)
How do I increment it by business days only so that week-ends are not
counted?
So for example friday november 2 + 5days becomes friday november 9 & not
wednesday nov 7.
Thanks for your help.
--
View this message in context:
2012 Aug 24
1
if then in R versus SAS
I am new to R and I have the following SAS statements:
if otype='M' and ocond='1' and entry='a.Prop' then MOC=1;
else MOC=0;
How would I translate that into R code?
Thanks in advance
--
View this message in context: http://r.789695.n4.nabble.com/if-then-in-R-versus-SAS-tp4641225.html
Sent from the R help mailing list archive at Nabble.com.
2013 Apr 12
2
Stat question: How to deal w/ negative outliers?
Hello all,
I have a question: I am using the interquantile method to spot outliers &
it gives me values of say 234 & -120 or for the higher & lower benchmarks.
I don't have any issues w/ the higher end. However I don't have any
negative values. My lowest possible value is 0. Should I consider 0 as an
outlier?
Thanks ahead for your thoughts
--
View this message in
2013 Apr 02
0
sqlFetch works but sqlQuery doesn't
I've been having some issues with sqlSave, and I think I've found an clue
that may identify the problem. In the code at http://pastebin.com/W6UGKep9,
I connect to a Netezza instance, make a simple table, and query it.
Despite sqlSave succeeding without error, sqlQuery tells me that the table
doesn't exist. Also, when I query the database outside of R, I see that
the table doesn't
2011 Aug 10
1
subqueries in sqlQuery function (package RODBC)
Hi R users.
sorry for missing example and if question is to general but I am wondering
if it is possible to execute subqueries in function sqlQuery (package RODBC)
with opened connection with Excel or SQL server 2000. I couldn't find any
example of this.
And if it is possible what should be a correct syntax for this query:
SELECT ct,COUNT(*) as n
FROM (SELECT COUNT(*) AS ct FROM children
2009 Oct 08
0
Problems With RODBC, sqlQuery
Hello,
Im trying to get a Oracle database to R, but I'm having problems with most
of SQL sintax. Suppose that Im trying to bring a table "TABLE" with columns
"COL1","COL2",.. from schema "SCHEMA". What am I doing wrong?
library(RODBC)
channel<-odbcConnect("xxx",uid="xxx",pwd="xxx")
sqlQuery(channel, "select *
2006 Jan 17
0
RODBC sqlQuery question
Why does this happen when I do a sqlQuery?
> sessionInfo()
Version 2.3.0 Under development (unstable) (2006-01-04 r36984)
powerpc-apple-darwin8.3.0
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "base"
other attached packages:
RODBC
"1.1-5"
> b
2005 Jan 11
1
RODBC package -- sqlQuery(channel,.....,nullstring=0) still gives NA's
R-help,
I'm using the RODBC package to retrieve data froma ODBC database which
contain NA's.
By using the argument nullstring = "0" in sqlQuery() I expect to
coerce them to numeric but still get NA's in my select.
I'm running on Windows XP
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386,
2008 Aug 12
1
[RODBC] date attribute in sqlQuery
Hello R users,
I would like to use an integer and a date as attributes in sqlQuery,
and these arguments
are defined in my function.
Here is my function:
GetReturn<-function(code,date)
{
channel<-odbcConnect("db","user1","password")
ssql<-paste("select * from TABLE Where PF_CODE =",code,"and PF_DATE=",date)
2009 Aug 20
1
problems with RODBC, sqlQuery
Hello,
Im trying to get a Oracle database to R, but I'm having problems with most
of SQL sintax. Suppose that Im trying to bring a table "TABLE" with columns
"COL1","COL2",.. from schema "SCHEMA". What am I doing wrong?
library(RODBC)
channel<-odbcConnect("xxx",uid="xxx",pwd="xxx")
sqlQuery(channel, "select * from
2012 Mar 28
1
Is it possible to de-select with sqlQuery from the RODBC library?
Dear R-list,
I'm queering a M$ Access database with the sqlQuery function from the RODBC library. As I cannot make a working example with a database here is an illustrative example,
library(RODBC)
mdbConnect<-odbcConnectAccess("S:/data/ ... /databse.mdb")
data <- sqlQuery(mdbConnect, "select id, DOB, V1, V2, ..., V1009, V1011, V1013 from someTable")
I want
2009 Sep 15
1
quoting a table name due to a special character in sqlQuery (RODBC)
Dear List,
I have a problem with RODBC on a Paradox-DB, sqlQuery, and special
characters in table names. Unfortunately, some of the latter include the
underscore <_>. And I am not able to change them.
That's not a problem, when I quote the table name:
> sqlQuery(channel2, 'SELECT * FROM "anmeldung-alt"')
Btw, if I swap ' and " it does not work:
>
2010 Oct 11
1
importing numeric types via sqlQuery
Hi everyone,
I am using the sqlQuery function (in RODBC library) to import data from a database into R. My table (called temp) in the database looks like this:
category numabc 54469517.307692307692def 36428860.230769230769
I used the following R code to pull data into R:data <-sqlQuery(channel, "select category, num from temp;")
However, the result is that "num" gets all its