Displaying 20 results from an estimated 5000 matches similar to: "R command to compare two vectors?"
2012 Jan 19
2
POSIXct value display incorrect for some values
First, the reproducable example, showing how converting from character to
POSIXct to character changes the milliseconds in the first time stamp
though not in the second:
> as.POSIXct('2010-06-03 9:03:58.324')
[1] "2010-06-03 09:03:58.323 PDT"
> as.POSIXct('2010-06-03 9:03:58.325')
[1] "2010-06-03 09:03:58.325 PDT"
This seems to be due to truncation of
2008 Aug 28
1
Interaction between aggregate() and length()
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
tt <- data.frame(idx=c(1,1,1,1,1,1,2,2,2,2,2,2)
2009 Apr 02
1
Updating a data frame
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, I'd
like to replace the values in
nn <- expand.grid('a'=1:4, 'b'=1:3)
2009 Feb 10
1
aggregate taking way too long to count.
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
750000 rows and I had to stop execution after about an hour. The by()
function is faster, but I
2010 Sep 01
2
invert order
Dear R-help list users,
I have a huge vector of numbers, how I can invert orden?
For example
x <- 1:10000000
I would like to obtain
x_r <- 10000000:1
Thanks,
Sebastian.
2010 Dec 09
1
how to use diff() with different variables?
Hi,
I first should say I am new to R. I have searched without success the R-archives to see if I could find an answer to what I am about to ask you.
My dataset is like:
x fine
1 A 2010-12-09 07:57:33
2 B 2010-12-09 08:05:00
3 C 2010-12-08 20:42:00
...
that is:
'data.frame': 3 obs. of 2 variables:
$ x : Factor w/ 3 levels "A","B","C":
2011 Jul 13
3
Colors in R
HI everyone,
I''m trying to assign colors to multiple lines in a graph. Problem is I don''t want to type in as many colors as there are lines....is there a way around this? In brief, I''m plotting the logratio for up to 60 samples and want a different color for each sample. Here is the code I''m using now..
Any help is greatly appreciated..
Best
LT
data <-
2009 Apr 22
2
R-User groups in North America (SF, LA, NYC, Ottawa)
Hi R folks,
I'd like to announce several new R users groups here in SF, LA, NYC,
and Ottawa - as well as their next scheduled event. The goal of these
user groups, besides gently explaining 'drop=TRUE' to the uninitiated,
is to exchange knowledge, promote best practices, and spur the
adoption of R for innovative applications. If I've missed any groups
here, please feel to add on
2008 Dec 11
3
Logical "in" test
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) {}
However, I'm not finding a clue on how to accomplish this, if it can
be done. Would someone with more R
2011 Apr 11
4
nndist R vs. ArcGIS
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.
Alexis
--
View this message in context: http://r.789695.n4.nabble.com/nndist-R-vs-ArcGIS-tp3442375p3442375.html
Sent from the R help mailing list archive at Nabble.com.
2010 Dec 10
3
Delete observations with a frequency < x
Hi,
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
2 a
2 b
2 d
Let's say, I would like to delete the rows in which the observation in the
second column has a frequency < 2 in
2011 Feb 25
6
preventing repeat in "paste"
Hello!
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=" ")
Thank you!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
2011 Apr 19
3
How to program with colleagues
Dear all,
my colleagues and I have to write some R code for some of our projects.
I would like to ask you help to organize us a little.
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
2010 Nov 05
4
subsets, %in%
Hi,
I have a question about %in% and subsettin data frames.
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, ie to do a subset that contains
all ID but someID? Something like %not in%, which would *remove* lines with
ID in
2012 Jan 27
2
PosixCT subsecond accuracy
A sample of the data I have is:
> head(sensor)
logged_on accx accy accz compassx compassy compassz
gyrox gyroy gyroz
1 1326561428000 -0.4602 0.8346 0.0936 0.145508 -0.350586 0.259766
59.617390 28.521740 59.617390
2 1326561428050 -0.4212 1.0452 0.1326 0.219727 -0.321289 0.241211
88.695656 27.478260 88.695656
3 1326561428100 -0.2496 1.3416 0.2886 0.214844 -0.326172
2010 Aug 02
7
Linux Editor
Hi Everyone,
I recently have started using R again on a Linux box after spending several
years on a Mac. Last I checked, the best way to use R was through EMACS
using something like ESS. I remember that being serviceable but not always
the most convenient.
Is there anything comparable to the mac version of R with its built in
console, editor, etc??
thanks!
--
View this message in context:
2010 Jan 25
5
Data transformation
Dear all,
I have a dataset that looks like this:
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 0
0 2 0 0 0 0 0 0 0 0
0 0 0 1 0 0
2011 Jan 05
3
Advice on obscuring unique IDs in R
Dear colleagues,
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. These represent medical events for many
thousands of people. It's important to be able to link
events for the same people.
It's much more important that the real record numbers
2005 Oct 07
2
Assign references
Folks,
I've run into trouble while writing functions that I hope will create
and modify a dataframe or two. To that end I've written a toy function
that simply sets a couple of variables (well, tries but fails).
Searching the archives, Thomas Lumley recently explained the <<-
operator, showing that it was necessary for x and y to exist prior to
the function call, but I haven't
2005 Jul 12
4
Calculation of group summaries
I know R has a steep learning curve, but from where I stand the slope
looks like a sheer cliff. I'm pawing through the available docs and
have come across examples which come close to what I want but are
proving difficult for me to modify for my use.
Calculating simple group means is fairly straight forward:
data(PlantGrowth)
attach(PlantGrowth)
stack(mean(unstack(PlantGrowth)))