Displaying 20 results from an estimated 10000 matches similar to: "previous monday date"
2011 Oct 11
1
apply for each value
Hello,
There has to be a more R'ish way to do this. I have two matrices, one has
the values I want, but I want to NA some of them. The other matrix has
binary values that tell me if I want to NA the values in the other matrix. I
produce a third matrix based on this. I've also tried apply() passing in
c(1,2) for rows and columns with no success yet.
Example (this works, but I'm
2011 Aug 17
3
Convert week value to date
Hello all,
I'm hoping to convert a decimal value for week of the year back to a date object.
Eg:
strptime(paste(2010,1:52,sep=" "),format="%Y %W")
I expected (hoped?) this would give me the date for Monday of each week. Instead, it's giving me 52 values of today's date.
Where am I erring?
Thanks
Michael
_______________________________________________________
2011 Aug 05
2
[?]apply functions or for loop
Hello,
First time posting to this mail list.
I'd like to use R in the most efficient way. I'm accomplishing what I want,
but feel there is a more R'ish way to do it. Just learning R.
*My goal: get ranks of value across rows with row names and column names
intact.*
I'm guessing one of the [?]apply functions will do what I need, but I
couldn't sort out which one (after a lot
2011 Sep 27
3
remove NaN from element in a vector in a list
Hello,
What is the best way to turn a matrix into a list removing NaN's? I'm new to
R...
Start:
> mt = matrix(c(1,4,NaN,5,3,6),2,3)
> mt
[,1] [,2] [,3]
[1,] 1 NaN 3
[2,] 4 5 6
Desired result:
> lst
[[1]]
[1] 1 3
[[2]]
[1] 4 5 6
Thanks!
Ben
[[alternative HTML version deleted]]
2011 Oct 12
1
Tinn-R change editor background color
Hello,
Does anyone know how to change the Tinn-R editor background color? White is
rough on the eyes...
Thanks,
Ben
[[alternative HTML version deleted]]
2011 Aug 23
1
R.oo modify an object inside another classes method
Can someone show me how to modify one (R.oo) class's object inside another
(R.oo) class's method? Is that possible with the R.oo package? A quick
example or reference to an example would be outstanding...
Thanks,
Ben
[[alternative HTML version deleted]]
2011 Aug 29
1
character vector to text with returns
Hello,
Does anyone know how to convert this:
> msg
[1] "a"
[2] "b"
[3] "c"
To:
> msg
"a
b
c"
In other words, I need to convert a character vector to a single string with
carriage returns for each row.
Functionally, I'm attempting to send an email of a character vector in a way
that is readable in the email body. I can only input one
2011 Sep 10
1
DBS to R
Hello,
I have a bunch of data files all with "dbs" file extensions. They are
generated via a SQL query from another program and source. Does anyone know
(or have ideas) how to get the data from a dbs file type into R (or into
some other format that can imported to R)? I've searched online for 4 hours
now...
Thanks!
Ben
[[alternative HTML version deleted]]
2011 Oct 06
1
counts in quantiles in and from a matrix
Hello,
I'm trying to get the count of values in each row that are above and below
quantile thresholds. Thanks!
Example:
> x = matrix(1:30,5,6)
> x
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 6 11 16 21 26
[2,] 2 7 12 17 22 27
[3,] 3 8 13 18 23 28
[4,] 4 9 14 19 24 29
[5,] 5 10 15 20 25 30
> qtl = t(apply(x, 1,
2011 Oct 11
1
high and lowest with names
Hello,
I'm looking to get the values, row names and column names of the largest and
smallest values in a matrix.
Example (except is does not include the names):
> x <- swiss$Education[1:25]
> dat = matrix(x,5,5)
> colnames(dat) = c('a','b','c','d','c')
> rownames(dat) = c('z','y','x','w','v')
>
2011 Sep 22
1
R.oo: do work on data member at construction
Hello,
I'd like to 'do work' on data members upon construction (i.e. without
implementing it in a get method). Is this the best way to create data member
'z' upon construction? I'm thinking if .z=paste(x,y) below gets more complex
I'll run into issues.
setConstructorS3("MyClass", function(x=NA,y=NA,...) {
this <- extend(Object(), "MyClass",
2011 Aug 08
1
R.oo error upon construction
Hello,
Using the R.oo package, how do I throw an error if a field is not present
when the user of the class creates the object?
Using the example in the R.oo package:
setConstructorS3("Person", function(name, age) {
if (missing(name)) name <- NA;
if (missing(age)) age <- NA;
extend(Object(), "Person",
.name=name,
.age=age
)
})
[rest of class methods
2008 May 09
2
which.max2()
Hello,
which.max() only returns one index value, the one for the
maximum value. If I want the two index values for the two
largest values, is this a decent solution, or is there a
nicer/better R'ish way?
max2 <-function(v)
{
m=which.max(v)
v[m] = -v[m]
m2=which.max(v)
result=c(m, m2)
result
}
Seems to work ok.
Thanks,
Esmail
2012 Apr 18
2
quarter end dates between two date strings
Hello,
I have two date strings, say "1972-06-30" and "2012-01-31", and I'd like to
get every quarter period end date between those dates? Does anyone know how
to do this? Speed is important...
Here is a small sample:
Two dates:
"2007-01-31"
"2012-01-31"
And I'd like to get this:
[1] "2007-03-31" "2007-06-30"
2011 Sep 14
1
rJython matrix message
Hello,
I've posted something similar under a different subject and never received a
solution. Trying again with (hopefully) a better description.
Objective: Send a matrix of string data in an email message. The message
must have authentication and be sent via an R script.
I'm almost there!
Here is where I am at:
I collect long error message lines in 'errs', which is a matrix.
2011 Aug 15
1
2 matrix scatter x [a lot]
Hello,
I'm pretty new to R. Basically, how do I speed up the for loop below. Or
better yet, get rid of the for loop all together.
objective: plot two data sets column against column by index. These data
sets have alot NA's. Some columns are all NA's. I need the plots to overlay.
I don't like the plots in matplot(). Needs to be much faster than the code
below...
#simple sample
2011 Aug 26
1
R.oo data members / inheritance
If someone is able, can you tell me if there is a better way to do this?
More specifically, do I have to rewrite all of the data members stuff and
extend stuff of parent class in the child class? See below. Thanks in
advance!
Example 1:
setConstructorS3("ClassA", function(A,x) {
if(missing(A))A=15;
if(missing(x))x=NA;
extend(Object(), "ClassA",
.size = A,
.x=x
2011 Jul 17
3
How to convert number (matlab) to date
Hello
I am new to R and I need to convert some dates (numeric format by matlab) to actual dates in R.
For instance,
Matlab -> 730456 -> >> datestr(730456)
ans =
02-Dec-1999
R -
> library(zoo)
> as.Date(730456)
[1] "3969-12-03"
I don't not mind the output format but it needs to be right.
Many thanks
Ed
2006 Mar 14
2
Date problem
Hello,
I have some "stupid" problems managing "date" data.
I have a colomn "date", which I converted from a character representation:
for example:
a="26/02/06"
date=strptime(a,format="%d/%m/%y")
For one part of the analysis, I'm interested only in the month and the
year, so I did:
m.y=strftime(date,format="%m/%y")
This returns me
2008 Jul 03
2
as.Date() clarification
When I use the code as.Date(0) the I get : "1970-01-01". My question is why it is like that? help file on as.Date seems to give no light on that. Can anyone clarify me?
Regards,
Send instant messages to your online friends http://uk.messenger.yahoo.com
[[alternative HTML version deleted]]