Manipulating Arrays
Using the below data:
df <- structure(list(dim1 = structure(c(1L, 3L, 1L, 4L, 1L, 2L, 2L,
2L, 3L, 1L, 4L, 3L, 4L, 4L, 3L, 2L), .Label = c("a1", "a2", "a3",
"a4"), class = "factor"), dim2 = structure(c(2L, 1L, 2L, 2L,
4L, 3L, 1L, 3L, 1L, 3L, 2L, 4L, 3L, 4L, 1L, 4L), .Label =
Hi All,
Thanks for your help. I need to reverse the digits of a number (unknown
lenght). Example 1234->4321
Tom
--
View this message in context:
http://www.nabble.com/How-do-I-reverse-the-digits-of-a-number-tp25838410p25838410.html
Sent from the R help mailing list archive at Nabble.com.
__
Thanks Gabor. That was exactly what I was looking for.
Ampy
ampc wrote:
>
> Hi,
>
> I have 2 date vectors d1 and d2.
>
> d1 <- structure(c(14526, 14495, 14464, 14433, 14402, 14371, 14340, 14309,
> 14278, 14247, 14216, 14185), class = "Date")
> d2 <- structure(c(14526, 14509, 14488, 1446
Hi,
I am passing a data frame and field name to a function. I've figured out how
I can create the formula based on the passed in field name, but I'm
struggling to create a vector based in that field.
for example if I hard code with the actual field name
Y = df$Target, everything works fine.
bu
Thanks for your ideas and suggestions. I need to point out that most of us
will create the Clustered-Stacked Column Chart in the matrix layout as David
gave above, but here i hope to display the graph side by side as the example
in the link http://peltiertech.com/Excel/ChartsHowTo/ClusterStack.ht
On Sat, Oct 10, 2009 at 5:51 PM, Peter Ehlers wrote:
> The key will show the levels of the 'groups' factor. So you will
> have to ensure that the factor fed to groups has the levels
> that you want displayed. ?xyplot explicitly states that
> drop.unused.levels will NOT do that for you.
>
> (Didn't
The last version of fgui was produced only 6 months ago so its
relatively recent and there was a JSS paper on it published during
that time frame as well. Send an email to the fgui package maintainer
if you want to know what he intends. The ggenericwidget function in
gWidgets is very similar fgui
On Oct 10, 2009, at 9:27 PM, tdm wrote:
Hi,
I am passing a data frame and field name to a function. I've figured
out how
I can create the formula based on the passed in field name, but I'm
struggling to create a vector based in that field.
for example if I hard code with the actual field
Thank you for recommending fgui. This package looks very promising.
By any chance do you know if it is still being maintained?
The URL provided for the packaged does not appear to be functional, so I was
curious if this package is going to be maintained going forward.
Also, do you know, on
On Sat, Oct 10, 2009 at 8:51 PM, Peter Ehlers wrote:
> The key will show the levels of the 'groups' factor. So you will
> have to ensure that the factor fed to groups has the levels
> that you want displayed. ?xyplot explicitly states that
> drop.unused.levels will NOT do that for you.
So the ans
You code is not reproducible.
Take a look at this much simpler example:
> a
x y xx xxx
1 1 4 8 12
2 2 5 9 13
3 3 6 10 14
4 4 7 11 15
5 1 4 8 12
6 2 5 9 13
7 3 6 10 14
8 4 7 11 15
> funct <- function(df, colnm) print(df[, colnm])
> funct(a, "xx")
[1] 8 9 10 11 8 9 10 11
#-
tom_p wrote:
>
> Hi All,
>
> Thanks for your help. I need to reverse the digits of a number (unknown
> lenght). Example 1234->4321
>
> Tom
>
> z <- 4321
> as.numeric(paste(rev(strsplit(as.character(z),"")[[1]]),collapse=""))
[1] 1234
--
View this message in context:
http://www.nabble.
You need to understand how accessing elements of a dataframe happen,
especially the '[[' operator (?"[[")
x <- function(dataFrame, name) dataFrame[[name]]
On Sat, Oct 10, 2009 at 9:27 PM, tdm wrote:
>
> Hi,
>
> I am passing a data frame and field name to a function. I've figured out how
> I can
Hi,
I am passing a data frame and field name to a function. I've figured out how
I can create the formula based on the passed in field name, but I'm
struggling to create a vector based in that field.
for example if I hard code with the actual field name
Y = df$Target, everything works fine.
On Oct 10, 2009, at 7:49 PM, Ashta wrote:
Thanks. This helps. How do I generate P?
Will this work?
p1<-pnorm(mean=0, std=1)
p2<-pnorm(mean=0, std=1)
Seems unlikely. You are not supplying sufficient arguments for the
pnorm function for one thing. For another I suspect you really want
the r
The key will show the levels of the 'groups' factor. So you will
have to ensure that the factor fed to groups has the levels
that you want displayed. ?xyplot explicitly states that
drop.unused.levels will NOT do that for you.
(Didn't Deepayan just answer something like this?)
-Peter Ehlers
Jac
try this to get the column output:
cat(x, sep='\n', file='/tempxx.txt')
For the transposed out, do:
write.table(t(x), file="filename.txt", row.names=F, col.names=F)
On Sat, Oct 10, 2009 at 2:09 PM, Eiger wrote:
>
> Hi, I have a question about "how" write output in a .txt file.
>
> With tihs co
you will have to specify what 'x' is. I am not sure what you are
trying to do with the variables you have not defined.
Sent from my iPhone
On Oct 10, 2009, at 19:49, Ashta wrote:
> Thanks. This helps. How do I generate P?
> Will this work?
>
> p1<-pnorm(mean=0, std=1)
> p2<-pnorm(mean=0, std
Please assist me.
In the package "boot" is a term called "statistic".
what is the r syntax for the mean?
is it, given that the name will be AV:
AV <- function (d,x){mean(x*w)}
Thanks.
Mitchell Wachtel
__
R-help@r-project.org mailing list
https:/
Thanks. This helps. How do I generate P?
Will this work?
p1<-pnorm(mean=0, std=1)
p2<-pnorm(mean=0, std=1)
x <- cbind(x, v1=ifelse(x[,'p'] > 0.4, 1, 0), v2=ifelse(x[,'2'] > 0.6, 0,
1))
If the 'data set' is a dataframe, the following will work:
x$v1 <- ifelse(x$p > 0.4, 1, 0)
x$v2 <- ifelse
Hi R-users,
I would like to calculate weighted mean of several
variables by two factors where the weight vector is
the same for all variables.
Below, there is a simple example where I have only two
variables: "v1","v2" both weighted by "wt" and my factors
are "gender" and "year".
set.seed(1)
df
Ted,
I have written an R function that implements C.T. Kelley's algorithm (described
in his book). I have tested this on many problems, smooth and non-smooth, and
in all my testing, I have found it to be clearly superior to optim's
Nelder-Mead. You can easily change this code to look at the e
I have a pure-R implementation of the N-M simplex translated from
the C code in Press et al 1994 (Numerical Recipes), instrumented to
save the progress. Since I'm not sure of the copyright status (NR's
code does not allow redistribution, but this is a translation ...) I'll send
it in separate
On 10/10/2009 7:00 PM, Another Oneforyou wrote:
Hi,
I'm working through "R-debug-tools.pdf" and on page 7 it describes doing:
Browse[1]> debug(sum) ## Flag sum for debugging
however, when I try this, I get:
Browse[1]> debug(sum)Error in debug(fun) : argument must be a closure
Does anyone know why
Hi,
I'm working through "R-debug-tools.pdf" and on page 7 it describes doing:
Browse[1]> debug(sum) ## Flag sum for debugging
however, when I try this, I get:
Browse[1]> debug(sum)Error in debug(fun) : argument must be a closure
Does anyone know why I get this error, and how to work around it?
Tha
Just saw I did something stupid. Both examples create a 2 by 2 grid in
your graph window, so you'll be able to plot 4 graphs in that window.
If you plot only 2 graphs, the lower half of the window will be empty
still. Just check the helpfiles and experiment a bit to get a grip of
how to get which g
Hi Emkay,
If you want to look at different plots together, you can also plot
them side by side in the same plot window.
You can specify this using for example:
par(mfcol=c(2,2))
( see ?par and check mfrow and mfcol)
or
layout(matrix(1:4,2,2))
(see ?layout and ?matrix)
eg :
x <- c
If the 'data set' is a dataframe, the following will work:
x$v1 <- ifelse(x$p > 0.4, 1, 0)
x$v2 <- ifelse(x$p > 0.6, 1, 0)
If it is matrix, try
x <- cbind(x, v1=ifelse(x[,'p'] > 0.4, 1, 0), v2=ifelse(x[,'p'] > 0.6, 1, 2))
If helps a lot if you follow the posting rules and provide commented,
mi
Well, looking into the development of GUI widgets using R packages it appears
that it is important to have well formed R functions. Moreover, it has made me
realize my functions are probably not well formed and should be brought closer
inline with R standards.
By any chance is there a single
Hi all,
I have a data set called x with200 rows and 12 columns. I want
create two more columns based on probability. ie
if p >0 .4 then v1 =1 else v1=0;
if p >0 .6 then v2 =1 else v2=0;
Finally x will have 14 variables.
Can any one show me how to do that?
Thanks
Ashta
.
On 10/10/09, Gabor Grothendieck wrote:
> There are many approaches to GUIs in R but for something quick, which
> I gather is your main aim here, have a look at the fgui package and
> also the very similar ggenericwidget function in the gWidgets package.
>
There is also rpanel for building simple
Greetings!
I want to follow the evolution of a Nelder-Mead function
minimisation (a function of 2 variables). Hence each simplex
will have 3 vertices.
Therefore I would like to have a function which can output
the coordinates of the 3 vertices after each new simplex
is generated. However, there se
On 07/10/2009 5:50 PM, gcheer3 wrote:
Thanks for your reply.
But I don't think it will really help. My problem is as follows:
I have 20 observations
y <- rnorm(N,mean= rep(th[1:2],N/2),sd=th[3])
I have a loglikelihood function for 3 variables mu<-(mu1,mu2) and sig
loglike <- function(m
On 10 October 2009 at 14:39, dinesh.som...@gatech.edu wrote:
| Hi
|
| I am a new R user, so if this question has been raised and answered before,
perhaps you can point me that way.
|
| I was looking for some package/scripts that can download financial data from
yahoo finance (or some other) we
Jim, thank you for your reply. I will try that. Thanks.
--
View this message in context:
http://www.nabble.com/Display-more-than-one-plot-tp25829214p25835685.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailin
Hi
I am a new R user, so if this question has been raised and answered before,
perhaps you can point me that way.
I was looking for some package/scripts that can download financial data from
yahoo finance (or some other) website. I did check
http://cran.r-project.org/web/packages/ but failed t
The following code produces a legend ("key") that mentions the unused
levels of Block.
library(MEMSS)
xyplot(yield~nitro, subset=(Block=="I" | Block=="II"), data=Oats,
group=Block, auto.key=T)
and adding "drop.unused.levels=T" does not fix it. And in fact even
the following does not solve the pro
John:
The 'year' dataset has 366 rows, I used the 'line.count' without the '1' to
come up with 12 rows to match the mlabs and then used line.count to draw the
labels. Is this close to what you want?
line.count <- c(cumsum(as.vector((table(year$monthnum);line.count
namposts <- line.count;namp
There is a function called odfTranslate that will help deal with
characters that might confound XML. You might need to use it on the
row/column names of your output.
Max
On Oct 10, 2009, at 11:33 AM, Rob James wrote:
Just to close out my earlier posting, I have identified and resolved
th
Hi, I have a question about "how" write output in a .txt file.
With tihs command, I write permutations of the numbers (1,2,3) in a .txt
file:
> x<-permn(c(1,2,3))
> write.table(x, file="filename.txt", row.names=F, col.names=F)
This is output in filename.txt:
1 1 3 3 2 2
2 3 1 2 3 1
3 2 2 1 1 3
On Sat, 10 Oct 2009, Dieter Menne wrote:
Ashta wrote:
I have a data set
x1 x2 x3
1 2 1
1 2 3
2 1 2
1 2 1
3 1 1
I want to tabulate in the following way.
1 2 3
x13 2 1
x22 3 0
x33 1 1
It is just like frequency distribution
Hello guys I am new to this list and for R too.
I am wondering if there is a patch for the SPSS reading code on the
foreign package, in order to be able to read long variable names.
Right now read.spss() just trunc the names to 8 characters.
Or if someone could help me on other way:
I have to pro
I'm just learning R (I don't know any other programming languages),
and I have a question. I am trying to figure out how to ask for user
input (say, a set of 3 numbers) then put those numbers into an array.
I've looked around, but I haven't been able to find any answers that I
understand.
Dirk Eddelbuettel wrote:
>
> Supply an argument 'lib' pointing to a directory where you write to, or
> alternatively (but not generally recommended) run R as root to install the
> package as root can write to /usr/lib/R/lib.
>
> Dirk
>
OK! I've installed this package.
Thank you!
:)
Example:
Eiger wrote:
>
>
> When I try to install the "combinat" package, it give me these errors:
> _
>
> Error in utils::install.packages(l[s + 1]) : unable to install packages
> _
>
> Wha
Here are a couple of possibilities both based on first converting the
data frame to long form:
> xtabs(~ind + values, stack(DF))
values
ind 1 2 3
x1 3 1 1
x2 2 3 0
x3 3 1 1
> t(table(stack(DF)))
values
ind 1 2 3
x1 3 1 1
x2 2 3 0
x3 3 1 1
On Sat, Oct 10, 2009 at 10:43 AM, A
On 10 October 2009 at 08:15, Eiger wrote:
| require(combinat)
| permn((c(23,46,70,71,89))
|
| Thanks.
| When I try to install the "combinat" package, it give me these errors:
| _
| --- Please select a CRAN mirror for use in this session ---
Just to close out my earlier posting, I have identified and resolved the
following odfWeave/XML error:
xmlParseStartTag: invalid element name
I used odfWeave to call various logistic regression models which
included the above mentioned variable. odfWeave failed to generate the
destina
Building on the two prior suggestions ( str() and methods() ) you
could write a function to get both the named components of an object
and the functions that work on its class. Using the example lm.D9 in
the help page for lm:
get_mths_str <- function(obj) c(functs =
list(methods(class=cl
Ashta wrote:
>
>
> I have a data set
> x1 x2 x3
> 1 2 1
> 1 2 3
> 2 1 2
> 1 2 1
> 3 1 1
>
> I want to tabulate in the following way.
> 1 2 3
> x13 2 1
> x22 3 0
> x33 1 1
>
> It is just like frequency distribution
>
See func
require(combinat)
permn((c(23,46,70,71,89))
Thanks.
When I try to install the "combinat" package, it give me these errors:
_
--- Please select a CRAN mirror for use in this session ---
Warning in utils::install.packages(l[s + 1]) :
argume
Dear R users,
I'm new in Text Mining applications and just started to look into the tm
package. If anyone of you has experience with this package, I'll appreciate
if you could share your thoughts around it. Also what's the best way to
store large amounts of text data on limited RAM when using this
require(combinat)
permn((c(23,46,70,71,89))
On Oct 10, 2009, at 10:05 AM, Eiger wrote:
Question 1.
I would calculate all the permutations of numbers (23,46,70,71,89)
How can I write correctly the code?
(Load gregmisc)
permutations (..?...)
__
Question 2.
It's possible
Hi all,
I have a data set
x1 x2 x3
1 2 1
1 2 3
2 1 2
1 2 1
3 1 1
I want to tabulate in the following way.
1 2 3
x13 2 1
x22 3 0
x33 1 1
It is just like frequency distribution
Any help is highly appreciated
[[alternative
Question 1.
I would calculate all the permutations of numbers (23,46,70,71,89)
How can I write correctly the code?
(Load gregmisc)
> permutations (..?...)
__
Question 2.
It's possible permute a string?
..for example:
EIGER
EGIER
EREGI
etc..etc..
Thanks,
E.
--
View this mes
There are many approaches to GUIs in R but for something quick, which
I gather is your main aim here, have a look at the fgui package and
also the very similar ggenericwidget function in the gWidgets package.
On Sat, Oct 10, 2009 at 1:05 AM, Jason Rupert wrote:
> It appears several that of my scr
I think you're missing the point. David _did_ show you how
to create a graph showing 4 clusters of stacked barcharts.
If you want them side-by-side instead of in the matrix
layout David gave, use the layout= argument.
-Peter Ehlers
zhijie zhang wrote:
Hi David,
Your codes are for stacked cha
I gave you more than you deserved. You provided no data and a link to
what appeared to me to be a rather ugly looking chart. I gave you the
help examples from the lattice equivalent. The barchart (stacked
column chart in your termnology) is "clustered" although it happens to
be presented in
Try this (where "lm" is the class of the lm output):
> methods(class = "lm")
[1] add1.lm* alias.lm* anova.lm case.names.lm*
[5] confint.lm*cooks.distance.lm* deviance.lm* dfbeta.lm*
[9] dfbetas.lm*drop1.lm* dummy.coef.lm* effects.l
Robert Wilkins wrote:
Am I asking for too much:
for any object that a stat proc returns ( y <- lm( y~x) , etc ) ) , is there
a super convenient function like give_all_extractors( y ) that lists all
extractor functions , the datatype returned , and a text descriptor
field ("pairwisepval" "lsmea
Create two zoo series, merge them and use na.locf (last occurence
carried forward):
library(zoo)
z1 <- zoo(as.numeric(d1), d1)
z2 <- zoo(as.numeric(d2), d2)
z <- merge(z1, z2)
z.na.locf <- na.locf(z, na.rm = FALSE)[time(z1)]
transform(as.data.frame(z.na.locf), z1 = as.Date(z1), z2 = as.Date(z2))
On Sat, Oct 10, 2009 at 1:01 PM, Jason Rupert wrote:
> Thank you very much for your response and it looks like R Commander is very
> capable, but I think it is heading the wrong direction from where we are
> looking to go, i.e. simpler interface.
>
> I guess (and I may be dating myself) when I w
Thank you very much for your response and it looks like R Commander is very
capable, but I think it is heading the wrong direction from where we are
looking to go, i.e. simpler interface.
I guess (and I may be dating myself) when I was previously working with MATLAB
I could use something lik
Hi David,
Your codes are for stacked chart. Actually, i hope to Create a
Clustered-Stacked Column Chart, which means that a chart will combine the
traits of stacked chart and clustered chart, see the example in the page
http://peltiertech.com/Excel/ChartsHowTo/ClusterStack.html.
Thanks.
2009/10
amira akl wrote:
Hello
I am a new user of R software. I benefit from using vrtest-package. However, the codes provided by the aforementioned package, for example, calculate the test statistics for Lo and Mackinlay (1988) under the assumptions of homoscedasticity and heteroscedasticity without c
On Sat, 2009-10-10 at 04:54 +0100, Lazarus Mramba wrote:
> Dear all,
>
> I seem to have many problems as I run R on my ubuntu system.
> want to set a mirror so that anytime I use the command "install.packages",
> it does not ask me for which mirror to use but go direct.
> This is because of the er
On Sat, Oct 10, 2009 at 12:13 AM, Rene wrote:
> Dear All,
>
>
>
> I have created a barchart, but the legend created by auto.key does not match
> the actual graph. Can someone give me some hint here?
>
>
>
> For example, my coding are:
>
>
>
> Library(lattice)
>
> dataset.table <-
> table(data.fram
On Thu, Oct 8, 2009 at 8:11 PM, John Field wrote:
> Dear R list,
>
> The code below puts qq-plots for two of three groups on the one plot.
> However the legend includes all three groups, ie the auto.key ignores the
> subset instruction. Is there an easy way to get around this, so that only
> tho
Sorry, forgot to "reply all"...
Laust wrote:
Dear list,
I am trying to set up a propensity-weighted regression using the
survey package. Most of my population is sampled with a sampling
probability of one (that is, I have the full population). However, for
a subset of the data I have only a 50%
On 10/10/2009 06:34 PM, tulesparo wrote:
Hello,
I am a beginner with R and I would need some help with doing the barplot I
want.
In fact I want to draw a barplot from my table, but the issue is that only
the modalities with nonzero values are plotted ; the fact is that I would
plot all the moda
On 10/10/2009 06:41 PM, Jim Lemon wrote:
Oops, should be:
gimmeDiffCol<-function(oldcol) {
rgbcomp<-col2rgb(oldcol)
if(rgbcomp[1,1]<127) newred<-sample(rgbcomp[1,1]:255,1)/255
else newred<-sample(0:rgbcomp[1,1],1)/255
if(rgbcomp[2,1]<127) newgreen<-sample(rgbcomp[2,1]:255,1)/255
else newg
Hello,
I am a beginner with R and I would need some help with doing the barplot I
want.
In fact I want to draw a barplot from my table, but the issue is that only
the modalities with nonzero values are plotted ; the fact is that I would
plot all the modalities, including those which have no valu
On Thu, Oct 8, 2009 at 10:52 AM, Folkes, Michael
wrote:
> hi all,
> It's not clear to me how (or if) I can pass multiple values for lty to a key
> in xyplot?
> I've tried: lines=list(lty=1:3), to no avail.
> Do I need to use something other than auto.key?
> (Deepayan, if you're out there, I have
On Thu, Oct 8, 2009 at 6:54 AM, baptiste auguie
wrote:
> Hi,
>
> Try the useOuterStrips function in the latticeExtra package.
...which is discussed in section 11.5 of the Lattice book.
-Deepayan
> HTH,
>
> baptiste
>
> 2009/10/8 Christian Ritter :
>> Dear all,
>>
>> I want to split the strips i
On 10/10/2009 11:41 AM, Jie TANG wrote:
hello ,every one ,
I draw a figure as shown in appendix A,
The tick characters in the Y-axis is arranged in the vertical
direction.Now I want to arranged the Y-axis tick in the horizontal
direction.
How could I do ,then?
Hi Jie,
Try this:
par(l
On 10/10/2009 11:10 AM, Jonathan Bleyhl wrote:
On a similar note, I'm trying to plot continuous values on the y vs.
categorical (dates) on the x and I want to color by date, but I want the
colors to be random so points close to each other are easily
distinguishable. Any thoughts?
Thanks,
Jon
p
Am I asking for too much:
for any object that a stat proc returns ( y <- lm( y~x) , etc ) ) , is there
a super convenient function like give_all_extractors( y ) that lists all
extractor functions , the datatype returned , and a text descriptor
field ("pairwisepval" "lsmean" etc)
That would just b
Dear All,
I have created a barchart, but the legend created by auto.key does not match
the actual graph. Can someone give me some hint here?
For example, my coding are:
Library(lattice)
dataset.table <-
table(data.frame(id=c("a","b","c","a","c","b","a"),colour=c("blue","green","
red","
On 10/10/2009 01:51 PM, emkayenne wrote:
Nobody? :-(
emkayenne wrote:
Hello, I'm pretty new to R and I am having a hrd time getting a grip. Just
a question: can someone tell me how to have more than one graphics windown
open at the same time? I want to look at some plote at the same time...
Jason Rupert wrote:
>
> I am curious if there is a typical approach for developing a GUI to run R
> scripts or to export R scripts in a DLL or other format so that they can
> be run from such a GUI.
>
> I also have not settled on a GUI development language so any suggestions
> there are also
80 matches
Mail list logo