[R] R example for ancova

2009-12-05 Thread syrvn

Hi list,

does anybody know a easy to understand example in R which shows how to
perfom an ANCOVA?
I already tried to understand the example which you get when you type ?aov,
but I did not really
understand the output.


Best,
syrvn

-- 
View this message in context: 
http://n4.nabble.com/R-example-for-ancova-tp949324p949324.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Vectors with equal sd but different slope

2010-01-29 Thread syrvn

Hi,

what I would need are 2 vector pairs (x,y) and (x1,y1). x and x1 must have
the same sd. y and y1 should also exhibit the same sd's but different ones
as x and x1. Plotting x,y and x1,y1 should produce a plot with 2 vectors
having a different slope. Plotting both vector pairs in one plot with fixed
axes should reveal the different slope.


many thanks
syrvn
-- 
View this message in context: 
http://n4.nabble.com/Vectors-with-equal-sd-but-different-slope-tp1415562p1415562.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problems installing stats (prcomp) package

2010-02-09 Thread syrvn

Hi,

since nearly 2 hours I try to install the stats package which includes the
prcomp package for
principal component analysis. I can not find the stats package via the R
paket-repository.
I found the following url (http://finzi.psych.upenn.edu/R/library/stats/)
which includes
2 files: stats.rdb and stats.rdx. I downloaded both files and tried to
install them via the R installer
choosing local packets (binary and source) but both variants failed.

Can anyone help?

best
mentor
-- 
View this message in context: 
http://n4.nabble.com/Problems-installing-stats-prcomp-package-tp1474341p1474341.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] convert data.frame to matrix -> NA factor problem

2010-07-14 Thread syrvn

Hi list,

I tried to convert a data.frame into a matrix using data.matrix.
Unfortunately my matrix contains missing values (NA) wherefore all columns
including NA's were changed into factors.

I thought that many people stumbled across that problem already wherefore
there must be a
simple solution. But it seems there isn't. I tried lapply, replace and other
things in combination
but still did not manage to convert my data.frame into a proper matrix with
numeric values.

Any advice?
Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-data-frame-to-matrix-NA-factor-problem-tp2288828p2288828.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert data.frame to matrix -> NA factor problem

2010-07-14 Thread syrvn

Hi,

I used str() on my data set:

$ X1: num  1 1 0 1 1 1 1 1 1 1 ...
$ X2: num  0 1 0 2 1 2 0 2 2 0 ...
$ X3: Factor w/ 4 levels "0","1","2","NA": 2 1 3 1 1 1 1 1 1 3
...



The difference to your str() output is that in your case NA columns are
"num" columns
and in my case they are Factors. That's prob. why it replaces the NAs with 4
after
applying data.matrix.

I use the package xlsx to read the data in as an excel file.

Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-data-frame-to-matrix-NA-factor-problem-tp2288828p227.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert data.frame to matrix -> NA factor problem

2010-07-14 Thread syrvn

Thanks again for your quick reply.

I understood your procedure but now it is even more strange why my
conversion does not work.
In your example, the NA values are in "brackets"  and what your
procedure does is to
convert these  values into NA and then it seems to be possible to use
data.matrix to
correctly convert the data.frame into a data.matrix. But the data I read
into R are already in that
form that the NA values are displayed as NA rather than . So the
conversion should actually work.

Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-data-frame-to-matrix-NA-factor-problem-tp2288828p2289022.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] p-values pvclust maximum distance measure

2010-07-20 Thread syrvn

Hi,

I am new to clustering and was wondering why pvclust using "maximum"
as distance measure nearly always results in p-values above 95%.

I wrote an example programme which demonstrates this effect. I
uploaded a PDF showing the results


Here is the code which produces the PDF file:

-
s <- matrix(runif(1600,0,1000), nrow=20)

a.res1 <- pvclust(t(s), method.hclust="complete", method.dist="euclidian",
nboot=500)
a.res2 <- pvclust(t(s), method.hclust="complete", method.dist="maximum",
nboot=500)
a.res3 <- pvclust(t(s), method.hclust="complete", method.dist="canberra",
nboot=500)
a.res4 <- pvclust(t(s), method.hclust="ward", method.dist="euclidian",
nboot=500)
a.res5 <- pvclust(t(s), method.hclust="ward", method.dist="maximum",
nboot=500)
a.res6 <- pvclust(t(s), method.hclust="ward", method.dist="canberra",
nboot=500)
a.res7 <- pvclust(t(s), method.hclust="average", method.dist="euclidian",
nboot=500)
a.res8 <- pvclust(t(s), method.hclust="average", method.dist="maximum",
nboot=500)
a.res9 <- pvclust(t(s), method.hclust="average", method.dist="canberra",
nboot=500)

s <- matrix(runif(1600,0,2), nrow=20)

b.res1 <- pvclust(t(s), method.hclust="complete", method.dist="euclidian",
nboot=500)
b.res2 <- pvclust(t(s), method.hclust="complete", method.dist="maximum",
nboot=500)
b.res3 <- pvclust(t(s), method.hclust="complete", method.dist="canberra",
nboot=500)
b.res4 <- pvclust(t(s), method.hclust="ward", method.dist="euclidian",
nboot=500)
b.res5 <- pvclust(t(s), method.hclust="ward", method.dist="maximum",
nboot=500)
b.res6 <- pvclust(t(s), method.hclust="ward", method.dist="canberra",
nboot=500)
b.res7 <- pvclust(t(s), method.hclust="average", method.dist="euclidian",
nboot=500)
b.res8 <- pvclust(t(s), method.hclust="average", method.dist="maximum",
nboot=500)
b.res9 <- pvclust(t(s), method.hclust="average", method.dist="canberra",
nboot=500)

pdf("YOUR PATH/Res.pdf", width=10, height=15)

par(mfrow=c(6,3))
plot(a.res1)
plot(a.res2)
plot(a.res3)
plot(a.res4)
plot(a.res5)
plot(a.res6)
plot(a.res7)
plot(a.res8)
plot(a.res9)

plot(b.res1)
plot(b.res2)
plot(b.res3)
plot(b.res4)
plot(b.res5)
plot(b.res6)
plot(b.res7)
plot(b.res8)
plot(b.res9)

dev.off()
--


Why is that???
Cheers syrvn


http://r.789695.n4.nabble.com/file/n2295594/Res.pdf Res.pdf 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/p-values-pvclust-maximum-distance-measure-tp2295594p2295594.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] p-values pvclust maximum distance measure

2010-07-20 Thread syrvn

Hi,

I am new to clustering and was wondering why pvclust using "maximum"
as distance measure nearly always results in p-values above 95%.

I wrote an example programme which demonstrates this effect. I
uploaded a PDF showing the results


Here is the code which produces the PDF file:

-
s <- matrix(runif(1600,0,1000), nrow=20)

a.res1 <- pvclust(t(s), method.hclust="complete", method.dist="euclidian",
nboot=500)
a.res2 <- pvclust(t(s), method.hclust="complete", method.dist="maximum",
nboot=500)
a.res3 <- pvclust(t(s), method.hclust="complete", method.dist="canberra",
nboot=500)
a.res4 <- pvclust(t(s), method.hclust="ward", method.dist="euclidian",
nboot=500)
a.res5 <- pvclust(t(s), method.hclust="ward", method.dist="maximum",
nboot=500)
a.res6 <- pvclust(t(s), method.hclust="ward", method.dist="canberra",
nboot=500)
a.res7 <- pvclust(t(s), method.hclust="average", method.dist="euclidian",
nboot=500)
a.res8 <- pvclust(t(s), method.hclust="average", method.dist="maximum",
nboot=500)
a.res9 <- pvclust(t(s), method.hclust="average", method.dist="canberra",
nboot=500)

s <- matrix(runif(1600,0,2), nrow=20)

b.res1 <- pvclust(t(s), method.hclust="complete", method.dist="euclidian",
nboot=500)
b.res2 <- pvclust(t(s), method.hclust="complete", method.dist="maximum",
nboot=500)
b.res3 <- pvclust(t(s), method.hclust="complete", method.dist="canberra",
nboot=500)
b.res4 <- pvclust(t(s), method.hclust="ward", method.dist="euclidian",
nboot=500)
b.res5 <- pvclust(t(s), method.hclust="ward", method.dist="maximum",
nboot=500)
b.res6 <- pvclust(t(s), method.hclust="ward", method.dist="canberra",
nboot=500)
b.res7 <- pvclust(t(s), method.hclust="average", method.dist="euclidian",
nboot=500)
b.res8 <- pvclust(t(s), method.hclust="average", method.dist="maximum",
nboot=500)
b.res9 <- pvclust(t(s), method.hclust="average", method.dist="canberra",
nboot=500)

pdf("YOUR PATH/Res.pdf", width=10, height=15)

par(mfrow=c(6,3))
plot(a.res1)
plot(a.res2)
plot(a.res3)
plot(a.res4)
plot(a.res5)
plot(a.res6)
plot(a.res7)
plot(a.res8)
plot(a.res9)

plot(b.res1)
plot(b.res2)
plot(b.res3)
plot(b.res4)
plot(b.res5)
plot(b.res6)
plot(b.res7)
plot(b.res8)
plot(b.res9)

dev.off()
--


Why is that???
Cheers syrvn


http://r.789695.n4.nabble.com/file/n2295593/Res.pdf Res.pdf 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/p-values-pvclust-maximum-distance-measure-tp2295593p2295593.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Brute-force clustering

2010-07-21 Thread syrvn

Hi all,

I use heatmap.2 for clustering and as you know you can choose between
several distance functions and clustering algorithms. Trying all
combinations isn't too bad but I have two further parameters and whenever I
change one of these I need do redo all cluster combinations. It probably
takes weeks to test all possible
combinations that's why I would like to use a kind of brute-force solution
to test all combinations.

One major issue is that I have 20 different cases c1-c20 and I need c1-c5 to
be in one cluster and c6-c8 in a different one and so on. So after trying a
certain combination I somehow need to check whether the cases fall into the
same clusters.

Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Brute-force-clustering-tp2296897p2296897.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Clustering groups

2010-07-21 Thread syrvn

Hi,

is there a way in R to identify those cluster methods / distance measures
which best reflect predefined cluster groups.

Given 10 observations O1...O10. Optimally, these 10 observations cluster as
follows:
cluster1: O1, O2, O3, O4
cluster2: O5, O6
cluster3: O7, O8, O9, O10.

What I want is a method which identifies that cluster method / distance
measure which best reflect my predefined groups.

Is that somehow possible to do?
Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Clustering-groups-tp2297210p2297210.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] specify heat.colors

2010-07-23 Thread syrvn

Hi,

I use heatmap.2 and heat.colors. Is it possible to specify the colors in
that way that
all values below, for instance, 1.5 should be coloured red, values between
1.5 and 1.7 green
and above 1.7 black?

Many thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/specify-heat-colors-tp2300139p2300139.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problems extracting p-value from summary(aov(...))

2010-09-29 Thread syrvn

Hi,

I did a aov and used summary to obtain the p-value. I tried many ways to
extract the p-value from
the summary result but failed. Among others I tried the following:



> test.summary <-
> summary(aov(data[,1]~time.points+Error(subject/time.points)))
> test.summary

Error: subject
  Df  Sum Sq  Mean Sq F value Pr(>F)
Residuals  9 0.27467 0.030518   

Error: subject:time.points
Df   Sum Sq   Mean Sq F value  Pr(>F)  
time.points  2 0.018563 0.0092814  3.1777 0.06578 .
Residuals   18 0.052574 0.0029208  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
> 
> as.matrix(test.summary[[1]][,5])
Error in `[.default`(test.summary[[1]], , 5) : 
  incorrect number of dimensions
> test.summary$"Error: Within"[[1]]$"Pr(>F)"
NULL
> test.summary[[2]][,5]
Error in `[.default`(test.summary[[2]], , 5) : 
  incorrect number of dimensions
> 


Any advise?
Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Problems-extracting-p-value-from-summary-aov-tp2718726p2718726.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Significance of the difference between two correlation coefficients

2010-11-29 Thread syrvn

Hi,

based on the sample size I want to calculate whether to correlation
coefficients are significantly different or not. I know that as a first step
both coefficients
have to be converted to z values using fisher's z transformation. I have
done this already but I dont know how to further proceed from there.

unlike for correlation coefficients I know that the difference for z values
is mathematically defined but I do not know how to incorporate the sample
size.

I found a couple of websites that provide that service but since I have huge
data sets I need to automate this procedure.

(http://faculty.vassar.edu/lowry/rdiff.html)

Can anyone help?

Cheers,
syrvn

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Significance-of-the-difference-between-two-correlation-coefficients-tp3063765p3063765.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Significance of the difference between two correlation coefficients

2010-11-29 Thread syrvn

Hi,

thanks a lot. that's what i tried to figure out!
it works great and is exactly what i need.

Best,
syrvn

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Significance-of-the-difference-between-two-correlation-coefficients-tp3063765p3063997.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] p-values with pvclust

2010-08-10 Thread syrvn

Hi,


if you look at the first image (Image1)  you see that there are 2 main
clusters 7 and 8
I wanted to use pvclust to calculate a p-value whether these clusters are
due to chance
or statistically significant. Unfortunately pvclust does not provide a
p-value for the first
brunch (7 and 8).

So I added a row to my matrix which is very different to the rest of the
data to create an additional
brunch. See image here 
http://r.789695.n4.nabble.com/file/n2319732/Image2.png . I finally got my
p-value for the brunch (7 and 8) which is 98 (9).

I was happy to see that the p-value was significant until I realised that if
I add an additional brunch which
is not that different from the rest but still cluster in a sperate cluster
(see image here  http://r.789695.n4.nabble.com/file/n2319732/Image3.png )
the p-value is changing and not significant any longer (84).



I was wondering why this happens because I thought that for each brunch the
p-value is calculated independently?

Does anybody know how to get a correct p-value for the first brunch (7 and
8) maybe without adding an additional brunch?

Best regards
syrvn
-- 
View this message in context: 
http://r.789695.n4.nabble.com/p-values-with-pvclust-tp2319732p2319732.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] p-values with pvclust

2010-08-10 Thread syrvn

Hi,


if you look at the first image (Image1)  you see that there are 2 main
clusters 7 and 8
I wanted to use pvclust to calculate a p-value whether these clusters are
due to chance
or statistically significant. Unfortunately pvclust does not provide a
p-value for the first
brunch (7 and 8).

So I added a row to my matrix which is very different to the rest of the
data to create an additional
brunch. See image 2. I finally got my p-value for the brunch (7 and 8) which
is 98 (9).

I was happy to see that the p-value was significant until I realised that if
I add an additional brunch which
is not that different from the rest but still cluster in a sperate cluster
(see image 3) the p-value is changing and not significant any longer (84).

http://r.789695.n4.nabble.com/file/n2319739/ImageNew2.png 

I was wondering why this happens because I thought that for each brunch the
p-value is calculated independently?

Does anybody know how to get a correct p-value for the first brunch (7 and
8) maybe without adding an additional brunch?

Best regards
syrvn
-- 
View this message in context: 
http://r.789695.n4.nabble.com/p-values-with-pvclust-tp2319739p2319739.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to get row name of matrix when result is a vector

2010-09-03 Thread syrvn

Hi,

the R code:

a <- matrix(c(1,5,4,3,7,10,34,4,3,8,6,5,12,17,45,3,2,45,46,47,3,4,22,12,21),
nrow=5)
rownames(a) <- c("a","b","c","d","e")
a
a[which(a[,3] < 8), ]
a[which(a[,3] < 6), ]


produces the following output:

> a
  [,1] [,2] [,3] [,4] [,5]
a1   10633
b5   34524
c44   12   45   22
d33   17   46   12
e78   45   47   21

> a[which(a[,3] < 8), ]
  [,1] [,2] [,3] [,4] [,5]
a1   10633
b5   34524

> a[which(a[,3] < 6), ]
[1]  5 34  5  2  4


I actually thought it must be rather easy to somehow extract the row name
when the result is just a vector as in the second example and not a matrix.
I tried several ways but without any success.

Any advice?
Best,
syrvn 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-get-row-name-of-matrix-when-result-is-a-vector-tp2525631p2525631.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to get row name of matrix when result is a vector

2010-09-03 Thread syrvn

Hi,

I do not understand the code right now but it does its job.
Thanks a lot!

Best,
syrvn
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-get-row-name-of-matrix-when-result-is-a-vector-tp2525631p2525657.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] series of boxplots

2011-02-07 Thread syrvn

hi group,

imagine the following data frame df:

1 2 3 4 ...
A 5 1 ..
A 4 3 ..
A 3 4 ..
B 7 9 ..
B 8 1 ..
B 6 8 ..

I tried the following and some variations to plot this matrix as boxplots:


boxplot(df[1:3,2]~df[1:3,1], xlim=c(1,10))
par(new=TRUE)
boxplot(cpd12[4:6,2]~df[1:3,1], xlim=c(2,10))
par(new=TRUE)
boxplot(df[1:3,3]~df[1:3,1], xlim=c(1,10))
par(new=TRUE)
boxplot(cpd12[4:6,3]~df[1:3,1], xlim=c(2,10))


can anybody help?
Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/series-of-boxplots-tp3263938p3263938.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Test for equivalence

2011-02-12 Thread syrvn

Hi!

is there a way in R to check whether the outcome of two different
experiments is statistically distinguishable or indistinguishable? More
preciously, I used the wilcoxon test to determine the differences between
controls and treated subjects for two different experiments. Now I would
like to check whether the two lists of analytes obtained are statistically
distinguishable or indistinguishable

I tried to use a equivalence test from the 'equivalence' package in R but it
seems that this test is not applicable to my problem. The test in the
'equivalence' package just determines similarity between two conditions but
I need to compare the outcome of two different experiments.

My experiments are constructed as follows:

Exp1:
8 control samples
8 treated samples
-> determine significantly changes (List A)

Exp2:
8 control samples
8 treated samples
-> determine significantly changes (List B)


Now i would like to check whether List A and List B are distinguishable or
indistinguishable.

Any advice is very much appreciated!

Best,
beginner
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Test-for-equivalence-tp3302739p3302739.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Test for equivalence

2011-02-14 Thread syrvn

Hi!

first of all. Thank you all very much for your input. I am sorry but I
haven't had yet the
time to reply to all of your messages. I will give you a more detailed
description of my
problem within the next 2 days!

Many thanks again.

Best,
syrvn
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Test-for-equivalence-tp3302739p3305890.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R system command does not work with objects/variables

2011-08-23 Thread syrvn
Hello!

with the R system command I would like to call a perl script which needs an
input directory and an output directory in form of a path. When I put in the
path directly it works. The script line looks as follows:

system("perl '../path1' '../path2' '../path3'")

If I store the path in a variable/object and call the perl script again it
does not run and I don't know how to overcome that issue.

p1 <- "../path1"
p2 <- "../path2"
p3 <- "../path3"

system("perl p1 p2 p3")

I also tried:

system("perl 'p1' 'p2' 'p3'")

Can anyone help?

Best,
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/R-system-command-does-not-work-with-objects-variables-tp3762544p3762544.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R system command does not work with objects/variables

2011-08-23 Thread syrvn
Hi,

it works great with the paste command! thanks a lot!

Best,
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/R-system-command-does-not-work-with-objects-variables-tp3762544p3762583.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Open windows explorer with specific path using system command

2012-06-14 Thread syrvn
Hello!

I found out that it is possible to open the windows explorer with a
predefined path via the cmd.exe program using the following command:

explorer PATH

Back in R using the following command opens up the windows explorer:

system("explorer", intern=TRUE)

However, when I specify a path R returns the following warning message and
does not open the explorer at the specified path:

> system("explorer C:\\Users\\xxx", intern=TRUE)
character(0)
attr(,"status")
[1] 1
Warning message:
running command 'explorer C:\Users\xxx' had status 1

I quoted the \ otherwise R complained about not recognising \U from \Users.

However, when the command is executed as we would expect the double \\ are
replaced by only one \.

When I copy paste the explorer C:\Users\xxx bit from the R warning message
into the cmd.exe program the explorer is opened up at the specified path.

Does anybody have any idea why that fails?

Many thanks
Syrvn



--
View this message in context: 
http://r.789695.n4.nabble.com/Open-windows-explorer-with-specific-path-using-system-command-tp4633354.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Quantitative analysis of treatment effects

2012-07-02 Thread syrvn
Hello!

I need to analyse a biological study. The study design is rather simple. It
includes 3 groups. 1 control group
and 2 test groups. The two test groups are treated with the same drug but
different doses. Each group has
approximately 14 observations and I look at around 600 variables. I already
used an one way ANOVA to
determine the significant hits between the groups. However, I now want to
know if there is a quantitative
effect between the treatment doses. In other words, is the treatment effect
(the difference between the control
group and a test group) bigger when you use a lower or a higher dose of the
same drug. I also need to include
1 or 2 co-variates in the analysis.

Unfortunately, I do not know if there is a statistical test/technique in R
which I can use to answer this question.
Any advise is very much appreciated.

syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Quantitative-analysis-of-treatment-effects-tp4635094.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Quantitative analysis of treatment effects

2012-07-02 Thread syrvn
I found a nice presentation which I think addresses my question/problem.

See slide 3 here:

http://www.ispor.org/meetings/atlanta0510/presentations/IP1-CookJohnR.pdf

--
View this message in context: 
http://r.789695.n4.nabble.com/Quantitative-analysis-of-treatment-effects-tp4635094p4635095.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Difference between two-way ANOVA and (two-way) ANCOVA

2012-07-04 Thread syrvn
Hi!

as my subject says I am struggling with the different of a two-way ANOVA and
a (two-way) ANCOVA.

I found the following examples from this webpage:

http://www.statmethods.net/stats/anova.html

# One Way Anova (Completely Randomized Design)
fit <- aov(y ~ A, data=mydataframe)

# Randomized Block Design (B is the blocking factor) 
fit <- aov(y ~ A + B, data=mydataframe)

# Two Way Factorial Design 
fit <- aov(y ~ A + B + A:B, data=mydataframe)
fit <- aov(y ~ A*B, data=mydataframe) # same thing

# Analysis of Covariance 
fit <- aov(y ~ A + x, data=mydataframe)

I) The 1. example is pretty clear. A simple on way ANOVA. 

II) Is it correct to say that example 2. (which is called a Randomized Block
Design) is a two way ANOVA? 

III) Example 3 is like example 2. (in case I was right in II) )  a two way
ANOVA but including an interaction term. That's why
they call it here a Factorial Design.

So far so good.

IV) For me, the ANCOVA (last example) looks like a two-way ANOVA. So in what
way is the variable "x" different to variable "B" so that it is called an
ANCOVA and not an ANOVA??? I presume that from the type of data R knows
whether to perform an ANCOVA or an ANOVA.

V) Is it right to say that the ANCOVA example is a two-way ANCOVA? Or can a
one-way ANCOVA actually exists?

You see I am a bit confused especially how R distinguishes between the
ANCOVA and the two-way ANOVA?

I hope to find some useful answers here.

Cheers!


--
View this message in context: 
http://r.789695.n4.nabble.com/Difference-between-two-way-ANOVA-and-two-way-ANCOVA-tp4635403.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] list.files() find files beginning with a .

2012-07-08 Thread syrvn
Hello,

when I use list.files with recursive = TRUE and all.files = TRUE, R returns
a list of strings/paths.
>From all those strings I want to keep only the ones starting with a .
I tried using grep to achieve that. However, the problem is that because of
the recursive list.files parameter,
for some files beginning with a . there is a path attached. I think it is
not as simple as it looks because all files
end with . something. .xlsx or .txt or .r...

files <- list.files("~", recursive = TRUE, all.files = TRUE)
files
/XXX/ZZZ/.R_history
/XXX/ZZZ/AAA/Script.r
/XXX/ZZZ/BBB/test.xlsx
/XXX/ZZZ/CCC/.xyz

files <- files[grep("^.*$", files)]

I want grep to return only the following to lines:

/XXX/ZZZ/.R_history
/XXX/ZZZ/CCC/.xyz

Any ideas on how to solve that issue?

Cheers
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/list-files-find-files-beginning-with-a-tp4635773.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Error when writing to Excel files using the packages xlsx and xlsx2

2011-07-13 Thread syrvn
Dear group,

I am working on a rather big project where the output data frames have
dimensions of 3000 x 15 or greater. We are using xlsx and xlsx2 to write the
data.frames to Excel sheets.

Since recently we get the following error, when trying to write the data
frames to the excel sheets:

Error in ls(envir = envir, all.names = private) : 
  invalid 'envir' argument

We figured out that the error occurs when the excel sheet is open while R
tries to write to it.
But now, closing all open excel sheets does not fix the error any longer. We
also tried deleting the excel sheet in case it might be corrupt but we still
get the same error.

We have a very narrow timeframe so any help on how to fix that error is very
much appreciated.

Best regards,
Flo

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-when-writing-to-Excel-files-using-the-packages-xlsx-and-xlsx2-tp3664617p3664617.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error when writing to Excel files using the packages xlsx and xlsx2

2011-07-13 Thread syrvn
Hi Denis,

are you saying that we should write the R output (data frame) to a .csv file
and then import
it manually into Excel?

Thanks
Flo

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-when-writing-to-Excel-files-using-the-packages-xlsx-and-xlsx2-tp3664617p3664639.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error when writing to Excel files using the packages xlsx and xlsx2

2011-07-13 Thread syrvn
Hi,

thanks for this web page!

We decided to go for XLConnect because it can read and write xlsx sheets.
With that package we get the same error message (see above) as with the xlsx
package.

After that error we even end up with a corrupted excel spread sheet. We are
not able
to open it any longer.

Because both packages use java as an interface we may conclude it is not an
error in
the package itself but with java.

Any other advices?

Many thanks,
Flo

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-when-writing-to-Excel-files-using-the-packages-xlsx-and-xlsx2-tp3664617p3664981.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question regarding Kruskal-Wallis test

2011-11-15 Thread syrvn
Hello,


I need to analyse an experiment with 3 groups:

Control group
Treated group 1 (drug 1)
Treated group 2 (drug 2)

If I use a Kruskal-Wallis test do analyse the data and if I define the
control group as the reference group does the test do then the following
comparisons?

Control group vs. Treated group 1
Control group vs. Treated group 2
Treated group 1 vs. Treated group 2

I am not sure about whether the last comparison is made by the test or not?
What happens if I have 4 different groups? Are there then all possible
combinations compared?


Cheers,
Syrvn


--
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-Kruskal-Wallis-test-tp4042627p4042627.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Extract pattern from string

2011-11-15 Thread syrvn
Hello,

with Sys.time() you get the following string:

"2011-11-15 16:25:55 GMT"

How can I extract the following substrings:

year <- 2011

month <- 11

day_time <- 15_16_25_55


Cheers,

Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Extract-pattern-from-string-tp4073432p4073432.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extract pattern from string

2011-11-15 Thread syrvn
Wow, that is a very clever way to do it.

Thank you very much!


Cheers,

Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Extract-pattern-from-string-tp4073432p4074023.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Eclipse StatET - create own code formatting

2011-11-19 Thread syrvn
Hello,

does anybody know whether it is possible to create its own code formatting
rules?

Defining rules under Eclipse -> Preferences -> R Code Formatting is so
limited.



Cheers,

Syrvn


--
View this message in context: 
http://r.789695.n4.nabble.com/Eclipse-StatET-create-own-code-formatting-tp4086386p4086386.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] fixed-effect or random-effect ANOVA model

2011-11-23 Thread syrvn
Hello,

I have a big study to analyse and I am unsure of which technique to use.

I have a group of patients suffering from disease 1. This group further
divides into 4 sub groups A, B, C and D

On the other hand I have another group of patients suffering from disease 2.
This group divides into 5 sub groups E, F, G, H and I.

The aim of my analysis is to check whether there are proteins which are
significantly changed between the two different types of diseases.

For the analysis I would pool all patients suffering from disease 1 together
to obtain a single group. I would do the same for disease 2. Then I would
use either a fixed-effects or random-effects ANOVA to identify significantly
changed analytes.

When I started to read about the different types of ANOVA's I came across
the q-statistics which is used to account for the heterogeneity within a
group. So it checks whether the effect size between sub-group A, B, C and D
is approx. the same.

Does this analysis make sense or how would you analyse this kind of data? Is
there an R package which can easily deal with such situations?

Cheers,
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/fixed-effect-or-random-effect-ANOVA-model-tp4099308p4099308.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R package for nested random-effects ANOVA models

2011-11-24 Thread syrvn
Hello,

can anyone recommend an R package which can deal with nested random-effects
ANOVA models?

Cheers

Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/R-package-for-nested-random-effects-ANOVA-models-tp4104374p4104374.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Confidence and variance plots

2011-11-25 Thread syrvn
Hello list,

I need to analyse some data but before that I would like to use plots like
as follows
to visualise the variance in the data:

Page 38, Fig 2.9: http://lme4.r-forge.r-project.org/book/Ch2.pdf 

Page 42, Fig 2.11: http://lme4.r-forge.r-project.org/book/Ch2.pdf 

and

Page 4, Fig 1: http://www.ehjournal.net/content/pdf/1476-069x-9-31.pdf


Does anybody know how to produce such plots in R? Are there any package
which can plot such graphics or do I have to construct these by myself,
somehow?


Cheers,
Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Confidence-and-variance-plots-tp4107110p4107110.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] dir.create() does not create directory

2011-11-26 Thread syrvn
Hello,

I am running Windows 7 and R-2.13 in StatET. 

When I try to create a directory it does not print any errors but if I check
outside eclipse if it exists or do a refresh in Eclipse the directory is not
been created. The strange thing is that it happens only to some
sub-folders... On the other hand when I use the normal windows explorer in
one of these sub-folders and create a folder it works.

Any ideas? I also tried the mode="777" option but still the same problem


Cheers,

syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/dir-create-does-not-create-directory-tp4110517p4110517.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fitting a linear model with lmer in the lme4 package

2011-11-28 Thread syrvn
Hello,


I need to fit a "Nested Random Effects ANOVA model" with the lmer function
in the lme4 package.

I read through the documentation 

http://lme4.r-forge.r-project.org/book/Ch2.pdf

and the data structure of the "Pastes" data set looks almost

exactly like mine. The only difference is that I have another factor which
distinguishes controls

from diseased patients.

For the "Pastes" data set they fittet their "Nested Random Effects model" as
follows:

lmer(strength ~ 1 + (1|sample) + (1|batch), Pastes, REML=FALSE)

My data strucute looks like as follows:

http://www.pic-upload.de/view-12130948/data.png.html

I am not sure of how to fit my model now. Would it be as simple as only
adding the third factor?

lmer(Protein_1 ~ 1 + (1|Group) + (1|Sub_Disease) + (1|Disease)) ?
    

Cheers,

Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Fitting-a-linear-model-with-lmer-in-the-lme4-package-tp4115455p4115455.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] quick ANOVA question

2011-11-29 Thread syrvn
Hello,


imagine the following experimental design:

Group - Value

control - 5
control - 6
control - 5

treated1 - 8
treated1 - 9
treated1 - 9

treated2 - 15
treated2 - 16
treated2 - 15

treated3 - 25
treated3 - 30
treated3 - 28


What I like to know is if I apply an ANOVA to this data and choose the
control group as the reference group (using the relevel function) 
what groups exactly are compared? Are only all treated groups 1, 2, 3 tested
against the control group or are all possible combinations tested?

What is compared?

A) Testing: control vs treated1; control vs treated2; control vs treated3;

or

B) Testing: control vs treated1; control vs treated2; control vs treated3;

treated1 vs treated2; treated1 vs treated3; treated2 vs
treated3;


Cheers





--
View this message in context: 
http://r.789695.n4.nabble.com/quick-ANOVA-question-tp4118724p4118724.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help needed in reproducing a plot

2011-11-29 Thread syrvn
Hello,


can anybody tell me how to produce a plot like the one in 

http://cran.r-project.org/web/packages/lme4/vignettes/Implementation.pdf

on page 13, Figure 6?

The data is stored in:

library(nlme)
data(Oats)


Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-needed-in-reproducing-a-plot-tp4119603p4119603.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Data alignment

2011-12-03 Thread syrvn
Hello!

I have a data.frame which looks like:

Name - Value
A - 400
A - 300
B - 200
B - 350
C - 500
C - 350
D - 450 
D - 600
E - 700 
E - 750
F - 630
F - 650

I want to add another column where all A,B should get an index 1, all C,D an
index of 2 and all E,F an index of 3 so that the data.frame looks like:

ID - Name - Value
1 - A - 400
1 - A - 300
1 - B - 200
1 - B - 350
2 - C - 500
2 - C - 350
2 - D - 450 
2 - D - 600
3 - E - 700 
3 - E - 750
3 - F - 630
3 - F - 650

My data.frame is quite big so I cannot add all values by hand.


Cheers




--
View this message in context: 
http://r.789695.n4.nabble.com/Data-alignment-tp4153024p4153024.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Data alignment

2011-12-03 Thread syrvn
Thanks for your suggestions. I will try them.

The "-" in my original post was actually only there to serve as a separator
so that it is easier for you to see the data structure but apparently it
rather confused you... sorry :)

--
View this message in context: 
http://r.789695.n4.nabble.com/Data-alignment-tp4153024p4153112.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] replace values

2011-12-03 Thread syrvn
Hello,


imagine the following data.frame:

ID name
1 *_A
2 *_A
3 *_B
4 *_B

* = can be any pattern

I want to replace every row which ends with _A by 1 and every row which ends
by _B with a 0

so that the data.frame looks like the following:

ID name
1 1
2 1
3 0
4 0


Which function do I use best to achieve this?

Cheers,
Syrvn



--
View this message in context: 
http://r.789695.n4.nabble.com/replace-values-tp4153301p4153301.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] xyplot squeezed together

2011-12-04 Thread syrvn
Hi,


I created the following example of a xyplot. The plot actually looks ok
apart from that the

x-axis is pretty squeezed/clinched. I tried aspect="fill" already but I want
to have all 3 sub plots

next to each other. I tried loads of different scaling varieties but with no
significant result...



library(lattice)

N <- 6

d <- data.frame(factor(rep(c("A1","A2","A3"),each=N),
levels=c("A1","A2","A3")),

   factor(rep(c("B1", "B2", "B3", "B4", "B5", "B6", "B7", 
"B8", "B9"),
each=N/3),

  levels=c("B1", "B2", "B3", "B4", "B5", "B6", 
"B7",
"B8", "B9")),

rep(c(0,1), each=N/3/2))

colnames(d) <- c("ID", "class", "group")

value <- matrix(c(400,300, 320,380, 410,500, 800,670, 810,900, 560,750,
1100,1200, 1200,1300, 1300,1200))

d <- cbind(d, value)

xyplot(value ~ group | ID, d, groups = class, type = c("g", "b"),

  auto.key = list(lines = TRUE, columns = 3), xlab = "blocked=0,
released=1",

  ylab = "value", aspect = 'xy', scales=list(x=list(at=-1:2,
labels=c("",0,1,""



Anyone any ideas how to enlarge the x-axis?

Cheers


--
View this message in context: 
http://r.789695.n4.nabble.com/xyplot-squeezed-together-tp4156661p4156661.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] simplest pgfSweave example results in error

2011-09-29 Thread syrvn
Hello,

since 3 days now I try to get pgfSweave running using Eclipse + StatET.

I created a super simple .Rnw file which can be viewed here:

http://www.text-upload.com/read.php?id=147992&c=6441045 test.Rnw 

When I use sweave it works perfectly fine but when I use pgfSweave I get an
error.
The R output can be viewed here:

http://www.text-upload.com/read.php?id=147995&c=3804886 R output 

the output of the test.tex file can be viewed here:

http://www.text-upload.com/read.php?id=147997&c=7898288 test.tex 

I have no clue at all why it doesn't work. For sweating I use the Sweave.sty
which comes with R.
Do I have to use a different file for pgfSweave?

Help is very much appreciated as I totally run out of ideas...

Best,
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/simplest-pgfSweave-example-results-in-error-tp3856628p3856628.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] simplest pgfSweave example results in error

2011-09-29 Thread syrvn
Hi Yihui,

thank you very much for your answer.

Just before I read your reply I deleted my basicTex and installed the full
MacTex on my system.
When I compile my .Rnw file I finally get a compiled PDF file. Nevertheless,
R outputs the following error message:

---
Not regenerating makefile for externalization, if your figures have changed,
remove //test2.makefile and recompile.
Error in tools::texi2dvi(paste(fn, "tex", sep = "."), pdf = pdf, ...) : 
  Running 'texi2dvi' on '/X/test2.tex' failed.
In addition: Warning message:
'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible 
---

It sounds a bit odd to me because in Eclipse I use the function:

Build tex file using the Eclipse/Texclipse configuration:

output format: PDF, build commands: pdflatex

Now I am wondering why R runs texi2dvi at all?

Referring to your answer. If I include or exclude \usepackage{tikz} does not
make a difference.
I get the same error message.


Best regards,
syrvn



--
View this message in context: 
http://r.789695.n4.nabble.com/simplest-pgfSweave-example-results-in-error-tp3856628p3858091.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] simplest pgfSweave example results in error

2011-09-30 Thread syrvn
Hi,

yes, I had a look at pgfSweave package and realised that it uses texi2dvi to
compile the pdf file.

I tried so much last night again that I am not entirely sure whether it is
the same Rnw file or not.

I just deleted everything and created a new R-project including a tiny
example. I also
included sessionInfo(). pgfSweave failed with the same error message:


==
> library(pgfSweave)
> pgfSweave(file = "/Users/XXX/Documents/Eclipse/Sweave_Test/test.Rnw")
Writing to file test.tex
Processing code chunks with options ...
 1 : echo highlight term verbatim
 2 : echo highlight term verbatim
 3 : echo highlight term verbatim tikz sanitize

You can now run (pdf)latex on 'test.tex'
Not regenerating makefile for externalization, if your figures have changed,
remove /Users/XXX/Documents/Eclipse/Sweave_Test/test.makefile and recompile.
Error in tools::texi2dvi(paste(fn, "tex", sep = "."), pdf = pdf, ...) : 
  Running 'texi2dvi' on '/Users/XXX/Documents/Eclipse/Sweave_Test/test.tex'
failed.
In addition: Warning message:
'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible
===

Also pgfSweave did not create any pdf file. I think the reason why I had a
pdf file the last time was that at some point I was running the normal
sweave which runs without any errors.

I then compiled the test.tex file by hand using pdflatex. The pdf was
created without any errors.

I uploaded all files produced by pgfSweave as well as pdflatex here:

http://elxsi.de/~wolfgang/

Hope that helps to track down the cause of the failure...

Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/simplest-pgfSweave-example-results-in-error-tp3856628p3859148.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Understanding the workflow between sweave, R and Latex

2011-09-30 Thread syrvn
Let's say I have written the following tiny .Rnw file:

_
\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{Sweave}

\usepackage{tikz}

\usepackage{pgf}

\begin{document}

<<>>=

sessionInfo()

@

\end{document}
_

I then can go to R and use sweave to translate the .Rnw file into a .tex
file

Once this is done the latex interpreter can be called and because I used

\usepackage{Sweave} Latex knows how to handle the sweave specific code tags.

When I first did this procedure I got the commong error that the Sweave.sty
file could

not be found. I googled and could solve the problem by typing the following
command

into the Mac OS Terminal:

_
mkdir -p ~/Library/texmf/tex/latex

cd ~/Library/texmf/tex/latex

ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave
_

What I don't understand now is how does the latex package
\usepackage{Sweave} know that it

has to look at ~/Library/texmf/tex/latex to find the symbolic link to the
Sweave.sty file?

What happens if I change the following line:

ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave

to

ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave_Link

In the .Rnw file do I have to use then \usepackage{Sweave_Link}?

Best regards,

syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Understanding-the-workflow-between-sweave-R-and-Latex-tp3859612p3859612.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Understanding the workflow between sweave, R and Latex

2011-09-30 Thread syrvn
Hi Duncan,

I use Eclipse and StatET plus TexClipse and Sweave which comes with the
StatET package.
So fore me it is basically one click as well to produce the pdf from the
.Rnw file.

I installed the MacTex live 2011 version on my computer and thought it might
actually be
easy to find out how and where latex searches for packages. But I did not
find the place
where all this is coded...

Best

--
View this message in context: 
http://r.789695.n4.nabble.com/Understanding-the-workflow-between-sweave-R-and-Latex-tp3859612p3859762.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Create web applications to run R scripts

2011-10-01 Thread syrvn
Hello,

is there anything similar to the Rwui package to create web applications to
run R scripts?


Many thanks,
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Create-web-applications-to-run-R-scripts-tp3863457p3863457.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to run Bibtex with pdfLatex in StatEt/MikTex on Windows ?

2011-10-03 Thread syrvn
Hello,

I have exactly the same problem that bibtex is not being called and so the
bibliography is not being processed...

Did you find any solution for that?

Many thanks
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-run-Bibtex-with-pdfLatex-in-StatEt-MikTex-on-Windows-tp2271396p3867625.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to run Bibtex with pdfLatex in StatEt/MikTex on Windows ?

2011-10-03 Thread syrvn
Hi Duncan,

you were right. texi2dvi does latex + bibtex. Unfortunately I cannot get it
running.

When I run texi2dvi(file = "path/to/tex/file", pdf=TRUE, quiet=FALSE) then I
get the following error message:

___
Error in texi2dvi(file = "/Users/XXX/Desktop/test/body.tex", texinputs =
"/Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/tex",  : 
  Running 'texi2dvi' on '/Users/XXX/Desktop/test/body.tex' failed.
Output:
You don't have a working TeX binary (tex) installed anywhere in
your PATH, and texi2dvi cannot proceed without one.  If you want to use
this script, you'll need to install TeX (if you don't have it) or change
your PATH or TEX environment variable (if you do).  See the --help
output for more details.

For information about obtaining TeX, please see http://www.tug.org.  If
you happen to be using Debian, you can get it with this command:
  apt-get install tetex-bin
__


So the output tells us it cannot find a a tex binary file. If I open my
terminal and type in:

/Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/tex

I get the following output:

This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
**

which means the tex binary is there.


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-run-Bibtex-with-pdfLatex-in-StatEt-MikTex-on-Windows-tp2271396p3868063.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to run Bibtex with pdfLatex in StatEt/MikTex on Windows ?

2011-10-03 Thread syrvn
I am a bit confused...

I wrote a little shell script called tex2pdf which just calls: texi2pdf
body.tex and when I execute it
in a terminal it runs smoothly. If I type into R: system("/Path/to/tex2pdf")
I get the same error message:


You don't have a working TeX binary (tex) installed anywhere in
your PATH, and texi2dvi cannot proceed without one.  If you want to use
this script, you'll need to install TeX (if you don't have it) or change
your PATH or TEX environment variable (if you do).  See the --help
output for more details.

For information about obtaining TeX, please see http://www.tug.org.  If
you happen to be using Debian, you can get it with this command:
  apt-get install tetex-bin


How can this happen? I originally thought it's a problem with the texi2dvi
function in R but it seems to be something else...

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-run-Bibtex-with-pdfLatex-in-StatEt-MikTex-on-Windows-tp2271396p3868123.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to run Bibtex with pdfLatex in StatEt/MikTex on Windows ?

2011-10-03 Thread syrvn
Hi,

I know now why it did not work. See here:

http://www.mail-archive.com/r-help@r-project.org/msg19682.html

I started R via the terminal with open -a R and then called the script again
as well as the texi2dvi function.
Both worked. The problem now is I use R within Eclipse and I don't know how
to start R in that way so that
the paths are set correct.


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-run-Bibtex-with-pdfLatex-in-StatEt-MikTex-on-Windows-tp2271396p3868226.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] texi2dvi problem when compiling incorrect Latex code

2011-10-04 Thread syrvn
Hello,

I am working on a big R project using Eclipse/StatET/Texlipse. I'd like to
write a Latex document within that project but DO NOT want to Sweave it.
It's pure Latex. Via the external tools configurations I set up 2 different
versions to ensure that my latex document is processed correctly.

Version 1 (System Call):
library(tools)
setwd("${container_loc}")
file = "${resource_loc:${source_file_path}}"
try(system(paste("texi2pdf", shQuote(file)), intern=TRUE))


Version 2 (R Call):
library(tools)
setwd("${container_loc}")
texi2dvi(file = "${resource_loc:${source_file_path}}", pdf = TRUE, quiet =
FALSE)


Both versions work well as long as there is no error in my latex code. As
soon as there is an error
the process of texi2pdf / texi2dvi is not finished as the programme waits
for user input (mostly just press "enter" key). The problem is that R
outputs the output only after the whole programme finished so I always end
up having to kill my R console.

Is there any workaround for that?

Syrvn



--
View this message in context: 
http://r.789695.n4.nabble.com/texi2dvi-problem-when-compiling-incorrect-Latex-code-tp3870827p3870827.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] texi2dvi problem when compiling incorrect Latex code

2011-10-05 Thread syrvn
Hi Ista,

thanks for you reply.

If I understod correctly you run your R within Eclipse but as the Lunch Type
you use Rterm rather than RJ.

I changed my configuration so that R is now lunched as Rterm and NOT as RJ
and I also removed the
quite=FALSE from my configuration. Unfortunately, I still have the same
problem.
To create an error in my latex code I just typed the following: \asdasd in
one of my .tex files.
When I compile my document by hand using the Mac OS X / UNIX terminal I get
the following latex compiling output:

Underfull \hbox (badness 1) in paragraph at lines 4--7

) (../abstract.tex
Underfull \hbox (badness 1) in paragraph at lines 1--12

../abstract.tex:15: Undefined control sequence.
l.15  \asdasdas
   
? 

It stops at the question mark and waits for user input. If I press enter it
continues and finally stops with an error which is fine.
The only problem is that if I do it in R the console does not print
everything until the question mark and therefore I cannot just
press enter to let latex finish compiling the code. 

I don't know how to get around this.


Best syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/texi2dvi-problem-when-compiling-incorrect-Latex-code-tp3870827p3873909.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] texi2dvi problem when compiling incorrect Latex code

2011-10-05 Thread syrvn
Hi Ista,

it's weird I don't know why this happens. I tried so many different ways but
now finally
I found a solution. I wrote a little shell script:

pdflatex -halt-on-error body.tex
bibtex body.aux
pdflatex -halt-on-error body.tex
pdflatex -halt-on-error body.tex

which does the job. So my "External Tools Configuration" looks like the
following now:

library(tools)
setwd("${container_loc}")
system("./body.sh", intern=TRUE)

I get the output into R and as soon as there is an error in my latex code it
the compilation/processing stops and the output is still put into the R
console. 
This was possible by adding the -halt-on-error parameter.

Thanks for your support anyway.

Best,
Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/texi2dvi-problem-when-compiling-incorrect-Latex-code-tp3870827p3874594.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Duplicate elements of a vector

2011-10-06 Thread syrvn
Hi,

let's assume I have the following vector a:

1 5 23

How can I use R to duplicate the elements so that my new vector looks like:

1 1 5 5 23 23


Many thanks,
Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Duplicate-elements-of-a-vector-tp3879561p3879561.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Duplicate elements of a vector

2011-10-06 Thread syrvn
thanks guys!

I also found this solution but I think yours is better.

as.vector(rbind(c(1, 5, 23)))


Cheers
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Duplicate-elements-of-a-vector-tp3879561p3879907.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Delete files with system command on Windows 7

2011-10-08 Thread syrvn
Under MacOS I use the following script to process my latex documents:

pdflatex -halt-on-error document.tex
bibtex document.aux
pdflatex -halt-on-error document.tex
pdflatex -halt-on-error document.tex
rm *.aux *.bbl *.blg *.log *.nlo *.thm

How can I realise this under Windows 7?



--
View this message in context: 
http://r.789695.n4.nabble.com/Delete-files-with-system-command-on-Windows-7-tp3885478p3885524.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Delete files with system command on Windows 7

2011-10-08 Thread syrvn
It's all in the context of calling commands via the system command in R.

I just found out that you can run system("pdflatex file") and it works fine.
So R finds the command "pdflatex" but not the "del" command which I can use
to delete files.

I am wondering how I have to call this command to be able for R to find it.

--
View this message in context: 
http://r.789695.n4.nabble.com/Delete-files-with-system-command-on-Windows-7-tp3885478p3885554.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Create order of numbers based on a given vector

2011-10-13 Thread syrvn
Hello!

If I have a vector vec <- c(FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE
FALSE)

I can I create the following order of numbers based on vector vec:

1, 2, 2, 3, 3, 3, 4, 5

Whenever there is a FALSE I increase the number (starting with 1).
Whenever there is a TRUE I set the same number as the previous FALSE has
been assigned to.


I would be happy for any input

Cheers,
Syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Create-order-of-numbers-based-on-a-given-vector-tp3901158p3901158.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Create order of numbers based on a given vector

2011-10-13 Thread syrvn
Hi,

thanks for all of your answers!

Great solutions for my problem :)

Best,
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Create-order-of-numbers-based-on-a-given-vector-tp3901158p3901292.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Remove specific rows in a matrix/data.frame

2011-10-13 Thread syrvn
Hi,


imagine the following matrix/data.frame

Letter Number
a 1
a 1
b 1
b 0
c 0
c 1
d 0
d 0 

If the numbers for two identical letters are also identical then I want to
remove either the first or the
second row of that letter. If for a letter the numbers are 1 and 0 I want to
remove the row with the 0.

That means if the code works I would and up with the following
matrix/data.frame

Letter Number
a 1
b 1
c 1
d 1


Many thanks,
Syrvn


--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-specific-rows-in-a-matrix-data-frame-tp3902149p3902149.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Remove specific rows in a matrix/data.frame

2011-10-13 Thread syrvn
Thanks for your answers! Will check them now :)

Yes, sorry, I was wrong.

Letter Number
d 0
d 0

should be:

Letter Number
d 0

after applying the algorithm!

--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-specific-rows-in-a-matrix-data-frame-tp3902149p3902216.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Remove specific rows in a matrix/data.frame

2011-10-13 Thread syrvn
Hello again,


dtf<-read.table(textConnection("Letter Test Number 
a b 1 
a b 1 
b b 1 
b b 0 
c b 0 
c b 1 
d b 0 
d b 0"),header=T) 
aggregate(Number ~ Letter,data=dtf,max)

how can I adjust this solution that the results also includes "Test"?

I tried:

aggregate(Number ~ Letter,data=dtf,max,by=list("Letter", "Test", "Number"))

But it breaks with the following error message:

Error in aggregate.data.frame(mf[1L], mf[-1L], FUN = FUN, ...) : 
  arguments must have same length





--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-specific-rows-in-a-matrix-data-frame-tp3902149p3902286.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Which function to use: grep, replace, substr etc.?

2011-10-16 Thread syrvn
Hello,

I have a simple question but I don't know which method is best to use for my
problem.

I have the following strings:

str1 <- "My_name_is_peter"
str2 <- "what_is_your_surname_peter"

I would like to apply predefined abbreviations for peter=p and name=n to
both strings
so that the new strings look like the followings:

str1: "My_n_is_p"
str2: "what_is_your_surn_p"

Which method is the best to use for that particular problem?

syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Which-function-to-use-grep-replace-substr-etc-tp3909871p3909871.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Which function to use: grep, replace, substr etc.?

2011-10-16 Thread syrvn
Hi,

thanks for the tip! I do it as follows now but I still have a problem I do
not understand:


abbrvs <- data.frame(c("peter", "name", "male", "female"),
  c("P", "N", "m", "f"))

colnames(abbrvs) <- c("pattern", "replacement")

str <- "My name is peter and I am male"

for(m in 1:nrow(abbrvs)) {
str <- sub(abbrvs$pattern[m], abbrvs$replacement[m], str, 
fixed=TRUE)
print(str)
}


This works perfectly fine as I get: "My N is P and I am m"

However, when I replace male by female then I get the following:  "My N is P
and I am fem"

but I want to have "My N is P and I am f".

Even with the parameter fixed=true I get the same result. Why is that?




--
View this message in context: 
http://r.789695.n4.nabble.com/Which-function-to-use-grep-replace-substr-etc-tp3909871p3909922.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] StatET: Commands are not submitted to the console

2011-11-02 Thread syrvn
Hello!

I am working for quite a while now with the Eclipse/StatET approach and it
always worked very well

until I updated to the 2.0 version of StatET. After the official release the
RJ console did not start. 

After they released another update a couple of days later it worked fine
again.

I did not do any programming for a week now and today I realised that when I
execute the selected lines 

in an R file they are not submitted to the console. I also tried RTerm
instead of RJ but it's the same 

problem. Commands are not submitted to the console.


Did anyone come across the same problem and knows how to fix that. Googling
does not result in any 

useful pages


I am running Mac OS X Lion + Newest version of Eclipse and StatET.
Everything is up to date.


Cheers,

syrvn
 

--
View this message in context: 
http://r.789695.n4.nabble.com/StatET-Commands-are-not-submitted-to-the-console-tp3983662p3983662.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Add number series to data frame

2012-03-06 Thread syrvn
Hi,

Is there a simple way of doing the following in R?


a <- data.frame(name = c(rep("A", 3), rep("B", 5), rep("C", 10)))

> a
   name
1 A
2 A
3 A
4 B
5 B
6 B
7 B
8 B
9 C
10C
11C
12C
13C
14C
15C
16C
17C
18C

Do some fancy R code here:

> a
   name val
1 A  1
2 A  2
3 A  3
4 B  1
5 B  2
6 B  3
7 B  4
8 B  5
9 C  1
10C  2
11C  3
12C  4
13C  5
14C  6
15C  7
16C  8
17C  9
18C  10



--
View this message in context: 
http://r.789695.n4.nabble.com/Add-number-series-to-data-frame-tp4450495p4450495.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Add number series to data frame

2012-03-06 Thread syrvn
Hi Sarah,

thanks a lot for this peace of code.

Is it possible to give the second sequence of "B" in your second example
(data frame b) 
the numbers 6, 7 and 8 instead of 1, 2 and 3 again? In my real data I have
more columns than
only those two and sometimes the are sorted differently so that column name
rather looks like
your second example (data frame b) rather than your first one.

Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Add-number-series-to-data-frame-tp4450495p4450656.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Add number series to data frame

2012-03-07 Thread syrvn
Hi Petr,

that works great. thanks!

I was working my head off on that :)

--
View this message in context: 
http://r.789695.n4.nabble.com/Add-number-series-to-data-frame-tp4450495p4452962.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] 2 sample wilcox.test != kruskal.test

2012-01-10 Thread syrvn
Hello,


I think I am right in saying that a 2 sample wilcox.test is equal to a 2
sample kruskal.test and

a 2 sample t.test is equal to a 2 sample anova. This is also stated in the
?kruskal.test man page:

The Wilcoxon rank sum test (wilcox.test) as the special case for two
samples; lm together with anova for performing one-way location analysis
under normality assumptions; with Student's t test (t.test) as the special
case for two samples.


>From this example it seems like it doesn't but I cannot figure out what I am
doing wrong.


x <- c(10,11,15,8,16,12,20)
y <- c(10,14,18,25,28,30,35)
f <- c(rep("a",7), rep("b",7))
d <- c(x,y)

wilcox.test(x,y)
kruskal.test(x,y)
kruskal.test(x~y)
kruskal.test(f~d)

t.test(x,y)
anova(lm(x~y))
summary(aov(lm(x~y)))


And why does kruskal.test(x~y) differ from kruskal.test(f~d)??


Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/2-sample-wilcox-test-kruskal-test-tp4282888p4282888.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 2 sample wilcox.test != kruskal.test

2012-01-11 Thread syrvn
Hi,

thanks for your answer. Unfortunately I cannot reproduce your results.

In my example the results still differ when I use your approach:

> x <- c(10,11,15,8,16,12,20)
> y <- c(10,14,18,25,28,30,35)
> f <- as.factor(c(rep("a",7), rep("b",7)))
> d <- c(x,y)
> kruskal.test(x,y)

Kruskal-Wallis rank sum test

data:  x and y 
Kruskal-Wallis chi-squared = 6, df = 6, p-value = 0.4232

> kruskal.test(x~y)

Kruskal-Wallis rank sum test

data:  x by y 
Kruskal-Wallis chi-squared = 6, df = 6, p-value = 0.4232

> kruskal.test(d~f)

Kruskal-Wallis rank sum test

data:  d by f 
Kruskal-Wallis chi-squared = 3.6816, df = 1, p-value = 0.05502

> kruskal.test(f~d)

Kruskal-Wallis rank sum test

data:  f by d 
Kruskal-Wallis chi-squared = 11.1429, df = 12, p-value = 0.5167


I know the last kruskal.test(f~d) is not correct as the factor is always
placed as the second bit but I still tried it that way just to be sure...

Cheers


--
View this message in context: 
http://r.789695.n4.nabble.com/2-sample-wilcox-test-kruskal-test-tp4282888p4285003.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 2 sample wilcox.test != kruskal.test

2012-01-11 Thread syrvn
Hi Michael and Mi³ego dnia,

yes right. I get identical results now! thanks a lot!

--
View this message in context: 
http://r.789695.n4.nabble.com/2-sample-wilcox-test-kruskal-test-tp4282888p4285325.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Detect numerical series

2012-02-11 Thread syrvn
Hello,

I am struggling with detecting successive digits in a numerical series
vector.

Here is an example:

vec <- c(1, 15, 26, 29, 30, 31, 37, 40, 41)

I want to be able to detect 29, 30, 31 and 40, 41.

Then, I would like to delete the successive digits from the vector.

1, 15, 26, 29, 37, 40


Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/Detect-numerical-series-tp4379088p4379088.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Detect numerical series

2012-02-11 Thread syrvn
That's great code. Thanks a lot!

--
View this message in context: 
http://r.789695.n4.nabble.com/Detect-numerical-series-tp4379088p4379133.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Derive pattern from vector

2012-02-11 Thread syrvn
Hello,

consider the following vector 'chars':


chars <- c(A, B, C, C, D, E, E, E, F, F, F)


I need to convert 'chars' into the following pattern:


1, 2, 3, 3, 4, 5, 5, 5, 6, 7, 8

As soon as there are duplicates they get the same number otherwise it's
increasing numbers.

However, for the char 'F' it should be always increasing numbers. Is that
possible in R?


I used the following code:


chars <- c('A', 'B', 'C', 'C', 'D', 'E', 'E', 'E', 'F', 'F', 'F')

chars_dup <- duplicated(chars)

cumsum(!chars_dup)

 [1] 1 2 3 3 4 5 5 5 6 6 6


But I do not know how to treat 'F' in the way described above.


Regards



--
View this message in context: 
http://r.789695.n4.nabble.com/Derive-pattern-from-vector-tp4379312p4379312.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derive pattern from vector

2012-02-11 Thread syrvn
fantastic. Thanks for that chunk of code. Works great! :)

--
View this message in context: 
http://r.789695.n4.nabble.com/Derive-pattern-from-vector-tp4379312p4379402.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Vector manipulation

2012-02-12 Thread syrvn
Hello,


I am stuck with the following problem. Consider the vector:

vec <- c(2,4,6,9,10)

I now want to use R to manipulate the vector as follows:

[1] 2, 4, 2, 6, 2, 9, 2, 10

In words, the first element of the vector should be placed in front of each
following number.

Which R commands do I need to achieve that?


Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381586.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Vector manipulation

2012-02-12 Thread syrvn
Great Dimitris. It helps indeed! Thanks a lot!

--
View this message in context: 
http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381614.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Deleting rows and columns containing NA's and "" only

2012-02-13 Thread syrvn
Hello,

I use read.xls from the gdata package to read in xlsx files. Sometimes these
data.frames contain NA columns
and rows only. I know how to get rid of those ones but here is the R output
of a test data set read in with read.xls

> t1
 A  B X D   X.1 X.2
1 test  1 NANA
2asdNA  asdasdNA
3  NA  asdasdNA
4  NANA NA

t1[1,2], t1[4,5] and t1[4,6] are NA in text form in the excel sheet. I don't
understand why in the first column it is  while in the last two is not.
I basically want to get rid of column 5 and 6 and row 4 as they do not
contain any relevant information. If i do a is.na.data.frame(t1):

> is.na.data.frame(t1)
 A BX D  X.1   X.2
[1,] FALSE FALSE TRUE FALSE TRUE FALSE
[2,]  TRUE FALSE TRUE FALSE TRUE FALSE
[3,] FALSE FALSE TRUE FALSE TRUE FALSE
[4,] FALSE FALSE TRUE FALSE TRUE FALSE

does not give me the result I hoped to get.

It seems that  and NA are treated as NA but in t1[4,6] it is treated as
FALSE because if I do

> as.character(t1[4,6])
[1] "NA "

one can see that there is a whitespace after NA which is, however, not in
the excel sheet for sure.

I do not know how to deal with that...

Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/Deleting-rows-and-columns-containing-NA-s-and-only-tp4384173p4384173.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Deleting rows and columns containing NA's and "" only

2012-02-13 Thread syrvn
Hi,

thanks for you suggestion.

I finally solved it in a different way using apply and is.na for TRUE NA's
and if(as.character(x) == "NA") etc.

However, I just spotted that read.xls seems to have problems reading in
special characters such as < or >.

Is there any workaround for that?

--
View this message in context: 
http://r.789695.n4.nabble.com/Deleting-rows-and-columns-containing-NA-s-and-only-tp4384173p4384663.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Deleting rows and columns containing NA's and "" only

2012-02-13 Thread syrvn
Hi David,

I am using read.xls not read.table.

--
View this message in context: 
http://r.789695.n4.nabble.com/Deleting-rows-and-columns-containing-NA-s-and-only-tp4384173p4384866.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] extract subset of data.frame

2012-02-23 Thread syrvn
Hello,


consider the following data.frame df and vector v

df <- data.frame(group = c("A","B","C","D"), value = c(1,2,3,4))
v <- c(2,3)

How can I return a sub data.frame which has only the rows left where value
matches v

df:

group value
B 2
C 3


Cheers

--
View this message in context: 
http://r.789695.n4.nabble.com/extract-subset-of-data-frame-tp4414251p4414251.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] gsub to manipulate characters

2012-02-24 Thread syrvn
Hello,

from a vector of strings I want to delete everything after the _

> v <- c("AAA_BB", "FF_MM")
> gsub("_*", "", v)
[1] "AAABB" "FFMM" 


but should be
[1] "AAA" "FF" 


Why does * not work? Even perl=TRUE does not give me the right result

Man thanks!


--
View this message in context: 
http://r.789695.n4.nabble.com/gsub-to-manipulate-characters-tp4416939p4416939.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] gsub to manipulate characters

2012-02-24 Thread syrvn
cool that works! thanks a lot :)

--
View this message in context: 
http://r.789695.n4.nabble.com/gsub-to-manipulate-characters-tp4416939p4416961.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] select rows by criteria

2012-03-01 Thread syrvn
Hello,

I am stuck with selecting the right rows from a data frame. I think the
problem is rather how to select them
then how to implement the R code.

Consider the following data frame:

df <- data.frame(ID = c(1,2,3,4,5,6,7,8,9,10), value =
c(34,12,23,25,34,42,48,29,30,27))

What I want to achieve is to select 7 rows (values) so that the mean value
of those rows are closest
to the value of 35 and the remaining 3 rows (values) are closest to 45.
However, each value is only
allowed to be sampled once!

Any ideas, how to achieve that?


Cheers






--
View this message in context: 
http://r.789695.n4.nabble.com/select-rows-by-criteria-tp4434812p4434812.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Output of system() not shown in if

2012-05-11 Thread syrvn
Hello,

I am using system(...) to invoke some unix commands. Everything is working
fine and the output of the programme
is returned to the R console. However, as soon as I put the system(...) call
into an if-clause the output is no longer
shown in the R console. Is there any workaround for that problem?

Cheers
syrvn

--
View this message in context: 
http://r.789695.n4.nabble.com/Output-of-system-not-shown-in-if-tp4626383.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Output of system() not shown in if

2012-05-11 Thread syrvn
Ah I managed to do it by simple adding a print() statement around the system
call... easy :)

--
View this message in context: 
http://r.789695.n4.nabble.com/Output-of-system-not-shown-in-if-tp4626383p4626461.html
Sent from the R help mailing list archive at Nabble.com.

__
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/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.