Displaying 20 results from an estimated 30000 matches similar to: "Combining matrices"
2009 Dec 18
2
how to combine multiple indicator variables in a single factor
Say I have a dataframe like this:
df <- data.frame(cbind(c(1,0,0,1),c(0,1,0,0),c(0,0,1,0)))
names(df) <- c('a','b','c')
I would like to create a factor in a new column, where the factor values are taken from the column names, like this:
> df2
a b c f
1 1 0 0 a
2 0 1 0 b
3 0 0 1 c
4 1 0 0 a
How would I do this? Thanks,
Dan
Daniel Nordlund
Bothell, WA USA
2012 Jul 27
2
How can I access an element of a string?
Dear Daniel and Jorge,
Thank you very much and it does help.
If I have a string "ABCD", how can I access the second element of the
string "B"? Thanks,
Miao
2012/7/27 Daniel Nordlund <djnordlund@frontier.com>
> > -----Original Message-----
> > From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org]
> > On Behalf Of jpm miao
2012 Mar 23
4
Missing Windows binary for R-2.15RC?
Hi,
The page
http://cran.r-project.org/bin/windows/base/rtest.html
has a link to:
http://cran.r-project.org/bin/windows/base/R-2.15.0rc-win.exe
However, clicking on that link gives a 404 "Object not found' error.
FYI.
Dan
2011 Feb 10
1
Revolution Analytics reading SAS datasets
Has anyone heard whether Revolution Analytics is going to release this capability to the R community?
http://www.businesswire.com/news/home/20110201005852/en/Revolution-Analytics-Unlocks-SAS-Data
Dan
Daniel Nordlund
Bothell, WA USA
2010 Feb 11
2
SAS and RODBC
I am using R-2.10.1 binary from CRAN on a WinXP Pro system. I also use SAS v9.2 on the same box. I just started using the SAS ODBC driver that comes with version 9 of SAS. I have been able to set up an ODBC source for SAS datasets using the driver, and then with RODBC I am able to read a sample SAS dataset.
> library(RODBC)
> ch <- odbcConnect('sasodbc', believeNRows=FALSE)
2011 Aug 04
2
Efficient way of creating a shifted (lagged) variable?
Hello!
I have a data set:
set.seed(123)
y<-data.frame(week=seq(as.Date("2010-01-03"), as.Date("2011-01-31"),by="week"))
y$var1<-c(1,2,3,round(rnorm(54),1))
y$var2<-c(10,20,30,round(rnorm(54),1))
# All I need is to create lagged variables for var1 and var2. I looked
around a bit and found several ways of doing it. They all seem quite
complicated - while in
2013 Apr 18
2
Multiple Multivariate regression in R with 50 independent variables
Hello all
Is there a method/package in R in which I can do regressions for more than
50 independent variables ?
Regards
The woods are lovely, dark and deep
But I have promises to keep
And miles before I go to sleep
And miles before I go to sleep
-----
[[alternative HTML version deleted]]
2011 Mar 09
2
Complex sampling?
R users,
I am trying to generate a randomized weekday survey schedule that ensures even coverage of weekdays in
the sample, where the distribution of variable DOW is random with respect to WEEK. To accomplish this I need
to randomly sample without replacement two weekdays per week for each of 27 weeks (only 5 are shown). However,
I need to sample from a sequence (3:7) that needs to be
2010 Oct 09
4
same random numbers in different sessions
Dear all
I'm using Xubuntu Lucid and I keep getting the same random numbers
whenever I start a new session of R. For example, I keep getting
> sample(1:1000, 1)
[1] 87
or
> rnorm(1:10)
[1] -1.3618103 0.4241701 1.0720076 0.2208145 -0.5375314 -0.4846588
[7] 0.7576768 0.6527407 -0.6868786 0.8718527
I expected that some set.seed() instruction woudl be present in a
config file in
2011 Apr 21
2
combining matrices
Heja,
I hope someone is still there to help me:
How can I somehow merge/combine matrices to get such a result:
Matrix A
A B
x1 1 0
x2 1 1
Matrix B
C D
x3 1 0
x4 0 1
Resulting Matrix?
A B C D
x1 1 0 0 0
x2 1 1 0 0
x3 0 0 1 0
x4 0 0 0 1
Does anyone see this probably obvious solution with R how to do this?
Sorry if this question is silly...it's too hot here to think properly ;O)
2011 Nov 07
3
Sampling with conditions
Hey everyone,
I am at best, an amateur user of R, but I am stuck on how to set-up the
following situation.
I am trying to select a random sample of numbers from 0 to 10 and insert
them into the first column of a matrix (which will used later in a loop).
However, I need to have those numbers add up to 10. How can I set those
conditions?
So far I have:
n<-matrix(0,nr=5,ncol=10)
for(i in
2010 Feb 13
2
lm function in R
Hello,
I am trying to learn how to perform Multiple Regression Analysis in R. I
decided to take a simple example given in this PDF:
http://www.utdallas.edu/~herve/abdi-prc-pretty.pdf
I created a small CSV called, students.csv that contains the following data:
s1 14 4 1
s2 23 4 2
s3 30 7 2
s4 50 7 4
s5 39 10 3
s6 67 10 6
Col headers: Student id, Memory span(Y), age(X1), speech rate(X2)
Now
2005 May 06
4
Choices from a matrix
Could someone please suggest a more clever solution to the following problem than my loop below?
Given X a 2xN matrix X, and I a k-subset of N,
Generate the (2^k)xN matrix Y with columns not in I all zero and the other columns with all choices of an entry from the first or second row of X.
For example, with
X <- matrix(1:8, nrow=2)
I <- c(1,3)
X is
1 3 5 7
2 4 6 8
and Y should be
1 0 5
2004 Nov 01
5
make apply() return a list
Hi,
I have a dataframe (say myData) and want to get a list (say myList) that
contains a matrix for each row of the dataframe myData. These matrices are
calculated based on the corresponding row of myData. Using a for()-loop to do
this is very slow. Thus, I tried to use apply(). However, afaik apply() does
only return a list if the matrices have different dimensions, while my
matrices have
2007 Jan 24
1
solving a structural equation model using sem or other package
I am trying to work my way through the book "Singer, JD and Willett, JB, Applied Longitudinal Data Analysis. Oxford University Press, 2003" using R. I have the SAS code and S-Plus code from the UCLA site (doesn't include chapter 8 or later problems). In chapter 8, there is a structural equation/path model which can be specified for the sem package as follows
S <- cov(al2)
2009 Aug 22
3
Help on comparing two matrices
Hi,
I need to compare two matrices with each other. If you can get one of
them out of the other one by resorting the rows and/or the columns, then
both of them are equal, otherwise they're not. A matrix could look like
this:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 0 1 1 1 0 1 1 0
[2,] 1 1 0 0 0 1 0 1
[3,] 1 0 1 0 0
2007 Apr 20
4
importing sas datasets
Hello,
I wanted to ask help about importing sas datasets.
1)I tried with some functions as read.ssd (foreign package),
but it doesn't import the file if the length of the
variables' names are longer than 8 bite (it has to conform
to the 6 version).
2)I then tried with the sas.get function (Hmisc package) but
with the command:
c<- sas.get(lib="c:\\ghan",
2012 Mar 31
2
A introductory question about Zips law (Newbie to statistics)
Hi everyone.
Newbie to statistics.
I have 40 matrices of ~400 values. how may I determine whether the
distribution follows zips law?
response <-sample (1:20,400*4, replace= TRUE)
Thank you vry much.
--
View this message in context: http://r.789695.n4.nabble.com/A-introductory-question-about-Zips-law-Newbie-to-statistics-tp4521190p4521190.html
Sent from the R help mailing list archive at
2006 Jun 15
2
Problem on Matrix multiplication
Dear all r-users,
I am getting a big problem with matrix multiplication
suppose I have,
> weight
Weight
1 1067640
2 8871500
3 42948778
4 127583735
5 22000000
6 44000000
7 56850000
8 23805662
and,
> s
a b c d e
f g h
a 402493.18 -133931.62 461483.3 -94042.86 674493.8
2004 May 22
2
How to define specific location of tick marks in plot()
Hi,
I wish to create a series of plots with the same x-axis range and the same
placement of tick marks. In addition I want to force the tick marks to be at
specific locations. For example, if I wish to have an x-axis which goes from
40 to 110, with tick marks at 40, 50, 60, ... , How can I accomplish that?
The various parameters I have tried changing just seem to be suggestions for