Displaying 20 results from an estimated 600 matches similar to: "Editing Strings in R"
2003 Jul 07
2
(PR#3427)
Hi;
I am having problems inverting matrices using the function
solve()
For example R can not invert the following matrix
[,1] [,2] [,3] [,4]
[,5]
[1,] 25 500 11250 275000
7.106250e+06
[2,] 500 11250 275000 7106250
1.906250e+08
2008 Nov 08
1
Clustering and functions
I am new to R and have written a function that clusters on subsets of a big data data set with 60,000 points. I am not sure why, but I keep getting a run-time error. Any suggestions would be greatly appreciated.
Here is the code:
library(cba)
d<-read.csv("data.csv", header=TRUE)
v<-c(53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,21,72 73,74,75,76,77,78)
2007 May 23
1
I made some progress on my previous "systemfit" question but still not quite there
Surprisingly, I played around with some test code and below actually
creates equations that look correct.
tempmat<-matrix(10,nrow=6,ncol=6)
restrictmat<-diag(6)
colnames(tempmat)<-c("AUD.l1","CHF.l1","CAD.l1","GBP.l1","EUR.l1","JPY.l
1")
2004 Nov 20
2
subset on data frame
I have a data frame. And I'd like to subset according to rownames.
subset(mydataframe, rownames(mydataframe) == myrow, select = mycols)
it turned out that "myrow" cannot be a vector. But I have multiple rows to
pick. Is there a way to get around this problem??
Thank you for your help!!
Lei Jiang
Department of Chemsitry
University of Washington
Box 351700
Seattle, WA 98195
2013 Jul 01
2
Problem with anova and the new abbreviation restrictions
An unwanted side effect of the new restrictions on abrreviated names.
The anova.coxph command, in a slavish copy of anova.lm etc, returns a data frame with
column labels of
loglik Chisq Df Pr(>|Chi|)
If one tries to extract the final column of the table errors result since it is not a
standard R variable name.
> afit <- anova(lm(conc ~ uptake, CO2))
> afit$P
[1]
2009 Nov 05
4
The equivalence of t.test and the hypothesis testing of one way ANOVA
I read somewhere that t.test is equivalent to a hypothesis testing for
one way ANOVA. But I'm wondering how they are equivalent. In the
following code, the p-value by t.test() is not the same from the value
in the last command. Could somebody let me know where I am wrong?
> set.seed(0)
> N1=10
> N2=10
> x=rnorm(N1)
> y=rnorm(N2)
> t.test(x,y)
Welch Two Sample t-test
data:
2006 Apr 19
1
Probable Numeric Bugs in svd function (PR#8781)
Hello,=0D
=0D
I just noticed that the "svd" function does not work properly for some=0D
sparse matrices.=0D
When I replace the 0 by very small noises (let's say 10^-16), it then=0D
works.=0D
The test I've performed is to compared the singular values to the eigen=0D
values (as I work with squarred matrices).=0D
=0D
Here is the code (I may be wrong!):=0D
=0D
2011 Nov 24
3
Is there way to add a new row to a data frame in a specific location
Is there easy way (without copying the existing rows to a temporary
location and copying back) to add a new row to a specific index location in
an existing data frame?
Example
df = data.frame( A= c('a','b','c'), B=c(1,2,3), C=(10,20,30))
newrow = c('X', 100, 200)
I want to add the newrow as the second row to the data frame df
Please suggest a solution that is
2009 Sep 17
2
What does model.matrix() return?
Hi,
I don't understand what the meaning of the following lines returned by
model.matrix(). Can somebody help me understand it? What can they be
used for?
attr(,"assign")
[1] 0 1 2 2
attr(,"contrasts")
attr(,"contrasts")$A
[1] "contr.treatment"
attr(,"contrasts")$B
[1] "contr.treatment"
Regards,
Peng
> a=2
> b=3
> n=4
2011 Nov 23
1
Losing custom attributes
Hi All,
I was adding a new row of data to my data frame using rbind(). I
was surprised to see that after adding new row, I lost my data frame level
attibute as well as col level attribute. Please help me to insert a new
row at frist or middle position so that my custom attribute is not lost.
Here is what I did.
age<-c(15,20,18)
weight<-c(40,42,30)
### creating my data frame
2010 Feb 09
1
"1 observation deleted due to missingness" from summary() on the result of aov()
I have the R code at the end. The last command gives me "1 observation
deleted due to missingness". I don't understand what this error
message. Could somebody help me understand it and how to fix the
problem?
> summary(afit)
Df Sum Sq Mean Sq F value Pr(>F)
A 2 0.328 0.16382 0.1899 0.82727
B 3 2.882 0.96057 1.1136 0.34644
C
2006 May 12
7
RJS and page.select collection size
I need to implement a conditional in my RJS template which looks
something like:
if (page.select(''row1'').first != null)
page << "new TableRow.MoveAfter(''row1'', ''newrow'');"
else
page << "new TableRow.MoveAfter(''row2'', ''newrow'');"
end
Now, dumb question.. My
2008 Oct 15
2
R: "in-place" appending to a matrix.
Hello fellow R sufferers,
Is there a way to perform an appending operation in place?
Currently, the way my pseudo-code goes is like this
for (i in 1:1000) {
if (some condition) {
newRow <- myFunction(myArguments)
X <- rbind(X, newRow) # <- this is the bottleneck!!
}
}
As you can see, it works but as the matrix X gets the size of a few million
rows, the
2011 Apr 28
1
Trying to perform an inner loop a random number of times
Grateful for any hints as to why I'm not getting the inner loop to cycle the
expected number of times.
Code and one run's results below.
Thanks,
Galen
> # source("looptest.r")
> sp<-numeric()
> iter<-numeric()
> rn<-numeric()
> ds<-data.frame(sp, iter, rn)
>
> for (sp in c(1:6)) {
+ i<-1
+
2009 Nov 22
1
Why F value and Pr are not show in summary() of an aov() result?
I have the following code. I'm wondering why summary() doesn't show F
value and Pr?
Rscript multi_factor.R
> a=3
> b=4
> c=5
> d=6
> e=7
>
> A=1:a
> B=1:b
> C=1:c
> D=1:d
> E=1:e
>
> X=matrix(nr=a*b*c*d*e,nc=5)
> colnames(X)=LETTERS[1:5]
>
> for(i_a in 1:a-1) {
+ for(i_b in 1:b-1) {
+ for(i_c in 1:c-1) {
+ for(i_d in 1:d-1) {
+
2009 Sep 15
1
coefficients of aov results has less number of elements?
Hi,
I run the following commands. 'A' has 3 levels and 'B' has 4 levels.
Should there be totally 3+4 = 7 coefficients (A1, A2, A3, B1, B2, B3,
B4)?
> a=3
> b=4
> n=1000
> A = rep(sapply(1:a,function(x){rep(x,n)}),b)
> B = as.vector(sapply(sapply(1:b, function(x){rep(x,n)}), function(x){rep(x,a)}))
> Y = A + B + rnorm(a*b*n)
>
> fr =
2009 Sep 22
1
Singular model.matrix of nested designs
Hi,
I want to do ANOVA for nested designs like following. I don't
understand why the matrix (t(X) %*% X) is singular. Can somebody help
me understand it?
Regards,
Peng
> a=2
> b=3
> n=4
> A = as.vector(sapply(1:a,function(x){rep(x,b*n)}))
> B = as.vector(sapply(1:(a*b), function(x){rep(x,n)}))
> cbind(A,B)
A B
[1,] 1 1
[2,] 1 1
[3,] 1 1
[4,] 1 1
[5,] 1 2
[6,] 1 2
[7,]
2011 Oct 29
1
Add col in data.frame
Hello Gurus,
I am still new to R. Here is my issue.
I was trying to add column to data frame that was populated by read.spss().
When I used cbind to add a new variable(column).
library(foreign)
mydf<-read.spss(file="C:/myspss.sav",use.value.labels=FALSE,
to.data.frame=TRUE,use.missings=FALSE)
attr(mydf,"variable.labels")
## it gives you all the labels
2010 Feb 06
1
duplicating records
Dear friends,
I need to fill in (duplicate the whole record) the missing days with the
same record values as long as AE is the same value (i.e. "1"), once AE
value changes, the process of duplication should proceed with the new AE
value till it changes again. e.g. I need to fill in records: day 18-day
44, all the records are carried with the new AE value of "0".
At the
2011 Nov 23
2
SPSS F-test on change in R square between hierarchical models
Hi,
I am wondering if anyone knows how to perform an F-test on the change in R
square between hierarchical models in R? SPSS provides this information and
a researcher that I am working with is interested in getting this
information. Alternatively, if someone knows how I can calculate the test
statistic (SPSS calls it F-change?) and dfs that would be helpful as well.
The output and the test I am