I would like to sum/mean/min a list of lists and numbers to return the
related lists.
-1+2*c(1,1,0)+2+c(-1,10,-1) returns c(2,13,0) but
sum(1,2*c(1,1,0),2,c(-1,10,-1)) returns 15 not a list.
Using the suggestions of Gabor Grothendieck,
Reduce('+',list(-1,2*c(1,1,0),2,c(-1,10,-1))) returns what we
We want to sum many vectors and numbers together as a vector if there is
at least one vector in the arguments.
For example, 1 + c(2,3) = c(3,4).
Since we are not sure arguments to sum, we are using sum function:
sum(v1,v2,...,n1,n2,..).
The problem is that sum returns the sum of all the values pres
For me, the angles circled are not exactly right.
See the pdf file: plot.pdf.
But it is OK.
Thanks Peter for your directions
-james
> On 2010-06-09 14:17, g...@ucalgary.ca wrote:
>> Thank.
>> Better. Seems that angles are close to but not equal to pi/2.
>> It may be because the plot box is not a sq
Thank.
Better. Seems that angles are close to but not equal to pi/2.
It may be because the plot box is not a square: the length of
x-axis is not the same as the length of y-axis.
Even curves y = x and y = 1-x look like not orthogonal but
they should since multiplication of their slopes is -1.
-jame
Rectangle R centered at (x,y) with width 2w and height 2h is given by
x1=x-w
y1=y-h
x2=x+w
y2=y-h
x3=x+w
y3=y+h
x4=x-w
y4=y+h
polygon(c(x1,x2,x3,x4),c(y1,y2,y3,y4))
Rotating a point (u,v) at (0,0) by theta degree is given by matrix
[cos(theta),-sin(theta)
sin(theta),cos(theta)]
so we have a new
text() can draw text on a plot.
Do we have a way/function to draw text with a box surround it?
Thanks,
-james
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/pos
As we knew, if a function is not used correctly,
an error message will throw/display in R:
> rnorm(-1)
Error in rnorm(-1) : invalid arguments
I would like to catch the error message or assign an error message to a
variable so that I can use them some where else.
So, how to catch error messages in
Thanks, Jorge.
Yes, I can also run the code.
But I would like to know the limitations on the lengths of variable names,
formulas/equations, and files.
Steve has pointed out a limitation on the length of a variable name is
256kb. So
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn
I would like to run R code from a file that is generated from other source.
The file consists of some variables and formulas/equations such as
Variables = log(100)
##Other variable definitions
VariablesWithLongNames = 2*3*log(12345678)+10^4 + Variables
Equations=log(VariablesWithLongNames)+Variabl
Thanks for your help.
-jmaes
> Hi James,
> If that's the case, then
>
> set.seed(123)
> x <- c(4,rnorm(20),8)
> bp <- boxplot(x)
> bp$out
> # [1] 4 8
> which(x %in% bp$out)
> # [1] 1 22
>
> is what you are looking for. :-)
>
> HTH,
> Jorge
>
>
> On Wed, Sep 9, 2009 at 4:07 PM, wrote:
>
>> Thank
Thank you very much.
But it seems that
x$out returns the values not the indexes of the values (1,22).
-james
> boxplot returns a dataframe that has the values in it at "$out":
>
>> x <- boxplot(c(4,rnorm(20),8))
>> x
> $stats
>[,1]
> [1,] -1.5364498
> [2,] -0.5282799
> [3,] -0.1398736
I am wondering if you know how to return by function or show in boxplot,
the indexes of unusual points, such as,
points that are outside the box or in [Q3+1.5IQR,Max].
For example,
> boxplot(c(4,rnorm(20),8))
There are 2 unusual points 4 and 8. How to show the indexes of 4 and 8 in
the boxplot
or
>
> On Aug 20, 2009, at 4:07 PM, g...@ucalgary.ca wrote:
>
>>>
>>> On Aug 20, 2009, at 3:42 PM, g...@ucalgary.ca wrote:
>>>
Thanks!
>
> On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote:
>
>> I got two questions on factors in regression:
>>
>> Q1.
>> In a table, t
>
> On Aug 20, 2009, at 3:42 PM, g...@ucalgary.ca wrote:
>
>> Thanks!
>>>
>>> On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote:
>>>
I got two questions on factors in regression:
Q1.
In a table, there a few categorical/factor variables, a few
numerical
variables and
Thanks!
>
> On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote:
>
>> I got two questions on factors in regression:
>>
>> Q1.
>> In a table, there a few categorical/factor variables, a few numerical
>> variables and the response variable is numeric. Some factors are
>> important
>> but others not.
I got two questions on factors in regression:
Q1.
In a table, there a few categorical/factor variables, a few numerical
variables and the response variable is numeric. Some factors are important
but others not.
How to determine which categorical variables are significant to the
response variable?
To get USDCAD rates from Bank of Canada, we first go
url <- "http://banqueducanada.ca/en/rates/exchange-avg.html";
select 12 months for Rates for the past and click "Get Rates" button. Then
the page moves to
address <- "http://banqueducanada.ca/cgi-bin/famecgi_fdps";
and the rates show in the h
We got all rows by:
library(XML)
doc =
htmlParse('http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm')
rows = xpathSApply(doc, '//table/tbody/tr')
The last row is:
row_last = rows[15]
row_last
[[1]]
Unsmoothed composite
leading indicator
221.8
218.4
217.1
211.2
209.4
210.5
Since there are many rows, using read.table we spent too much on reading
in rows that we do not want. We are wondering if there is a way to read
only rows that we are interested in. Thanks,
-james
> I think you can use readLines(n=1) in loop to skip unwanted rows.
>
> On Mon, Jun 1, 2009 at 12:56
Thanks, Juliet.
It works for filtering columns.
I am also wondering if there is a way to filter rows.
Thanks again.
-james
> One can use colClasses to set which columns get read in. For the
> columns you don't
> want you can set those to NULL. For example,
>
> cc <- c("NULL",rep("numeric",9))
>
>
We are reading big tables, such as,
Chemicals <-
read.table('ftp://ftp.bls.gov/pub/time.series/wp/wp.data.7.Chemicals',header
= TRUE, sep = '\t', as.is =T)
I was wondering if it is possible to set a filter during loading so that
we just load what we want not the whole table each time. Thanks,
-j
Yes, XML can help load HTML tables.
As we knew, tables in Bureau of Labor Statistics (http://www.bls.gov/)
can be displayed in HTML and can also be loaded directly using their urls,
for example, ftp://ftp.bls.gov/pub/time.series/wp/
I was wondering if tables in Statist Canada have such locations so
We would like to load data from Statistics Canada
(http://www.statcan.gc.ca/) using R,
for example, Employment and unemployment rates.
It seems to me that the tables are displayed in HTML.
I was wondering if you know how to load these tables. Thanks,
-james
___
If we knew two pth quantiles for a normal distribution,
is it possible that we can find mean and sigma for the normal distribution
using R?
Let x ~ norm(mean, sigma).
Suppose that qnorm(0.9,mean,sigma) and qnorm(0.1,mean,sigma) are known.
Can we find mean and sigma using R?
Thanks,
-james
_
I have a small data set (see attachment valve.txt or valve.csv), in which
there are a few facors: Type, ValveBody,Manufacturer
and a few numeric sizes: FlangeSize, Port.Size, Pressure and Cost.
I would like to find a statistics model that shows how Cost is related to
these factors and numeric size
I have a small data set (see attachment valve.txt or valve.csv), in which
there are a few facors: Type, ValveBody,Manufacturer
and a few numeric sizes: FlangeSize, Port.Size, Pressure and Cost.
I would like to find a statistics model that shows how Cost is related to
these factors and numeric size
I would like to load the producer price indexes of BLS (Bureau of Labor
Statistics) into R:
For example, Commodity Data in
http://www.bls.gov/ppi/
There are many tables there.
I was wondering if you knew some R-package/function that can do this
or any basic idea onwriting functions to load data t
I would like to use Tornado charts/diagrams to rank risks and opportunities
in a variable (for example, Cost) that depends on a few other variables
which have risks using R and R-packages.
I did some RSiteSearchs but did not find Tornado chart plots
and how to rank risks and opportunities.
Any idea
Thanks for your ideas.
I would like to find all possible maximums - "mountains" on a graph of a
given density function but I have no ideas. In calculus, there is a
general approach for a given function f(x): Find derivative of f(x) and
estimate all zeros of f'(x). These zeros give us locations of m
Yes, a random variable, discrete or continuous one, should associate with
a probability space and a measurable space.
I thought that graph of density(rv) below could give us an example of a
density function. I am very sorry for confusing you.
My question is how to find/estimate maximum values of a
I would like to find the maximum values on the density function of a
random variable. For example, I have a random variable
rv <- rbinom(1,1,0.1) + rnorm(1)
Its density function is given by density(rv) and can be displayed by
plot(density(rv)). How to calculate its maximum values?
A densi
Please forget the last email I sent with the same subject.
=
I would like to generate pseudo-random numbers between two numbers using
R, up to a given distribution,
for instance, norm. That is something like rnorm(HowMany,Min,Max,mean,sd)
over rnorm(HowMany,mean,sd).
I am wondering
I would like to generate pseudo-random numbers between two numbers using
R, up to a given distribution,
for instance, rnorm.
That is something like rnorm(HowMany,Min,Max,mean,sd) over
rnorm(HowMany,mean,sd).
I am wondering if
dnorm(runif(HowMany, Min, Max), mean, sd)
is good. Any idea? Thanks.
-
For a given random variable rv, for instance, rv = rnorm(1000),
I plot its density curve and calculate some quantiles:
plot(density(rv))
P10P50P90 = = quantile(rv,probs = c(10,50,90)/100)
I would like to color the area between P10 and P90 and under the curve
and mark the P50 on the curve.
> rv = r
I am using RDCOM as a data-transfer between R and C#.net.
I got a question on datasets with missing data.
For instance, if list = c(1,2,3,NA,5), in R, typeof(list) is integer
but, in C#, I did not see a suitable data type for (1,2,3,NA,5).
Of course, one can use is.na to transfer (1,2,3,NA,5) into
I got a table on SQL Server, which has columns EquationId (int) and
Formula (varch(900)).
I need to select Formula with certain EquationId, for example,
Select Formula from OGA_DEV.dbo.Equation where EquationId = 3
I tried to work within RGui using RODBC:
> library(RODBC)
> conn = odbcConnect("S
I would like to know some basic properties,
such as its domain, its range, if it is increasing, of the function
defined. I was wondering if R provides functionalities to show this
information. If not, any ideas on writing such functions.
Thanks.
-james
Given a data set and a set of predictors and a response in the data,
we would like to find a model that fits the data set best.
Suppose that we do not know what kind of model (linear, polynomial
regression,... ) might be good, we are wondering if there is R-package(s)
can auctomatically do this.
Ot
38 matches
Mail list logo