Displaying 20 results from an estimated 90 matches similar to: "Matching two vectors"
2015 Jun 18
3
[LLVMdev] problem with replacing an instruction
I am trying to change this
define void @main(float* noalias %arg0, float* noalias %arg1, float*
noalias %arg2) {
entrypoint:
%0 = bitcast float* %arg1 to <4 x float>*
intothis
define void @main(float* noalias %arg0, float* noalias %arg1, float*
noalias %arg2) {
entrypoint:
%0 = getelementptr float* %arg1, i64 0
%1 = bitcast float* %0 to <4 x float>*
I must be close but
2011 Mar 29
3
Reversing order of vector
Dear R helpers
Suppose I have a vector as
vect1 = as.character(c("ABC", "XYZ", "LMN", "DEF"))
> vect1
[1] "ABC" "XYZ" "LMN" "DEF"
I want to reverse the order of this vector as
vect2 = c("DEF", "LMN", "XYZ", "ABC")
Kindly guide
Regards
Vincy
[[alternative HTML
2006 Jul 04
1
Problems when computing the 1rst derivative of mixtures of densities
Hi everybody,
I am currently working on mixtures of two densities ( f(xi,teta)=
(1-teta)*f1(xi) + teta*f2(xi) ),
particularly on the behavior of the variance for teta=0 (so sample only
comes from the first distribution).
To determine the maximum likelihood estimator I use the Newton-Rapdon
Iteration. But when
computing the first derivative I get a none linear function (with several
asymptotes)
2008 Nov 18
4
How do I generate multiple (similar) objects within R?
Hi,
I wonder if anyone knows how to generate a list of objects, e.g. ten
vectors with names: vect1, vect2, ... , vect10.
My own idea was to use something like:
for (i in 1:10)
print(paste("vect", i,"<-NULL",sep=""))
but the result is:
"vect1<-NULL"
...
"vect10<-NULL"
and not
vect1<-NULL
...
vect10<-NULL
as I would
2009 Sep 01
3
data frame
HI, R user,
I generate the vectors with the same length. I want to put each vector into each column of data frame. Why it doesnt work`?
rm<-data.frame()
for(a in 1:6){
rm[,a]<-getmeasure(p1,a,speech)
}
thanks a lot
Tammy
_________________________________________________________________
Share your memories online with anyone you want.
2011 Aug 23
4
Correlation discrepancy
Dear R list, I have one very elementary question regrading correlation between two variables.
x = c(44,46,46,47,45,43,45,44)
y = c(44,43,41,41,46,48,44,43)
> cov(x, y)
[1] -2.428571
However, if I try to calculate the covariance using the formula as
covariance = sum((x-mean(x))*(y-mean(y)))/8 # no of of paired obs. = 8
or
covariance = sum(x*y)/8-(mean(x)*mean(y))
gives
2010 Oct 27
4
One silly question about "tapply output"
Dear R helpers
I have a data which gives Month-wise and Rating-wise Rates. So the input file is something like
month rating rate
January AAA 9.04
February AAA 9.07
..........................................
..........................................
Decemeber AAA 8.97
January BBB 11.15
February
2011 Mar 09
3
Rearranging the data
Dear R helpers,
xx = data.frame(country = c("USA", "UK", "Canada"), x = c(10, 50, 20), y = c(40, 80, 35), z = c(70, 62, 10))
> xx
country x y z
1 USA 10 40 70
2
UK 50 80 62
3 Canada 20 35 10
I need to arrange this as a new data.frame as follows -
country type values
USA
2011 Jan 25
4
Subtracting elements of data.frame
Dear R helpers
I have a dataframe as
df = data.frame(x = c(1, 14, 3, 21, 11), y = c(102, 500, 40, 101, 189))
> df
x y
1 1 102
2 14 500
3 3 40
4 21 101
5 11 189
# Actually I am having dataframe having multiple columns. I am just giving an example.
I need to subtract all the rows of df by the first row of df i.e. I need to subtract each element of 'x' column by 1. Likewise I
2011 Mar 16
2
One to One Matching multiple vectors
Dear R helpers
Suppose,
x = c(0, 1, 2, 3)
y = c("A", "B", "C", "D")
z = c(1, 3)
For given values of z, I need to the values of y. So I should get "B" and "D".
I tried doing
y[x][z] but it gives
> y[x][z]
[1] "A" "C"
Kindly guide.
Regards
Vincy
[[alternative HTML version deleted]]
2011 May 30
2
Value of 'pi'
Dear R helpers,
I have one basic doubt about the value of pi. In school, we have learned that
pi = 22/7 (which is = 3.142857). However, if I type pi in R, I get pi = 3.141593. So which value of pi should be considered?
Regards
Vincy
[[alternative HTML version deleted]]
2011 Aug 25
1
Autocorrelation using acf
Dear R list
As suggested by Prof Brian Ripley, I have tried to read acf literature. The main problem is I am not the statistician and hence have some problem in understanding the concepts immediately. I came across one literature (http://www.stat.nus.edu.sg/~staxyc/REG32.pdf) on auto-correlation giving the methodology. As per that literature, the auto-correlation is arrived at as per following.
2011 Sep 14
2
Question regarding dnorm()
Hi,
I have one basic doubt. Suppose X ~ N(50,10).
I need to calculate Probability X = 50.
dnorm(50, 50, 10) gives me
[1] 0.03989423
My understanding is (which is bit statistical or may be mathematical) on a continuous scale, Probability of the type P(X = .....) are nothing but 1/Infinity i.e. = 0. So as per my understanding P(X = 50) should be 0, but even excel also gives 0.03989422. Obviously
2010 Dec 09
4
Sequence generation in a table
Dear R helpers
I have following input
f = c(257, 520, 110). I need to generate a decreasing sequence (decreasing by 100) which will give me an input (in a tabular form) like
257, 157, 57
520, 420, 320, 220, 120, 20
110, 10
I tried the following R code
f = c(257, 520, 110)
yy = matrix(data = NA, nrow = 3, ncol = 6)
for (i in 1:3)
{
value = NULL
for (j in 1 : 6)
{
2012 May 22
3
What's wrong with MEAN?
Dear R helpers,
I have recently installed R version 2.15.0
I just wanted to calculate
mean(16, 18)
Surprisingly I got answer as
> mean(16, 18)
[1] 16
> mean(18, 16)
[1] 18
> mean(14, 11, 17, 9, 5, 18)
[1] 14
So instead of calculating simple Arithmetic average, mean command is generating first element as average. I restarted the machine, changed the machine, but still the
2012 Apr 20
3
Matrix multiplication by multple constants
Dear R helpers
Suppose
x <- c(1:3)
y <- matrix(1:12, ncol = 3, nrow = 4)
> y
[,1] [,2] [,3]
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
I wish to multiply 1st column of y by first element of x i.e. 1, 2nd column of y by 2nd element of x i.e. 2 an so on. Thus the resultant matrix should be like
> z
[,1] [,2] [,3]
[1,] 1
2010 Dec 31
3
Changing column names
Dear R helpers
Wish you all a very Happy and Prosperous New Year 2011.
I have following query.
country = c("US", "France", "UK", "NewZealand", "Germany", "Austria", "Italy", "Canada")
Through some other R process, the result.csv file is generated as
result.csv
var1 var2 var3 var4 var5 var6 var7
2012 Sep 12
6
How to append the random no.s for different variables in the same data.frame
Dear R helpers,
(At the outset I sincerely apologize if I have not put forward my following query properly, though I have tried to do so.)
Following is a curtailed part of my R - code where I am trying to generate say 100 random no.s for each of the products under consideration.
library(plyr)
n = 100
my_code = function(product, output_avg, output_stdev)
{
BUR_mc = rnorm(n, output_avg,
2011 Mar 21
2
Correlation for no of variables
Dear R helpers,
Suppose I have stock returns data of say 1500 companies each for say last 4 years. Thus I have a matrix of dimension say 1000 * 1500 i.e. 1500 columns representing companies and 1000 rows of their returns.
I need to find the correlation matrix of these 1500 companies.
So I can find out the correlation as
cor(returns) and expect to get 1500 * 1500 matrix. However, the process
2012 Jul 19
3
Maintaining Column names while writing csv file.
Dear R helpers,
I have one trivial problem while writing an output file in csv format.
I have two dataframes say df1 and df2 which I am reading from two different csv files.
df1 has column names as date, r1, r2, r3 while the dataframe df2 has column names as date, 1w, 2w.
(the dates in both the date frames are identical also no of elements in each column are equal say = 10).
I merge these