Folks,
I am looking for a means for calculating the 1-R^2 ratio for variable selection
to mimic the values of PROC VARCLUS in SAS. While there may be better methods
for variable selection, we are trying to duplicate published results at this
time.
To date, I have been unable to find a way to
Good morning folks,
Recently calls to sendmail() in the sendmailR package have occasionally failed
with the error if (code == lcode) { : argument is of length zero. The only
thing we are setting in the control argument is the smtp server
(control=list(smtpServer='smtp.epa.gov')), so the port
dat1[order(val), ] # Gives Error in order(val) : object 'val' not found
dat1[order(dat1[,2]), ] # Works just fine.
dat1[order(dat1$val), ]
unless you used attach(dat1).
Better to avoid 'attach' altogether and go with the first suggestion. That can
get rather unwieldy when ordering on
I have measured values for 47 chemicals in a stream. After processing
the original data frame through reshape2, the recast data frame has this
structure:
'data.frame': 256 obs. of 47 variables:
$ site : Factor w/ 143 levels BC-0.5,BC-1,..: 1 1 1 2 2 2 2 2
2 2...
$ sampdate :
Oh now wait a minute. If THATs considered old, what's next -- punch
cards? CDs?
cur - who knows the answers to that question and accepts the mantle of
authority conferred by time, though he may not actually live up to it.
From: Marc Schwartz marc_schwa...@me.com
Oh I knew that Carl?still
Alex writes:
Dear all,
...
a. Do you know if there is any system that can convert our R scripts
to html pages with some nice dependency graphs (which functions calls
which).
b. Could you please suggest me an easy way to exchange the R code
with my colleagues. I know about these version
Some might have noticed that REvolution Computing released the doSMP
package to the general public about a month and a half ago, which allows
multiple cores to be accessed for parallel computation in R. Some of our
physical habitat calculations were taking an extraordinary amount of time
to
How do I remove all objects except one in R?
rm(list=ls()) #will remove ALL objects
But he wanted to remove all objects ***except one***!!! So what's the
point of this answer?
I can't see any way except a rather round-about kludge to do what the
OP wants. ...
That might work. Or
I have a bunch of geographic locations specified by lat-long
coordinates. What's an easy way to calculate geographic distance
between any two points? OR, perhaps there is a function for
calculating a distance matrix for K sites?
A comparison of some geographic distance calculations is
Alexis wrote:
Can anyone tell me why I would get different average nearest neighbor
values
for the same set of coordinates between ArcGIS 10 and R? Sometimes the
difference in distance is over 1.3 km.
spatstat::nndist calculates Euclidean distances rather than distances
along the earth's
A comparison of some geographic distance calculations is provided at
http://pineda-krch.com/2010/11/23/great-circle-distance-calculations-in-r/
, along with code for calculating the Vincenty inverse formula, which
relies on the WGS-84 ellipsoid approximations.
You know, Scott, I should
I often get this error missing value where TRUE/FALSE needed when
I'm doing some loops, like with this one
...
Can someone explain me what I do wrong because I don't see the
difference with other loops that work
It's probably not the loop that's biting you, but rather the data. This
is
s-start; e-end
middle-as.character(c(1,2,3))
I would like to get the following result:
start 123 end or start 1 2 3 end or start 1,2,3 end
How can I avoide this (undesired) result:
paste(s,middle,e,sep= )
Sometimes you just have to do something more than once:
paste(s, paste(middle,
Gary/Hongwei writes:
I'm wondering how I can aggregate data in R with different functions for
different columns. For example:
x-rep(1:5,3)
y-cbind(x,a=1:15,b=21:35)
y-data.frame(y)
I want to aggregate a and b in y by x. With a, I want to use
function mean; with b, I want to use function
So I was thinking of embedding it into a if else loop but I am stuck on
how
to define the belongs to in R syntax. Any hint will be much
appreciated.
?ifelse# handles vectors, while if() handles single values
?'%in%'# also see match() and which()
Enjoy the day,
cur
--
Curt Seeliger,
Dr. Anthony wrote on 01/05/2011 01:19:49 PM:
This may be a question with a really obvious answer, but I
can't find it. I have access to a large file with real
medical record identifiers (mixed strings of characters and
numbers) in it. ...
It's not that trivial of a question, or more
Amelia of Aukland writes:
Suppose instead of having above dataframe having single data for
variable 1 and variable 2, I have following data as
variable_1 variable_2
10 20
40 30
3
Luca wrote on 12/09/2010 09:38:07 AM:
...
What I am trying to do is to build another variable fine1 that
should contain the lagged value for fine, that is:
xfine fine1
1 A 2010-12-09 07:57:33 NA
2 B 2010-12-09 08:05:00 2010-12-09 07:57:33
3 C 2010-12-08
mathijsdevaan wrote on 12/09/2010 04:21:54 PM:
I have two columns with data (both identifiers - it's an affiliation
list)
and I would like to delete the rows in which the observations in the
second
column have a frequency 5 in the entire second column. Example:
1 a
1 b
1 c
Is there any similar function in R to the first. in SAS?
?duplicated
a$d - ifelse( duplicated( a$a ), 0 , 1 )
a$d.2 - as.numeric( !duplicated( a$a ) )
Actually, duplicated does not duplicate SAS' first. operator, though it
may suffice for the OP's needs.
To illustrate,
...
# I've found I need to lag a column to mimic SAS' first.
# operator, thusly, though perhaps someone else knows
# differently. Note this does not work on unordered
# dataframes!
lag.k1 - c(NA, tt$k1[1:(nrow(tt) - 1)])
tt$r.first.k1 - ifelse(is.na(lag.k1), 1, tt$k1 != lag.k1)
Say I need to keep ID 1,2,4,5, 10 from the data frame dat. I can do:
dat - data.frame(ID = 1:10, var = 1:10)
someID - c(1,2,4,5,10)
subset(dat, dat$ID %in% someID)
Is there a quick way to do the opposite ...
Two operators spring to mind: ! and %nin
subset(dat, !(dat$ID %in% someID))
Michael writes:
I can use data() to find the available datasets in a package, but I'd
like to extract and display some additional
information for each dataset than what is provided by data(), e.g.,
class() and dim() for datasets for which
these are available.
...
for all datasets in
Sebastian writes:
I have a huge vector of numbers, how I can invert orden?
For example
x - 1:1000
I would like to obtain
x_r - 1000:1
Well, 1000:1 works for me. If you need to rev()erse a pre-existing
vector, try rev().
cur
--
Curt Seeliger, Data Ranger
Raytheon Information
Is there anything comparable to the mac version of R with its built in
console, editor, etc??
Aside from ESS/EMACS, you might try JGR, Tinn-R and Eclipse with StatET.
The later has the most features and is the best IDE, and we're in the
process of migrating to it from Tinn-R.
cur
--
Curt
The reason R is powerful is becasue it can handle large vectors without
each
element being manipulated? Please let me know where I am wrong.
for(i in 1:length(news1o)){
+ if(news1o[i]s2o[i])
+ s[i]-1
+ else
+ s[i]--1
+ }
You might give ifelse() a shot here.
s - ifelse(news1o s2o, 1,
Thomas writes:
... Until then and until I can
convince colleagues and teachers to use better
software, how do you suggest that I learn SAS?
I suspect that it'll be a book on R for SAS-users,
so I'm expecting recommendations of books like
those that are best for R-users learning SAS.
As it
I want to be able to rotate a matrix 90 degrees, clockwise.
For example,
mat
[,1] [,2] [,3]
[,1] 12 1
[,2] 32 6
[,3] 45 3
I want to rotate it, so that it looks like this...
[,1] [,2] [,3]
[,1] 43 1
[,2] 52 2
mat
# [,1] [,2] [,3]
# [1,]121
# [2,]326
# [3,]453
matrix(rev(mat),nrow=3,byrow=TRUE)[(3:1),]
# [,1] [,2] [,3]
# [1,]431
# [2,]522
# [3,]361
How's that? (But
Patrick Burns pbu...@pburns.seanet.com
* What were your biggest misconceptions or
stumbling blocks to getting up and running
with R?
I came into R from SAS, with its powerful data step language and very
simplified data types. Most of my work is data manipulation prior to a
variety of
r-help-boun...@r-project.org wrote on 01/25/2010 02:39:32 PM:
x - read.table(textConnection(col1 col2
3 1
2 2
4 7
8 6
5 10), header=TRUE)
I want to rewrite it as below:
var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
1 0 1 0 0 0 0 0 0
r-help-boun...@r-project.org wrote on 01/25/2010 03:32:41 PM:
Jim writes to David:
These days I tend to use RJDBC http://www.rforge.net/RJDBC/ which is a
bit less of a hassle.
Hint use the jtds driver http://jtds.sourceforge.net/
...
I have a client running Microsoft SQL Server. I am
[stuff about SAS CARDS statement, I think]
INPUT survey $ 1-2 seasonal $ 3 state $ 4-5 area $ 6-10 supersector
$
11-12 @13 industry $8. datatype $ 21-22 year period $ value footnote
$ ;
...
This just seems like horrendously bad practice, which is one reason
it's kludgy in R. If it
Corrado writes:
I do not understand what more information! Take any vector of length 1,
for
example x-1. Plus all the command that where in my previous email
What is the logic behind
identical(length(x),1)
being false?
identical() returns FALSE because they are not identical,
Folks,
An RUnit test suite is failing after all tests are complete with the
following message:
Error in parse(n = -1, file = file) : unexpected '}' at
620:
621: }
All individual tests work when run individually, and all but one run
within the RUnit test suite. What
An RUnit test suite is failing after all tests are complete with the
following message:
Error in parse(n = -1, file = file) : unexpected '}' at
620:
621: }
...
You need to take a look at the file that was being passed to parse. One
way to do this is
Folks,
In brief -- how many of you have found the 'operators' package to be
valuable in their work?
Not that I lack respect for the amount of work involved in creating and
maintaining a package, but I am unsure about the utility of these new
operators. Several of the operators appear to
Thanks for replying, Francois.
To directly answer your question, the difference between using base R
functions and a library comes down to code correctness and stability, as
well as future support. Portions of the language, whether in base or in
packages, which have been around a long time,
... I saw my friend has a R Console window which has automatic syntax
reminder when he types in the first a few letters of R command. ...
You might be thinking of JGR (Jaguar) at
http://jgr.markushelbig.org/JGR.html . This editor also prompts you with
function argument lists, including for
Thanks for beating me to that, Gabor. The %OS format spec isn't in the
strptime() docs. How else might we have found this for ourselves?
cur
r-help-boun...@r-project.org wrote on 05/26/2009 02:59:20 PM:
as.POSIXct(c(06:00:00.100,06:00:01.231), format = %H:%M:%S%OS)
[1] 2009-05-26
Use format,
format(myt, %H:%M:%S%OS)
--
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638
Thanks, that worked. However, is there is way to just get the time
and not have the date added? I assume the date is added since POSIX
is
Madan asks:
I am trying to import a table from SQL server to R(2.9.0), however i am
getting errors while running the below codes. Can anyone identify and
let me
know where did i go wrong??? Thanks in anticipation :)
...
NEWDATASQL1 - sqlFetch(myconne, CampaignDataLarge)
Error in
Kynn writes:
So I'm curious to learn what strategies R users have found to get around
this annoyance.
I use Rseek for most of my R questions: http://www.rseek.org/
cur
--
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638
Correction:
University of Oregon
http://www.fsl.orst.edu/R_users - (unknown if currently active)
Kenneth B. Pierce Jr.
ken.pierce at oregonstate edu
That's not University of Oregon, it's Oregon State University. U of O is
in Eugene.
They don't seem to be recently active in any
To my earlier question about updating a dataframe, and certainty that this
has been solved several times before, Dr. Winsemius suggests (Thanks!):
I am sure this is not the most elegant method, but it will work.
new - merge(nn,uu, by = c(a,b), all.x=T)
new$y - with( new,
Folks,
Updating values in a table is simple in SAS or SQL, but I've wracked my
brain looking for an elegant solution in R to no avail thus far. Certainly
this is a common need that's been solved in dozens of different ways.
Given an initial dataframe nn and a smaller dataframe of updates uu,
Folks,
The code below reliably crashes an R 2.8.1 session on XP when connected to
an SQL Server 2005 database. The problem arises when appending data using
sqlSave() with rownames=FALSE to a table that had been previously created
with rownames=TRUE. Certainly it's daft to do this as a
Folks,
As reproduced in the code below, our data is being transformed during the
sqlFetch() operation. This has apparently been an issue since 2002. Are
there any ways for correctly reading data from MS SQL Server 2005? Why
does RODBC ignore the type information supplied by SQL Server?
kayj asks:
I have a problem with ifelse(), I do not understand how it works.
X-c(2,2,1,1,0,0)
str(X)
num [1:6] 2 2 1 1 0 0
Y-ifelse(X0,1,0)
Y
[1] 1 1 1 1 0 0
Since X is a vector, the operation X0 is also a vector. The function
ifelse() is correctly providing output for each
Folks,
I'm checking the structure of a dataframe for duplicate parameters at a
site station (i.e depth should be measured once, not twice), using
aggregate to count each parameter within a site station. The fake data
below has only 26000 rows, and takes roughly 14 seconds. My real data has
Wow, table() works wonderfully fast! Thank you for pointing it out to me.
I still need to associate those counts with specific
parameter/station/site combinations, and I'm as stumped by that as I am by
the object returned by by(). It looks like I can do the following:
tmp - with(df1,
Folks,
I am creating a small package which builds just fine but fails the check
during the installation phase, as it can not find the files I am
source()ing:
cannot open file 'c:\PROGRA~1\R\R-28~1.0\library\nla\nlamets.r': No
such file or directory
The path to the files are predicated on
OK, this should be trivial but I'm not finding it. I want to compress
the test,
if (i==7 | i==10 | i==30 | i==50) {}
into something like
if (i in c(7,10,30,50)) {}
so I can build a excludes vector
excludes - c(7,10,30,50)
and test
if (i in excludes) {}
Works for me.
Could I suggest that citation() be modified to include
the URL automatically?
I second this suggestion. I experienced similar case once as well.
Thanks for pointing that function out to me. When I run it, the URL is
included:
citation()
To cite R in publications use:
R Development
Well, I am going to type in ever value because the data sheets are of
counts of insects that I identified, so I should be okay with
accuracy... I really just need something that allows for more than
256 columns as I have encounter over 256 species of insects in even
small streams. ...
Oh,
Folks,
I've been running into an odd situation that occurs when I use length()
function with aggregate(), but not with either one separately. Together,
the results looks correct but is given an unexpected name. 'if
(stringsAsFactors) factor(x) else x' instead of just 'x'.
# Numbers work ok
That's a great work around, as I can eliminate renaming the results column
from 'x' to whatever. Thanks for the quick tip, Henrique.
On the other hand, I'm still stumped as to why aggregate() would name an
output column as 'if (stringsAsFactors) factor(x) else x'. That sort of
behaviour
57 matches
Mail list logo