[R] Help

2024-02-20 Thread Lisa Hupfer via R-help
I am writing my master thesis in which I compared two cultures . So for my 
statistics I need to compare Age,Sex,Culture as well as have a look at the 
tasks scores .

Anyone familiar with this ?
I’d love to share my script so you guide me where I did wrong . 

Regards 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Calculating a P for trend

2018-11-29 Thread Lisa van der Burgh
Hi all,



I have a question about calculating a P for trend on my data. Let�s give an 
example that is similar to my own situation first: I have a continuous outcome, 
namely BMI. I want to investigate the effect of a specific medicine, let�s call 
it MedA on BMI. MedA is a variable that is categorical, coded as yes/no use of 
the medication. A also have the duration of use of the MedA, divided in three 
categories: use of MedA for 1-30 days, use of MedA for 31-60 days and use of 
MedA for 61-120 days (categories based on literature). I have performed a 
linear regression analyses and it seems like there is some kind of trend: the 
longer the use of MedA, the higher the BMI will be (the betas increase with 
time of use).  So an exemplary table:






Outcome: BMI


Beta


MedA use duration





  Use for 1-30 days


0.060


  Use for 31-60 days


0.074


  Use for 61-120 da


0.081




So, I have created three variables and I modelled them in Rstudio (on a 
multiple imputed dataset using MICE):



mod1  <- with(imp, lm(BMI ~ MedA_1to30))

pool_ mod1  <- pool(mod1)

summary(pool_ mod1, conf.int = TRUE)



mod2  <- with(imp, lm(BMI ~ MedA_31to60))

pool_ mod2  <- pool(mod2)

summary(pool_ mod2, conf.int = TRUE)



mod3  <- with(imp, lm(BMI ~ MedA_61to120))

pool_ mod3  <- pool(mod3)

summary(pool_ mod3, conf.int = TRUE)



Now that I have done this, I want to calculate a p for trend. I do know what a 
P for trend measures, but I do not know how to calculate this myself. I read 
something about the partial.cor.trend.test() function from the trend package, 
but I do not know what I should fill in. Because I can only fill in an x and y, 
but I have three time variables. So I do not know how to solve this. Can 
somebody help me?



If more information is necessary, I am happy to give it to you!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Question Mixed-Design Anova in R

2018-11-23 Thread Lisa van der Burgh
Dear John and Peter,


Thank you both for your answers. I am going to try the solutions you gave me!


Thanks again,

Lisa


From: Fox, John 
Sent: 23 November 2018 16:54:49
To: Lisa van der Burgh
Cc: r-help@R-project.org; peter dalgaard
Subject: RE: [R] Question Mixed-Design Anova in R

Dear Lisa,

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of peter
> dalgaard
> Sent: Friday, November 23, 2018 10:16 AM
> To: Lisa van der Burgh <40760...@student.eur.nl>
> Cc: r-help@R-project.org
> Subject: Re: [R] Question Mixed-Design Anova in R
>
> You seem to be bringing in a ton of stuff without looking at features in base
> R...
>
> Check
>
> help(mauchly.test)
> help(anova.mlm)
>
> and examples therein. There are also options in the "car" package.

With respect to the latter, see in particular the O'Brien-Kaiser example in 
?Anova.

I hope this helps,
 John

-
John Fox
Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
Web: https://socialsciences.mcmaster.ca/jfox/


>
> -pd
>
> > On 23 Nov 2018, at 11:43 , Lisa van der Burgh <40760...@student.eur.nl>
> wrote:
> >
> > Hi Everyone,
> >
> >
> >
> > I have a question about Mixed-Design Anova in R. I want to obtain Mauchly s
> test of Sphericity and the Greenhouse-Geisser correction. I have managed to
> do it in SPSS:
> >
> >
> >
> > GLM Measure1 Measure2 Measure3 Measure4 Measure5 Measure6 BY
> Grouping
> >
> >  /WSFACTOR=Measure 6 Polynomial
> >
> >  /METHOD=SSTYPE(3)
> >
> >  /PLOT=PROFILE(Measure*Grouping)
> >
> >  /CRITERIA=ALPHA(.05)
> >
> >  /WSDESIGN=Measure
> >
> >  /DESIGN=Grouping.
> >
> >
> >
> > I have tried to replicate this in R:
> >
> > library("dplyr")
> >
> > library("tidyr")
> >
> > library("ggplot2")
> >
> > library("ez")
> >
> >
> >
> > PatientID <- c(1:10)
> >
> > Measure1 <- c(3,5,7,4,NA,7,4,4,7,2)
> >
> > Measure2 <- c(1,2,5,6,8,9,5,NA,6,7)
> >
> > Measure3 <- c(3,3,5,7,NA,4,5,7,8,1)
> >
> > Measure4 <- c(1,2,5,NA,3,NA,6,7,3,6)
> >
> > Measure5 <- c(2,3,NA,8,3,5,6,3,6,4)
> >
> > Measure6 <- c(1,2,4,6,8,3,5,6,NA,4)
> >
> > Grouping <- c(1,0,1,1,1,0,0,1,1,0)
> >
> > dataframe <- data.frame(PatientID, Measure1, Measure2, Measure3,
> > Measure4, Measure5, Measure6, Grouping)
> >
> > dataframe$Grouping <- as.factor(dataframe$Grouping)
> >
> > dataframe
> >
> >
> >
> > ezPrecis(dataframe)
> >
> > glimpse(dataframe)
> >
> >
> >
> > dataframe %>% count(PatientID)
> >
> >
> >
> > dataframe %>% count(PatientID, Grouping, Measure1, Measure2,
> Measure3,
> > Measure4, Measure5, Measure6) %>%
> >
> >  filter(PatientID %in% c(1:243)) %>%
> >
> >  print(n = 10)
> >
> >
> >
> > # So, we have a mixed design with one between factor (Grouping) and 6
> within factors (Measure 1 to 6).
> >
> >
> >
> > dat_means <- dataframe %>%
> >
> >  group_by(Grouping, Measure1, Measure2, Measure3, Measure4,
> Measure5,
> > Measure6) %>%
> >
> >  summarise(mRT = mean(c(Measure1, Measure2, Measure3, Measure4,
> > Measure5, Measure6))) %>% ungroup()
> >
> > View(dat_means)
> >
> >
> >
> > ggplot(dat_means, aes(c(Measure1, Measure2, Measure3, Measure4,
> > Measure5, Measure6), mRT, colour = Grouping)) +
> >
> >  geom_line(aes(group = Grouping)) +
> >
> >  geom_point(aes(shape = Grouping), size = 3) +
> >
> >  facet_wrap(~group)
> >
> >
> >
> > ANOVA <- ezANOVA(dat, x, PatientID, within = .( c(Measure1, Measure2,
> > Measure3, Measure4, Measure5, Measure6)),
> >
> >between = Grouping, type = 3)
> >
> >
> >
> > print(ANOVA)
> >
> >
> >
> >
> >
> > However, this does not work. I know I am probably doing it completely
> wrong, but I do not know how to solve it. Besides that, I do not know what to
> fill in at the  x .
> >
> > Can somebody help me?
> >
> >
> >
> > Thank you in advance.
> >
> > Lisa
> >
> >
> >  [[alternative HTML version deleted]]
> >
> > __

[R] Question Mixed-Design Anova in R

2018-11-23 Thread Lisa van der Burgh
Hi Everyone,



I have a question about Mixed-Design Anova in R. I want to obtain Mauchly�s 
test of Sphericity and the Greenhouse-Geisser correction. I have managed to do 
it in SPSS:



GLM Measure1 Measure2 Measure3 Measure4 Measure5 Measure6 BY Grouping

  /WSFACTOR=Measure 6 Polynomial

  /METHOD=SSTYPE(3)

  /PLOT=PROFILE(Measure*Grouping)

  /CRITERIA=ALPHA(.05)

  /WSDESIGN=Measure

  /DESIGN=Grouping.



I have tried to replicate this in R:

library("dplyr")

library("tidyr")

library("ggplot2")

library("ez")



PatientID <- c(1:10)

Measure1 <- c(3,5,7,4,NA,7,4,4,7,2)

Measure2 <- c(1,2,5,6,8,9,5,NA,6,7)

Measure3 <- c(3,3,5,7,NA,4,5,7,8,1)

Measure4 <- c(1,2,5,NA,3,NA,6,7,3,6)

Measure5 <- c(2,3,NA,8,3,5,6,3,6,4)

Measure6 <- c(1,2,4,6,8,3,5,6,NA,4)

Grouping <- c(1,0,1,1,1,0,0,1,1,0)

dataframe <- data.frame(PatientID, Measure1, Measure2, Measure3, Measure4, 
Measure5, Measure6, Grouping)

dataframe$Grouping <- as.factor(dataframe$Grouping)

dataframe



ezPrecis(dataframe)

glimpse(dataframe)



dataframe %>% count(PatientID)



dataframe %>% count(PatientID, Grouping, Measure1, Measure2, Measure3, 
Measure4, Measure5, Measure6) %>%

  filter(PatientID %in% c(1:243)) %>%

  print(n = 10)



# So, we have a mixed design with one between factor (Grouping) and 6 within 
factors (Measure 1 to 6).



dat_means <- dataframe %>%

  group_by(Grouping, Measure1, Measure2, Measure3, Measure4, Measure5, 
Measure6) %>%

  summarise(mRT = mean(c(Measure1, Measure2, Measure3, Measure4, Measure5, 
Measure6))) %>% ungroup()

View(dat_means)



ggplot(dat_means, aes(c(Measure1, Measure2, Measure3, Measure4, Measure5, 
Measure6), mRT, colour = Grouping)) +

  geom_line(aes(group = Grouping)) +

  geom_point(aes(shape = Grouping), size = 3) +

  facet_wrap(~group)



ANOVA <- ezANOVA(dat, x, PatientID, within = .( c(Measure1, Measure2, Measure3, 
Measure4, Measure5, Measure6)),

between = Grouping, type = 3)



print(ANOVA)





However, this does not work. I know I am probably doing it completely wrong, 
but I do not know how to solve it. Besides that, I do not know what to fill in 
at the �x�.

Can somebody help me?



Thank you in advance.

Lisa


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 plotting recurrence matrix

2018-10-04 Thread Lisa Handke
Hi everyone,

 

I am trying to plot a recurrence matrix (package: nonlinearTseries).

 

This is my command, which gives the plot as found in the attached image
(example 1):

 

Team1 <- read.delim("Team1.txt", header =TRUE)

Team1_plot <- rqa(time.series = Team1$Kat5, embedding.dim = 1, time.lag = 1,

radius = 0.1,lmin =2, vmin =2, distanceToBorder = 2, save.RM
= TRUE,

do.plot = FALSE )

 

RP <- Team1_plot$recurrence.matrix

image (RP)

 

My first problem

 

1.  I cannot change the labeling of the axis limits

 

While this command helps rotate the datapoints WITHIN the plot as desired
(example 2):

 

image(t(RP[,ncol(RP):1])) # rotate matrix by 90° and plot

 

the labeling of the axes is still wrong (the y-axis still starts with 223).
Adding parameters such as ylim or ymax has not helped.

 

2.  I am trying to convert it into a colour-coded image. I have
categories ranging from numbers 1 to 5 (as well as random unique larger
numbers referring to nonrecurrent values). With some help, I have managed to
assign my numeric values in my data to colours using this function:

 

RP2 <- as.matrix(RP)*1

TS <- Team1$Kat5

for (i in seq(1,dim(RP2)[1])) {

  for (j in seq(1,dim(RP2)[1])) {

if (RP2[i,j] == 1 & TS[i] < 6) { # test if recurrence is present in RP
AND corresponding value in the time-series is < 6, in which case that
Recurrent is coded according to the value in the time series

  RP2[i,j] <- TS[i]

} else if (RP2[i,j] == 1 & TS[i] < 6) { # if the above is not the case,
test if recurrence is present in RP AND corresponding value in the
time-series is > 5, in which case that recurrence is deleted from the RP

  RP2[i,j] <- 0

}

  }

}

 

image.scale(RP2, zlim=c(1,5),col= c("yellow", "red", "blue", "green",
"orange")

 

My problem is that the image I receive from doing this (see attachment) is
scaled from 0 to 1 and I seem to be incapable of understanding why this is
and how to change it. Once again, I have tried using y and x lim as well as
max functions, but have not managed to attain any results.

 

I realize these are amateur questions but I have been struggling with this
for quite some time and would really appreciate any help I can get.

 

Thanks and best regards,

Lisa

 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Recoding variables in R

2018-05-23 Thread Lisa van der Burgh
Thank you all for your help, it worked!

Op 23 mei 2018 om 19:27 heeft marta azores 
mailto:martazo...@gmail.com>> het volgende geschreven:

Try that code

NewDF<-DF[!DF$Anxiolytics==1,]

2018-05-23 10:14 GMT+00:00 Lisa van der Burgh 
mailto:lisavdbu...@hotmail.com>>:
Hi all,


I have a very general question and I think for you maybe very easy, but I am 
not able to solve it.

I have a dataset and that dataset contains the variable Anxiolytics. This 
variable is coded as 0, 1, 2. The variable looks as follows:


> summary(DF$Anxiolytics)
   01 2   NA's
1102   0 20440


You can see that the variable is coded as 0, 1, 2, but group 1 is 'empty'. So I 
want to remove this group, such that I get:

> summary(DF$Anxiolytics)
   0  2   NA's
1102 20  440

And then I want to recode the variable in a way that 2 becomes 1, such as:

> summary(DF$Anxiolytics)
   0  1   NA's
1102 20  440

Can you help me with the code for doing this?

Thank you in advance!
Best, Lisa


[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
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.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Recoding variables in R

2018-05-23 Thread Lisa van der Burgh
Hi all,


I have a very general question and I think for you maybe very easy, but I am 
not able to solve it.

I have a dataset and that dataset contains the variable Anxiolytics. This 
variable is coded as 0, 1, 2. The variable looks as follows:


> summary(DF$Anxiolytics)
   01 2   NA's
1102   0 20440


You can see that the variable is coded as 0, 1, 2, but group 1 is 'empty'. So I 
want to remove this group, such that I get:

> summary(DF$Anxiolytics)
   0  2   NA's
1102 20  440

And then I want to recode the variable in a way that 2 becomes 1, such as:

> summary(DF$Anxiolytics)
   0  1   NA's
1102 20  440

Can you help me with the code for doing this?

Thank you in advance!
Best, Lisa


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-Studio+Commander

2016-09-01 Thread Lisa Ducati HH
> Hello,
> 
> I would like to Know if i can install r on my iPad Air 2? Is this possible?
> 
> Regards Lisa-Marie Kindler

Von meinem iPhone gesendet
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 in data.farme--duplicate row.names error

2016-05-20 Thread Rees, Lisa Marie (MU-Student)
Don,

Thank you for your helpful response.  At this point, I do believe it is a 
package error and I have contacted the developer.

Thanks,
Lisa

-Original Message-
From: MacQueen, Don [mailto:macque...@llnl.gov] 
Sent: Thursday, May 19, 2016 4:27 PM
To: Rees, Lisa Marie (MU-Student); r-help@r-project.org
Subject: Re: [R] error in data.farme--duplicate row.names error

You will probably have to contact the maintainer of the package, since the 
error appears to be generated inside the package's function.

Immediately after the error, type
  traceback()
The results might give you a clue. Or they might not!

There might be some requirements on the second argument of the
DefineGame() function. Check the help page for DefineGame and see if the object 
you supplied, value, meets those requirements.

-Don

--
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/19/16, 7:16 AM, "R-help on behalf of Rees, Lisa Marie (MU-Student)"
 wrote:

>I'm using the "GameTheory" package--- DefineGame(14,values) and values 
>is equal to 16,383 observations.
>
>I keep getting the following error-
>[Error in data.frame(rep(0, 2^n - 1), row.names = Bmat) :
>  duplicate row.names: 1, 11, 111, 12, 112, 1112, 2, 13, 113, 1113, 
>3, 1213, 11213, 111213, 213, 14, 114, 1114, 4, 1214, 11214, 
>111214, 214, 1314, 11314, 111314, 314, 121314, 1121314, 
>11121314, 21314]
>
>What can I do to fix this issue?  I would greatly appreciate any help.
>
>Thank you.
>
>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 in data.farme--duplicate row.names error

2016-05-19 Thread Rees, Lisa Marie (MU-Student)
Michael,

Thanks for your response.  

I tried table(table(Bmat)) and it gave me the following error:
[  Error in table(Bmat) : object 'Bmat' not found]

FYI--
"values" contains 16,383 observations ranging from 0 to less than 1.

Lisa



-Original Message-
From: Michael Dewey [mailto:li...@dewey.myzen.co.uk] 
Sent: Thursday, May 19, 2016 11:05 AM
To: Rees, Lisa Marie (MU-Student); r-help@r-project.org
Subject: Re: [R] error in data.farme--duplicate row.names error

Dear Lisa

What does Bmat contain? Perhaps try table(table(Bmat)) and see if any entries 
are greater than unity.

On 19/05/2016 15:16, Rees, Lisa Marie (MU-Student) wrote:
> I'm using the "GameTheory" package--- DefineGame(14,values) and values is 
> equal to 16,383 observations.
>
> I keep getting the following error-
> [Error in data.frame(rep(0, 2^n - 1), row.names = Bmat) :
>   duplicate row.names: 1, 11, 111, 12, 112, 1112, 2, 13, 113, 
> 1113, 3, 1213, 11213, 111213, 213, 14, 114, 1114, 4, 1214, 
> 11214, 111214, 214, 1314, 11314, 111314, 314, 121314, 1121314, 
> 11121314, 21314]
>
> What can I do to fix this issue?  I would greatly appreciate any help.
>
> Thank you.
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
> 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.
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 in data.farme--duplicate row.names error

2016-05-19 Thread Rees, Lisa Marie (MU-Student)
I'm using the "GameTheory" package--- DefineGame(14,values) and values is equal 
to 16,383 observations.

I keep getting the following error-
[Error in data.frame(rep(0, 2^n - 1), row.names = Bmat) :
  duplicate row.names: 1, 11, 111, 12, 112, 1112, 2, 13, 113, 1113, 3, 
1213, 11213, 111213, 213, 14, 114, 1114, 4, 1214, 11214, 111214, 
214, 1314, 11314, 111314, 314, 121314, 1121314, 11121314, 21314]

What can I do to fix this issue?  I would greatly appreciate any help.

Thank you.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 with RUSBoost

2015-04-14 Thread Lisa Gandy
I am considering using RUSBoost (https://github.com/SteveOhh/RUSBoost) and
was wondering if anyone has used this package, and could give me some
insight and help.  The help would be on more of the machine learning side,
I just have a few questions about implementation.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Tomorrow Webinar: Enter a KDD Cup or Kaggle Competition without being an expert!

2015-01-12 Thread Lisa Solomon
Webinar: Enter a KDD Cup or Kaggle Competition, You don't need to be an expert!

Tomorrow, January 13, 2015 from 10am-11am PDT

* If inconvenient time, please register and we will send you a 
recording.

Click to Register: http://hubs.ly/y0q_jf0

Abstract:

* Quickly achieve a place in the top 5: We will show you how Salford's 
TreeNet gradient boosting can be used for the 2009 KDD Cup competition to 
quickly achieve a place in the top 5.

* Takeaway: At the end of this webinar, our goal is that you will be 
able to build a TreeNet model that can bring you within decimal places of a 
winning solution.

* Starting Point for Kaggle, KDD and other data science competitions: 
Use this information as a starting point for Kaggle competitions and other KDD 
Cup competitions.

* 30-day software access: All attendees receive 30-day access to 
TreeNet gradient boosting, and other Salford Predictive Modeler technology.

Click to Register: http://hubs.ly/y0q_jf0

















[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 with Caret

2015-01-09 Thread Lisa Gandy
*My code is below:*

library('RMySQL')
library('DMwR')
library('tm')
library('Snowball')
library('SnowballC')

con <- dbConnect(MySQL(), user="root", password="stuff0645",
dbname="TwitterCelebs", host="localhost")

rt_outlier <- dbGetQuery(con, "SELECT *,tweet_text from
outlier_info,tweets where outlier_info.tweet_id=tweets.tweet_id limit
500")

rt_not_outlier <- dbGetQuery(con,"Select *, tweet_text from
not_outlier_info,tweets where
not_outlier_info.tweet_id=tweets.tweet_id limit 500");

dbDisconnect(con)

all_tweets = rbind(rt_outlier,rt_not_outlier)
all_tweets[,"tweet_text"] <- iconv(all_tweets[,"tweet_text"], to = "utf-8")

corpus = Corpus(VectorSource(all_tweets[,"tweet_text"]))
corpus = tm_map(corpus,removePunctuation)
corpus <- tm_map(corpus, tolower)
corpus <- tm_map(corpus, stemDocument)
corpus <- tm_map(corpus,removeWords,stopwords("english"))
corpus <- tm_map(corpus,stripWhitespace)
corpus <- tm_map(corpus,removeNumbers)
mydata.dtm <- TermDocumentMatrix(corpus,control=list(weighting=weightTfIdf,
minWordLength=2, findFreqTerms=5))


dataframe <- as.data.frame(inspect(mydata.dtm))

d=as.data.frame(t(dataframe))

classData = c(rep(0,500),rep(1,500))
classData = as.factor(classData)

library('caret')
ctrl = trainControl(method = "repeatedcv", repeats = 3,)
set.seed(2)
mymodel <- train(d, classData,trControl=ctrl,method="J48",model=FALSE)

Basically, what is happening here is that I keep getting the error and
warnings:

Error in train.default(d, classData, method = "J48", model = FALSE) :
  final tuning parameters could not be determined
In addition: Warning messages:1: In train.default(d, classData, method
= "J48", model = FALSE) :
  Models using Weka will not work with parallel processing with
multicore/doMC2: In nominalTrainWorkflow(x = x, y = y, wts = weights,
info = trainInfo,  :
  There were missing values in resampled performance measures.3: In
train.default(d, classData, method = "J48", model = FALSE) :
  missing values found in aggregated results

What am I doing wrong? Also note I'm using model=FALSE in training to
conserve memory, as this has been a problem


-- 
Lisa Gandy, PhD
Assistant Professor
Central Michigan University
Computer Science Dept
Pearce 119
989-774-3696
gand...@cmich.edu
https://intlab.cps.cmich.edu/lgandy/

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Chicago, Data Mining Training (Hands-On, $35), Chicago, May 23rd

2014-05-15 Thread Lisa Solomon
Join us for a hands-on data mining training in Chicago, IL on May 23, 2014:

* Cost: $35

* Registration: http://hub.am/1ftOoR0

* Learn data mining quickly using Salford Systems' Commercial Data 
Mining Software (No programming skills needed).

Agenda:

8:30am-9:00am Breakfast (provided)

* 9:00am-12:00pm

* Introduction to Data Mining

* Case Study Examples
12:00pm-1:00pm Lunch (provided)

* 1:00pm-3:00pm

* Build and Score Predictive Models

* Optimization for Predictive Accuracy

* Create Reports: Translating insights into actionable results

Why you should attend:

* Get step-by-step instruction for the most popular data mining 
techniques used in predictive analytics including decision trees, 
classification, segmentation, non-linear regression, ensemble methods, boosted 
decision trees, etc.

* Walk away with everything you will need to start your own data mining 
projects.

* Be ready to apply your new data mining knowledge at your organization 
to create immediate value.

* All attendees receive 90-day access to the SPM Salford Predictive 
Modeler technology.

We hope to see you in Chicago!


[[alternative HTML version deleted]]

__
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] match from a data.frame in dependence of an ID

2014-03-28 Thread Lisa S
Try xtabs()
>> df2 = data.frame(ID = c(10,10,10,10,10,11,11,12),Group =
c(1,2,3,4,5,3,4,4),Value = c(10,20,30,40,50,60,70,80))
>> xtabs(df2$Value~df2$ID + df2$Group)

I think this is exactly what you want.


On Fri, Mar 28, 2014 at 4:51 PM, Mat  wrote:

> Hello togehter,
>
> i have a litte problem. I have an output data.frame which look like this
> one:
> ID
> 1  10
> 2  11
> 3  12
>
> Now I have another data.frame with more than one line for each ID:
> IDGroupValue
> 1  10110
> 2  10220
> 3  10330
> 4  10440
> 5  10550
> 6  11360
> 7  11470
> 8  12480
>
> How can i match these two data.frame for the following result:
>
> ID1 2 3 4 5
> 1  1010   2030   40   50
> 2  11 60   70
> 3  12   80
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/match-from-a-data-frame-in-dependence-of-an-ID-tp4687745.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.
>

[[alternative HTML version deleted]]

__
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] Merge two vectors into one

2014-03-24 Thread Lisa S
He wants a[1] b[1] a[2] b[2] a[3] b[3]
I think you can do:
x =  as.vector(rbind(a, b))



On Mon, Mar 24, 2014 at 2:39 PM, Frans Marcelissen <
fransiepansiekever...@gmail.com> wrote:

> Why not simply
>
> > a<-1:3
> > b<-4:5
> > c(a,b)
> [1] 1 2 3 4 5
>
>
> 2014-03-22 23:22 GMT+01:00 Tham Tran :
>
> > Dear R users,
> >
> > Given two vectors x and y
> > a=1 2 3
> > b=4 5 6
> >
> > i want to combine them into a single vector z as 1 4 2 5 3 6
> >
> > Thanks for your help
> >
> > Tham
> >
> >
> >
> > --
> > View this message in context:
> > http://r.789695.n4.nabble.com/Merge-two-vectors-into-one-tp4687361.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.
> >
>
> [[alternative HTML version deleted]]
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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] Import multiple files into R

2014-03-20 Thread Lisa S
But I don't think a list can contain that much data - we dont know how big
each txt file is.

So I'd like to do:
city.set <- c('Asheville','Charlotte')
month.set <- c('Dec', 'Jan', 'Feb')

comb.set <- expand.grid(city.set,month.set)
comb.set$filename = paste(comb.set[,1],comb.set[,2],sep = '_')

for i in 1:nrow(comb.set){
db <- read.table(comb.set$filename[i] + '.txt',header = TRUE)
save(db,filename + '.dat')
rm(db)
}

So that each file is saved in a .dat file as a data frame, and she only
need to load and remove whenever she uses the file.


On Thu, Mar 20, 2014 at 5:14 PM, PIKAL Petr  wrote:

> Hi
>
> Best way is to put those files in one directory and start R from this
> directory or set this directory as working one.
>
> ?set.wd
> Then you can use list.files() to get file names.
> ?list.files
>
> myfiles<-list.files()
>
> Than strip txt. E.g. by
>
> filenames<-strsplit(list.files(), "\\."))
>
> After that you can use for cycle to read all files, however I would prefer
> list structure.
>
> files<-vector(mode="list", length(myfiles))
>
> for (i in 1:length(myfiles)) {
> files[[i]]<-read.table(myfiles[i])
> names(files)[[i]]<-filenames[[i]][1]
> }
>
> Instead of 75 objects you will get one list object and you can easily use
> interactively or programmatically its parts.
>
> Regards
> Petr
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > project.org] On Behalf Of ajaykumar
> > Sent: Thursday, March 20, 2014 6:15 AM
> > To: r-help@r-project.org
> > Subject: [R] Import multiple files into R
> >
> > Hi I want to import around 75 files. Each file has a name and a time
> > and is comma separated.
> > For example some of my file names are
> > Asheville_Dec.txt
> > Asheville_Jan.txt
> > Asheville_Feb.txt
> > Charlotte_Dec.txt
> > Chapelhill_Jan.txt
> >
> > The time months are only Dec Jan and Feb. The locations are different.
> > I have data for these 3 months at 25 cities which I want to import in R
> > I don't want to use read.table 75 times and keep changing names.
> >
> > Is there any way I can keep all the city names in an object and the
> > three months in another object and then use a loop over read.table of
> > location_time.txt I would also like to view them as 75 different data
> > sets in R So the file Asheville_Dec must be in a dataset called
> > Asheville_Dec in R
> >
> > Can this be done.
> > Please help
> >
> >
> >
> > --
> > View this message in context: http://r.789695.n4.nabble.com/Import-
> > multiple-files-into-R-tp4687178.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.
>
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
> neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho 
> kopie
> vymažte ze svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento 
> email
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou 
> modifikacemi
> či zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
> smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně 
> přijmout;
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
> výslovným dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
> společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně 
> zmocněn
> nebo písemně pověřen a takové pověření nebo plná moc byly 
> adresátovi tohoto
> emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich
> existence je adresátovi či osobě jím zastoupené známá.
>
> This e-mail and any documents attached to it may be confidential and are
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its
> sender. Delete the contents of this e-mail with all attachments and its
> copies from your system.
> If you are not the intended recipient of this e-mail, you are not
> authorized to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible dama

Re: [R] computation

2014-01-13 Thread Lisa S
In this calculation:
(dg0%*%t(dx0))
 is

[,1]  [,2]
[1,]0 -0.75
[2,]0  0.50

So: exp2 = NaN

It is extremely easy to find out the issue if you go back line by line,
this is a basic procedure of debugging. Please do it yourself next time.




On Mon, Jan 13, 2014 at 3:09 PM, IZHAK shabsogh  wrote:

> kindly help me fine what is the mistake with following:
> my aim is to compute those steps and obtain a vector with values (3,5)
> but i am geting (NAN,NAN)
>
> Q<-matrix(c(5,-3,-3,2),2,2)
> b<-rbind(0,1)
> H0<-diag(2)
> x0<-rbind(0,0)
> d0<-b
> g0<--b
> a0<--(t(g0)%*%d0)/(t(d0)%*%Q%*%d0)
> x1<-x0+a0[,1]*d0
> dx0<-x1-x0
> g1<-Q%*%x1-b
> dg0<-g1-g0
> exp1<-(t(dg0)%*%H0%*%dg0)/(t(dg0)%*%dx0)
> exp2<-(dx0%*%t(dx0))/(dg0%*%t(dx0))
> exp3<-(dx0%*%t(dg0)%*%H0 +H0%*%dg0%*%t(dx0))/(dx0%*%t(dg0))
> H1<-H0+(1+exp1[,1])*exp2-exp3
> d1<--H1%*%g1
> a2<-(t(g1)%*%d1)/(t(d1)%*%Q%*%d1)
> x2<-x1+a2[,1]*d1
>
> [[alternative HTML version deleted]]
>
>
> __
> 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.
>
>

[[alternative HTML version deleted]]

__
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] X11 font -adobe-helvetica size 15 could not be loaded

2013-04-04 Thread Lisa Daniel
HI All,

I got this Error message, when I tried to plot
 X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 5 at size 15 could 
not be loaded


sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_CA.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_CA.UTF-8    LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=C LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C    
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 

other attached packages:
[1] stringr_0.6.2  reshape2_1.2.2

loaded via a namespace (and not attached):
[1] plyr_1.8    tools_3.0.0


I looked online for a solution.and found this 
(https://stat.ethz.ch/pipermail/r-help/2002-June/022116.html).  But, 

/etc/X11 $ ls
app-defaults rgb.txt  xkb   Xresources  Xsession.options
default-display-manager  X    Xreset    Xsession    XvMCConfig
fonts    xinit    Xreset.d  Xsession.d  Xwrapper.config

doesn't have XF86Config

 capabilities("X11")
 X11 
TRUE 
names(X11Fonts())
[1] "serif"    "sans" "mono" "Times"    "Helvetica"   
[6] "CyrTimes" "CyrHelvetica" "Arial"    "Mincho" 


Then, I installed xfonts-100dpi, xfonts-75dpi (Ubuntu-based).
xset -q #output


Font Path:
  /usr/share/fonts/X11/misc,/usr/share/fonts/X11/Type1,built-ins
Regards,
Lisa.

__
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] Hands-on Webinar: Advances in Regression: Modern Ensemble and Data Mining Approaches (no charge)

2013-03-20 Thread Lisa Solomon
Hands-on Webinar (no charge)
Advances in Regression: Modern Ensemble and Data Mining Approaches
**Part of the series: The Evolution of Regression from Classical Linear 
Regression to Modern Ensembles

Register Now for Parts 3, 4:  https://www1.gotomeeting.com/register/500959705
**All registrants will automatically receive access to recordings of Parts 1 & 
2.

Course Abstract: Overcoming Linear Regression Limitations
 Regression is one of the most popular modeling methods, but the classical 
approach has significant problems. This webinar series addresses these 
problems. Are you working with larger datasets? Is your data challenging? Does 
your data include missing values, nonlinear relationships, local patterns and 
interactions? This webinar series is for you!
 In our March 29th session (Part 3), we will focus on modern ensemble and 
data mining approaches. These methods dramatically improve the performance of 
weak learners such as regression trees. The techniques discussed here enhance 
the performance of regression trees considerably. These methods inherit the 
good features of trees (variable selection, missing data, mixed predictors) and 
improve on the weak features such as prediction performance.
 Did you miss parts 1 and 2? With your registration, you will receive links 
to the recordings of Part 1 and 2. Covered in part 1 and 2 are  improvements to 
conventional and logistic regression, as well as a discussion of classical, 
regularized, and nonlinear regression from both a theoretical and hands-on 
point of view. The hands-on component includes a step-by-step demonstration 
with instructions for reproducing the demo at your leisure. Especially for the 
dedicated student: after watching this recording, you will be able to apply 
these methods to your own data.

Part 3: March 29, 10-11am PST - Regression methods discussed:

* Nonlinear Ensemble Approaches:

o   TreeNet Gradient Boosting

o   Random Forests

o   Gradient Boosting incorporating Random Forests

* Ensemble Post-Processing:

o   ISLE Importance Sampled Learning Ensembles

o   RuleLearner rule based learning ensembles

Part 4: April 12, 10-11am PST - Hands-on demonstration of concepts discussed in 
Part 3

 *   Step-by-step demonstration
 *   Datasets and software available for download
 *   Instructions for reproducing demo at your leisure
 *   For the dedicated student: apply these methods to your own data (optional)




[[alternative HTML version deleted]]

__
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] try/tryCatch

2013-03-18 Thread lisa
here is the error:

> aa<-metatrialstry(beta_5_50)

Error in asMethod(object) : matrix is not symmetric [1,2]



metatrials, the function that i am attempting to convert with try/tryCatch,
gives me back a matrix with as many rows are there are simulations  (z) in
the aray with dim(x,y,z). with the data i attached, x is 500(number of
patients), y is 9 (these are covariates), and z is 500.


metatrials<-function(mydata){

a<-matrix(data=NA, nrow=dim(mydata)[3], ncol=5)
colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se")

for(ii in 1:dim(mydata)[3]){
tmp<-mydata[,,ii]
tmp1<-as.data.frame(tmp)
names(tmp1)=c("persons", "d1", "tp", "fn", "fp", "fn", "detect", "d0",
"outcome")
lm1<-lmer(outcome~0+d1+d0+(0+d1+d0 | persons), family=binomial,
data=tmp1, nAGQ=3)
a[ii,1]=lm1@fixef[1]
a[ii,2]=lm1@fixef[2]
a[ii,3]=vcov(lm1)[1,2]/prod(sqrt(diag(vcov(lm1
a[ii,4:5]=sqrt(diag(vcov(lm1)))

}
return(a)
}


##


what i want is for the function to go on to the next data set in the array
and simply return an NA for that line in the metatrials results. so
basically, just keep going.


thanks so much for your help!


-Lisa


On Mon, Mar 18, 2013 at 4:24 PM, jim holtman  wrote:

> It would help if you told us what type of error you are getting and to
> also provide sample data so that we could run it to see what happens.  I
> use 'try' a lot to catch errors and have not had any problems with it.
>
> On Mon, Mar 18, 2013 at 6:11 AM, lisa  wrote:
>
>> Hi All,
>>
>> I have tried every fix on my try or tryCatch that I have found on the
>> internet, but so far have not been able to get my R code to continue with
>> the "for loop" after the lmer model results in an error.
>>
>> Here is two attemps of my code, the input is a 3D array file, but really
>> any function would do
>>
>> metatrialstry<-function(mydata){
>>
>> a<-matrix(data=NA, nrow=dim(mydata)[3], ncol=5)
>> #colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se",
>> "counter")#colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se")
>> k=1
>> for(ii in 1:dim(mydata)[3]){
>> tmp<-mydata[,,ii]
>> tmp1<-as.data.frame(tmp)
>> names(tmp1)=c("persons", "d1", "tp", "fn", "fp", "fn", "detect", "d0",
>> "outcome")
>> lm1<-try(lmer(outcome~0+d1+d0+(0+d1+d0 | persons), family=binomial,
>> data=tmp1, nAGQ=3), silent=T)
>> if(class(lm1)[1]!='try-error'){
>> a[ii,1]=lm1@fixef[1]
>> a[ii,2]=lm1@fixef[2]
>> a[ii,3]=vcov(lm1)[1,2]/prod(sqrt(diag(vcov(lm1
>> a[ii,4:5]=sqrt(diag(vcov(lm1)))
>> }
>> }
>> #k=k+1
>> #a[ii,6]=k
>>
>> return(a)
>> }
>>
>> #
>> # try / try catch ###
>> #
>>
>>
>>
>> metatrialstry<-function(mydata){
>>
>> a<-matrix(data=NA, nrow=dim(mydata)[3], ncol=5)
>> #colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se", "counter")
>> colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se")
>> #a[,6]=rep(0, length(a[,6]))
>> for(ii in 1:dim(mydata)[3]){
>> tmp<-mydata[,,ii]
>> tmp1<-as.data.frame(tmp)
>> names(tmp1)=c("persons", "d1", "tp", "fn", "fp", "fn", "detect", "d0",
>> "outcome")
>> lm1<-tryCatch(lmer(outcome~0+d1+d0+(0+d1+d0 | persons),
>> family=binomial, data=tmp1, nAGQ=3), error=function(e) e)
>> a[ii,1]=lm1@fixef[1]
>> a[ii,2]=lm1@fixef[2]
>> a[ii,3]=vcov(lm1)[1,2]/prod(sqrt(diag(vcov(lm1
>> a[ii,4:5]=sqrt(diag(vcov(lm1)))
>> }
>> return(a)
>> }
>>
>>
>> Any guidance would be greatly appreciated...
>>
>> thanks!
>> Lisa
>>
>> --
>> Lisa Wang
>> email: wang.li...@gmail.com
>> cell: +49 -0176-87786557
>> Tübingen, Germany, 72070
>>
>> [[alternative HTML version deleted]]
>>
>>
>> __
>> 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.
>>
>>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.




-- 
Lisa Wang
email: wang.li...@gmail.com
cell: +49 -0176-87786557
Tübingen, Germany, 72070
__
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] try/tryCatch

2013-03-18 Thread lisa
Hi All,

I have tried every fix on my try or tryCatch that I have found on the
internet, but so far have not been able to get my R code to continue with
the "for loop" after the lmer model results in an error.

Here is two attemps of my code, the input is a 3D array file, but really
any function would do

metatrialstry<-function(mydata){

a<-matrix(data=NA, nrow=dim(mydata)[3], ncol=5)
#colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se",
"counter")#colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se")
k=1
for(ii in 1:dim(mydata)[3]){
tmp<-mydata[,,ii]
tmp1<-as.data.frame(tmp)
names(tmp1)=c("persons", "d1", "tp", "fn", "fp", "fn", "detect", "d0",
"outcome")
lm1<-try(lmer(outcome~0+d1+d0+(0+d1+d0 | persons), family=binomial,
data=tmp1, nAGQ=3), silent=T)
if(class(lm1)[1]!='try-error'){
a[ii,1]=lm1@fixef[1]
a[ii,2]=lm1@fixef[2]
a[ii,3]=vcov(lm1)[1,2]/prod(sqrt(diag(vcov(lm1
a[ii,4:5]=sqrt(diag(vcov(lm1)))
}
}
#k=k+1
#a[ii,6]=k

return(a)
}

#
# try / try catch ###
#



metatrialstry<-function(mydata){

a<-matrix(data=NA, nrow=dim(mydata)[3], ncol=5)
#colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se", "counter")
colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se")
#a[,6]=rep(0, length(a[,6]))
for(ii in 1:dim(mydata)[3]){
tmp<-mydata[,,ii]
tmp1<-as.data.frame(tmp)
names(tmp1)=c("persons", "d1", "tp", "fn", "fp", "fn", "detect", "d0",
"outcome")
lm1<-tryCatch(lmer(outcome~0+d1+d0+(0+d1+d0 | persons),
family=binomial, data=tmp1, nAGQ=3), error=function(e) e)
a[ii,1]=lm1@fixef[1]
a[ii,2]=lm1@fixef[2]
a[ii,3]=vcov(lm1)[1,2]/prod(sqrt(diag(vcov(lm1
a[ii,4:5]=sqrt(diag(vcov(lm1)))
}
return(a)
}


Any guidance would be greatly appreciated...

thanks!
Lisa

-- 
Lisa Wang
email: wang.li...@gmail.com
cell: +49 -0176-87786557
Tübingen, Germany, 72070

[[alternative HTML version deleted]]

__
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] Tomorrow: The Evolution of Regression from Classical Linear Regression to Modern Ensembles (hands-on)

2013-03-14 Thread Lisa Solomon
Tomorrow, Friday March 15

Maybe you missed Part 1 of "The Evolution of Regression Modeling from Classical 
Linear Regression to Modern Ensembles " webinar series, but you can still join 
for Parts 2, 3, & 4
> Register Now for Parts 2, 3, 4: 
> https://www1.gotomeeting.com/register/500959705
> 
> Course Outline: Overcoming Linear Regression Limitations
> 
> Regression is one of the most popular modeling methods, but the classical 
> approach has significant problems. This webinar series addresses these 
> problems. Are you working with larger datasets? Is your data challenging? 
> Does your data include missing values, nonlinear relationships, local 
> patterns and interactions? This webinar series is for you! We will cover 
> improvements to conventional and logistic regression, and will include a 
> discussion of classical, regularized, and nonlinear regression, as well as 
> modern ensemble and data mining approaches. This series will be of value to 
> any classically trained statistician or modeler.
> 
> Part 2 (Hands-on): March 15, 10-11am PST - Hands-on demonstration of concepts 
> discussed in Part 1 (Classical Regression, Logistic Regression, Regularized 
> Regression: GPS Generalized Path Seeker, Nonlinear Regression: MARS 
> Regression Splines)
> 
> Step-by-step demonstration
> Datasets and software available for download
> Instructions for reproducing demo at your leisure
> For the dedicated student: apply these methods to your own data (optional)
> · Part 1 recording: 
> http://www.salford-systems.com/videos/tutorials/805-the-evolution-of-regression-modeling-part-1
> 
> Part 3: March 29, 10-11am PST - Regression methods discussed
> *Part 1 is a recommended pre-requisite
> 
> Nonlinear Ensemble Approaches: TreeNet Gradient Boosting; Random Forests; 
> Gradient Boosting incorporating RF
> Ensemble Post-Processing: ISLE; RuleLearner
> Part 4: April 12, 10-11am PST - Hands-on demonstration of concepts discussed 
> in Part 3
> 
> Step-by-step demonstration
> Datasets and software available for download
> Instructions for reproducing demo at your leisure
> For the dedicated student: apply these methods to your own data (optional)
>  
> 
>  
> 
>  

[[alternative HTML version deleted]]

__
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] Hands-on Webinar Series (no charge) The Evolution of Regression from Classical Linear Regression to Modern Ensembles

2013-03-11 Thread Lisa Solomon
Maybe you missed Part 1 of "The Evolution of Regression Modeling from Classical 
Linear Regression to Modern Ensembles " webinar series, but you can still join 
for Parts 2, 3, & 4
Register Now for Parts 2, 3, 4: https://www1.gotomeeting.com/register/500959705
Download (optional) a free evaluation of the SPM software suite v7.0 (used in 
the hands-on components of the webinar). As a webinar participant you will 
qualify for a 60-Day Evaluation of the software at no charge: 
http://2.salford-systems.com/the-salford-predictive-modeler-download/
Course Outline: Overcoming Linear Regression Limitations
Regression is one of the most popular modeling methods, but the classical 
approach has significant problems. This webinar series addresses these 
problems. Are you working with larger datasets? Is your data challenging? Does 
your data include missing values, nonlinear relationships, local patterns and 
interactions? This webinar series is for you! We will cover improvements to 
conventional and logistic regression, and will include a discussion of 
classical, regularized, and nonlinear regression, as well as modern ensemble 
and data mining approaches. This series will be of value to any classically 
trained statistician or modeler.
Part 2 (Hands-on): March 15, 10-11am PST - Hands-on demonstration of concepts 
discussed in Part 1 (Classical Regression, Logistic Regression, Regularized 
Regression: GPS Generalized Path Seeker, Nonlinear Regression: MARS Regression 
Splines)

 *   Step-by-step demonstration
 *   Datasets and software available for download
 *   Instructions for reproducing demo at your leisure
 *   For the dedicated student: apply these methods to your own data (optional)

* Part 1 recording: 
http://www.salford-systems.com/videos/tutorials/805-the-evolution-of-regression-modeling-part-1
Part 3: March 29, 10-11am PST - Regression methods discussed
*Part 1 is a recommended pre-requisite

 *   Nonlinear Ensemble Approaches: TreeNet Gradient Boosting; Random Forests; 
Gradient Boosting incorporating RF
 *   Ensemble Post-Processing: ISLE; RuleLearner
Part 4: April 12, 10-11am PST - Hands-on demonstration of concepts discussed in 
Part 3

 *   Step-by-step demonstration
 *   Datasets and software available for download
 *   Instructions for reproducing demo at your leisure
 *   For the dedicated student: apply these methods to your own data (optional)




[[alternative HTML version deleted]]

__
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] Results from clogit out of range?

2013-03-04 Thread Lisa S
Thanks for the illustrative example. In my project actually my supervisor
wanted to estimate the probabilities using a "conditional MLE" approach,
which happens to be the case that *uses clogit() while trying to achieve
aim b in your words*.

I learned that clogit() is based on the sufficient statistic which is
usually the sum over all positive responses in each stratum. However since
we are supposed to not knowing the responses when trying to predict a new
sample, it can be impossible to do this "out-of-sample" prediction right?

Now what I suggested is to use clogit() to estimate beta (ppl say this beta
is better than betas from unconditional MLE, why??) and derive the linear
predictor for any new sample by multiplying new predictors with this beta,
then

1) if there is only one obs each strata, use the traditional unconditional
formula

phat = exp(xbeta)/(1+exp(xbeta))

to get the so-called predicted probability;

2) if there is a lot of obs each strata, use

phat = exp(xbeta)/sum(exp(xbeta))

to get the so-called predicted probabilities.

My case has only 1 obs per stratum so I used method 1. Though I am not sure
if it is reasonable. Would like to hear opinions from all of you guy. ;P

On Mon, Mar 4, 2013 at 10:04 PM, Terry Therneau  wrote:

> I'm late to this discussion, but let me try to put it in another context.
>   Assume that I wanted to know whether kids who live west of their school
> or east of their shool are more likely to be early (some hypothesis about
> walking slower if the sun is in their eyes).  So I create a 0/1 variable
> east/west and get samples of 10 student arrival times at each of 100
> different schools.  Fit the model
>
>lm(arrive ~ factor(school) + east.west)
>
> where "arrive" is in some common scale like "minutes since midnight".
>  Since different schools could have different starting times for their
> first class we need an intercept per school.
>
>   Two questions:
>  1. Incremental effect: the coefficient of east/west measures the
> incredmental effect across all schools.  With n of 1000 it is likely
> estimated with high precision.
>  2. Absolute: predict the average arrival time (on the clock) for
> students.
>
> Conditional logistic is very like this.  We have a large number of strata
> ("schools") with a small number of observations in each (often only 2 per
> strata).  One can ask incremental questions about variables common to all
> strata, but absolute prediction is pretty worthless.  a. You can only do it
> for schools (strata) that have already been seen and b. there are so few
> subjects in each of them that the estimates are very noisy.
>   The default prediction from clogit is focused on questions of type 1.
>  The documentation doesn't even bother to mention predictions of type 2,
> which would be probabilities of events.  I can think of a way to extract
> such output from the routine (being the author gives some insight), but why
> would I want to?
>
> Terry Therneau
>
>

[[alternative HTML version deleted]]

__
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] Results from clogit out of range?

2013-03-01 Thread Lisa Sheng
Sorry I was asking a question inspired by the original question, which relates 
to the out of sample prediction. 

He was asking why it's not of the probability range, and I also found that 
clogit only gives out linear predictors in both estimation and prediction, but 
never the probability. For in sample ones, we can derive it as the last thread 
says; that's what inspired me of thinking of out of sample cases. And I am 
guessing but not sure if the probability of that case can also be deduced. 

I'd like to hear of your opinions. Thanks anyway for your response and sorry 
for the misunderstandings.

Thanks,
Lisa

On 1 Mar, 2013, at 10:10 PM, David Winsemius  wrote:

>>>> I still don't think the exp(lp)/(1+exp(lp)) gonna work. Since this is 
>>>> conditional logit model, while this formula is only used in unconditional 
>>>> ones. By using this, one neglects the information based on stratum. Though 
>>>> I don't know how to solve it to. I am also working on a project on this 
>>>> and I do hope there's someone explaining this problem. Will that be a 
>>>> possibility that the phat can never be estimated as we never know the 
>>>> individual intercept?
> 
>>> This appears to be addressed to a thread that appeared almost three years 
>>> ago. I suspect you have not read all the way to the end of the thread:
>>> 
>>> https://stat.ethz.ch/pipermail/r-help/2010-April/235956.html
> On Feb 28, 2013, at 5:45 PM, lisa wrote:
> 
>> I do appreciate this answer. I heard that in SAS, conditional logistic model 
>> do predictions in the same way. However, this formula can only deal with 
>> in-sample predictions. How about the out-of-sample one? Is it like one of 
>> the former responses by Thomas, say, it's impossible to do the out-of-sample 
>> prediction??
> 
> I do not understand how an "out-of-sample" conditional estimate makes any 
> logical sense. The questioner was asking why he was getting values outside 
> the range of [0,1] which is not the same as asking for estimates for strata 
> outside the range of the stratum values. Charles Berry gave another sensible 
> answer, but I did not interpret his suggestion as solving what you seem to be 
> requesting.
> 
> -- 
> 
> David Winsemius
> Alameda, CA, USA
> 

__
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] Results from clogit out of range?

2013-02-28 Thread lisa
I do appreciate this answer. I heard that in SAS, conditional logistic model do 
predictions in the same way. However, this formula can only deal with in-sample 
predictions. How about the out-of-sample one? Is it like one of the former 
responses by Thomas, say, it's impossible to do the out-of-sample prediction??
__
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 and barplot in the same page

2013-02-27 Thread Lisa Daniel
Dear Rhelp,

I am trying to get multiple xyplots and barplots in the same page.  I couldn't 
get it work.
Example code:
library(lattice)
library(grid)
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
 = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0,
            axis.bottom=0.8)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.50, 0.33, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.50, 0.66, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.50, 0.99, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.45), more = TRUE)
j=j+1
counts <- table(mtcars$gear)
barplot(counts, main="Car Distribution",  #this part is not correct
   xlab="Number of Gears") 

Thanks in advance,

Lisa


__
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] Alternate tick labels in xyplot

2013-02-14 Thread Lisa Daniel


Dear David and Duncan,

Thank you for the responses.

David:

I was able to fix it with grid.text().

Duncan:
I would certainly look into ?scale.components in latticeExtra package 
(xscale.components.default)

The code for the figure is below.
library(lattice)
library(grid)

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
 = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0,
            axis.bottom=0.8)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.50, 0.33, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.50, 0.66, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.50, 0.99, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.45), more = FALSE)
grid.text("Upper row", x=0.5, y=0.97, gp=gpar(fontsize=12, col="black"))
grid.text("Lower row", x=0.5, y=0.47, gp=gpar(fontsize=12, col="black"))



Thanks,
Lisa


- Original Message -
From: David Winsemius 
To: Lisa Daniel 
Cc: "r-help@r-project.org" 
Sent: Thursday, February 14, 2013 4:31 PM
Subject: Re: [R] Alternate tick labels in xyplot


On Feb 14, 2013, at 10:52 AM, Lisa Daniel wrote:

> Dear Rhelp,
> I was able to solve the tick labels part.  If somebody can help me in 
> creating title for each row of figures above the individual headings, it will 
> be great.

I think you need to be looking at grid.text() in package grid.

> library(grid)
> library(lattice)
> xy <-xyplot(decrease ~ treatment, OrchardSprays,
>     main= "Some plot",
>         groups = rowpos, type = "a",
>     scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
>                 page     = function(n){
>                          grid.text(LETTERS[j],
>                          y = 0.95,
>                          x = 0.15,
>                          default.units = "npc",
>                          just = c("left"),
>                          gp = gpar(fontsize = 12,fontface="bold") )
>                        },
>     par.settings = c(simpleTheme(lty=1:8, 
>col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
> = list(main = 1.2,
>                        sub  = 0,
>                        axis.top = 0.2,
>                        top.padding  = 0.1,
>                        bottom.padding = 0)) ),
>         auto.key = list(x = 0.2, y = 0.9,
>         cex = 0.75, points = FALSE, lines = TRUE)) 
> j=1
> print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
> j=j+1
> print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
> j=j+1
> print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
> j=j+1
> print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
> j=j+1
> print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
> j=j+1
> print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)
> 
> Many thanks,
> Lisa
> 
> 
> 
> 
> - Original Message -
> From: Lisa Daniel 
> To: "r-help@r-project.org" 
> Cc: 
> Sent: Thursday, February 14, 2013 12:14 PM
> Subject: Alternate tick labels in xyplot
> 
> Dear Rhelp,
> 
> I would like to get alternate tick labels for the xyplot:
> library(lattice)
> library(grid)
> 
> xy <-xyplot(decrease ~ treatment, OrchardSprays,
>     main= "Some plot",
>         groups = rowpos, type = "a",
>                 page     = function(n){
>                          grid.text(LETTERS[j],
>                          y = 0.95,
>                          x = 0.15,
>                          default.units = "npc",
>                          just = c("left"),
>                          gp = gpar(fontsize =

Re: [R] Alternate tick labels in xyplot

2013-02-14 Thread Lisa Daniel
Dear Rhelp,
I was able to solve the tick labels part.  If somebody can help me in creating 
title for each row of figures above the individual headings, it will be great.
library(grid)
library(lattice)
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
 = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)

Many thanks,
Lisa




- Original Message -
From: Lisa Daniel 
To: "r-help@r-project.org" 
Cc: 
Sent: Thursday, February 14, 2013 12:14 PM
Subject: Alternate tick labels in xyplot

Dear Rhelp,

I would like to get alternate tick labels for the xyplot:
library(lattice)
library(grid)

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


similar to the x-axis in the code below, but somehow it is not working when I 
pasted 'list(axis.components=...) in the above code:
xyplot(rnorm(12) ~ 1:12 , type="l",
scales=list(x=list(at=seq(2,12,2),labels=c(1, ' ', 3 , ' ' , 5 , ' ' ))),
par.settings=list(axis.components=list(bottom=list(tck=c(0,1) 

scales=list(x=list(at=seq(1,8,1),labels=c('A', ' ', 'C', ' ' ,'E' , ' ','G',' 
'))),

If possible, I would like a heading for each rows (justified to center) above 
the individual heading.

Please help.
Many thanks,
Lisa.


__
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] Alternate tick labels in xyplot

2013-02-14 Thread Lisa Daniel
Dear Rhelp,

I would like to get alternate tick labels for the xyplot:
library(lattice)
library(grid)

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


similar to the x-axis in the code below, but somehow it is not working when I 
pasted 'list(axis.components=...) in the above code:
xyplot(rnorm(12) ~ 1:12 , type="l",
scales=list(x=list(at=seq(2,12,2),labels=c(1, ' ', 3 , ' ' , 5 , ' ' ))),
par.settings=list(axis.components=list(bottom=list(tck=c(0,1) 

scales=list(x=list(at=seq(1,8,1),labels=c('A', ' ', 'C', ' ' ,'E' , ' ','G',' 
'))),

If possible, I would like a heading for each rows (justified to center) above 
the individual heading.

Please help.
Many thanks,
Lisa.

__
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] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Duncan and Pascal,
Thank you for the response.

Duncan: 

I was able to fix the space between title and figure.  I would also like to  
have separate main titles for each row of figures in addition to the individual 
titles.

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)

Pascal:
I would prefer not to use panels as this is for publication purpose.  


Many thanks,
Lisa





- Original Message -
From: Duncan Mackay 
To: Lisa Daniel ; r-help-r-project.org 

Cc: 
Sent: Wednesday, February 13, 2013 7:53 PM
Subject: Re: [R] Plotting multiple xyplots in same page

Hi Lisa

have a look at par.settings in ?xyplot

trellis.par.get() shows the settings

trellis.par.get()[[27]]
$left
$left$tck
[1] 1

$left$pad1
[1] 1

$left$pad2
[1] 1


$top
$top$tck
[1] 1

$top$pad1
[1] 1

$top$pad2
[1] 1


$right
$right$tck
[1] 1

$right$pad1
[1] 1

$right$pad2
[1] 1


$bottom
$bottom$tck
[1] 1

$bottom$pad1
[1] 1

$bottom$pad2
[1] 1

as an example:

par.settings = list(
layout.heights = list(main = 0,
                       sub  = 0,
                       axis.top = 0.2,
                       top.padding  = 0,
                       bottom.padding = 0)    )

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au




At 09:10 14/02/2013, you wrote:
>Dear Rhelp,
>
>I was able to plot 6 figures in one page.  I do need help in 
>reducing the space between the title and the plot and assigning 
>A,B,C,D,E,F to each figure
>library(lattice)
>trellis.par.set(theme = col.whitebg())
>xy <- xyplot(decrease ~ treatment, OrchardSprays,
>         main="Some plot",
>               groups = rowpos, type = "a",
>               auto.key = list(x = 0.2, y = 0.9,
>                 cex = 0.52, points = FALSE, lines = TRUE))
>
>
>print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
>print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
>print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
>print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
>print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
>print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)
>
>Thanks in advance,
>Lisa
>
>
>
>- Original Message -
>From: Lisa Daniel 
>To: "r-help@r-project.org" 
>Cc:
>Sent: Wednesday, February 13, 2013 5:28 PM
>Subject: Plotting multiple xyplots in same page
>
>Dear Rhelp,
>
>I would like to have 6 xyplots in the same page.  Similar to 
>(par(mfrow=c(3,3))
>Found this example on the R archives.
>library(lattice)
>trellis.par.set(theme = col.whitebg())
>xy <- xyplot(decrease ~ treatment, OrchardSprays,
>               groups = rowpos, type = "a",
>               auto.key = list(x = 0.2, y = 0.9,
>                 cex = 0.75, points = FALSE, lines = TRUE))
>
>print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE)
>print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE)
>print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE)
>print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE)
>
>
>
>
>When I changed the print() to:
>
>  print(xy, pos=c(0.0,0.0,0.33,0.33),more = TRUE),
>the figure was not looking good.
>
>Also, is it possible to assign A, B, C,D, etc for each figure.
>
>
>
>a<- rnorm(1000,0,1)
>b<- rnorm(1000,0,2)
>c<- rnorm(1000,0,3)
>d<- rnorm(1000,0,4)
>par(mfrow=c(2,2))
>hist(a,main="")
>title(main="A",adj=0)
>hist(b,main="")
>title(main="B",adj=0)
>hist(c,main="")
>title(main="C",adj=0)
>hist(d,main="")
>title(main="D",adj=0)
>
>
>I

Re: [R] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Duncan,

Thank you.  It helped a lot.
I was able to get it correct though I couldn't get it working under 
simpleTheme() (for publication purpose).

#this gave me the correct format.
library(grid)
library(lattice)
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = list(
 layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
#pdf("trial.pdf",width=12)
#jpeg("trial.jpeg",quality=100,width=680,height=480)
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)
#dev.off()


# I tried the same with simpleTheme(), but I am not getting it correct, (the 
lines are colored):

pset <- simpleTheme(lty = 1:8, col="black",lwd=2)  
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = list(pset,
 layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


#the output from the below code is B&W, but space between title and figure not 
corrected

pset <- simpleTheme(lty = 1:8, col="black",lwd=2)  
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = pset,
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 

j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


Also, I would like to create a main title for the first row and second row of 
figures.
Many thanks in advance,
Lisa


- Original Message -
From: Duncan Mackay 
To: Lisa Daniel ; r-help-r-project.org 

Cc: 
Sent: Wednesday, February 13, 2013 7:53 PM
Subject: Re: [R] Plotting multiple xyplots in same page

Hi Lisa

have a look at par.settings in ?xyplot

trellis.par.get() shows the settings

trellis.par.get()[[27]]
$left
$left$tck
[1] 1

$left$pad1
[1] 1

$left$pad2
[1] 1


$top
$top$tck
[1] 1

$top$pad1
[1] 1

$top$pad2
[1] 1


$right
$right$tck
[1] 1

$right$pad1
[1] 1

$right$pad2
[1] 1


$bottom
$bottom$tck
[1] 1

$bottom$pad1
[1] 1

$bottom$pad2
[1] 1

as an example:

par.settings = list(
layout.heights = list(main = 0,
                       sub  = 0,
                       axis.top = 0.2,
                       top.padding  = 0,
                       bottom.padding = 0)    )

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New

Re: [R] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Rhelp,

I was able to plot 6 figures in one page.  I do need help in reducing the space 
between the title and the plot and assigning A,B,C,D,E,F to each figure
library(lattice)
trellis.par.set(theme = col.whitebg())
xy <- xyplot(decrease ~ treatment, OrchardSprays,
        main="Some plot",
  groups = rowpos, type = "a",
  auto.key = list(x = 0.2, y = 0.9,
    cex = 0.52, points = FALSE, lines = TRUE))


print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)

Thanks in advance,
Lisa



- Original Message -
From: Lisa Daniel 
To: "r-help@r-project.org" 
Cc: 
Sent: Wednesday, February 13, 2013 5:28 PM
Subject: Plotting multiple xyplots in same page

Dear Rhelp,

I would like to have 6 xyplots in the same page.  Similar to (par(mfrow=c(3,3))
Found this example on the R archives.
library(lattice)
trellis.par.set(theme = col.whitebg())
xy <- xyplot(decrease ~ treatment, OrchardSprays,
  groups = rowpos, type = "a",
  auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE))

print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE)
print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE)
print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE)
print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE)




When I changed the print() to:

 print(xy, pos=c(0.0,0.0,0.33,0.33),more = TRUE),
the figure was not looking good.

Also, is it possible to assign A, B, C,D, etc for each figure. 



a<- rnorm(1000,0,1) 
b<- rnorm(1000,0,2) 
c<- rnorm(1000,0,3) 
d<- rnorm(1000,0,4) 
par(mfrow=c(2,2)) 
hist(a,main="") 
title(main="A",adj=0) 
hist(b,main="") 
title(main="B",adj=0) 
hist(c,main="") 
title(main="C",adj=0) 
hist(d,main="") 
title(main="D",adj=0)


I tried this to xyplot, but it was not working.

Please help me.  

Many thanks in advance,
Lisa.


__
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] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Rhelp,

I would like to have 6 xyplots in the same page.  Similar to (par(mfrow=c(3,3))
Found this example on the R archives.
library(lattice)
trellis.par.set(theme = col.whitebg())
xy <- xyplot(decrease ~ treatment, OrchardSprays,
  groups = rowpos, type = "a",
  auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE))

print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE)
print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE)
print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE)
print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE)




When I changed the print() to:

 print(xy, pos=c(0.0,0.0,0.33,0.33),more = TRUE),
the figure was not looking good.

Also, is it possible to assign A, B, C,D, etc for each figure. 



a<- rnorm(1000,0,1) 
b<- rnorm(1000,0,2) 
c<- rnorm(1000,0,3) 
d<- rnorm(1000,0,4) 
par(mfrow=c(2,2)) 
hist(a,main="") 
title(main="A",adj=0) 
hist(b,main="") 
title(main="B",adj=0) 
hist(c,main="") 
title(main="C",adj=0) 
hist(d,main="") 
title(main="D",adj=0)


I tried this to xyplot, but it was not working.

Please help me.  

Many thanks in advance,
Lisa.

__
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] Webinar: Advances in Gradient Boosting: the Power of Post-Processing. TOMORROW, 10-11 a.m., PST

2012-12-13 Thread Lisa Solomon
Webinar: Advances in Gradient Boosting: the Power of Post-Processing

TOMORROW: December 14, 10-11 a.m., PST



Webinar Registration: 
http://2.salford-systems.com/gradientboosting-and-post-processing/


Course Outline:
I. Gradient Boosting and Post-Processing:
o What is missing from Gradient Boosting?
o Why post-processing techniques are used?

II. Applications Benefiting from Post-Processing: Examples from a variety of 
industries.
o Financial Services
o Biomedical
o Environmental
o Manufacturing
o Adserving

III. Typical Post-Processing Steps

IV. Techniques:
o Generalized Path Seeker (GPS): modern high-speed LASSO-style regularized 
regression.
o Importance Sampled Learning Ensembles (ISLE): identify and reweight the most 
influential trees.
o Rulefit: ISLE on "steroids." Identify the most influential nodes and rules.

V. Case Study Example:
o Output/Results without Post-Processing
o Output/Results with Post-Processing
o Demo


[[alternative HTML version deleted]]

__
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] Webinar signup: Advances in Gradient Boosting: the Power of Post-Processing. December 14, 10-11 a.m., PST

2012-11-26 Thread Lisa Solomon
Webinar signup:

Advances in Gradient Boosting: the Power of Post-Processing

December 14, 10-11 a.m., PST



Webinar Registration:
http://2.salford-systems.com/gradientboosting-and-post-processing/


Course Outline:

*Gradient Boosting and Post-Processing:

o   What is missing from Gradient Boosting?

o   Why post-processing techniques are used?

*Applications Benefiting from Post-Processing: Examples from a variety 
of industries.

o   Financial Services

o   Biomedical

o   Environmental

o   Manufacturing

o   Adserving

*Typical Post-Processing Steps

*Techniques:

o   Generalized Path Seeker (GPS): modern high-speed LASSO-style regularized  
regression.

o   Importance Sampled Learning Ensembles (ISLE): identify and reweight  the 
most influential trees.

o   Rulefit: ISLE on "steroids."  Identify the most influential nodes and rules.

*Case Study Example:

o   Output/Results without Post-Processing

o   Output/Results with Post-Processing

o   Demo




[[alternative HTML version deleted]]

__
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] Webinar signup: Gradient Boosting and Classification Trees: A Winning Combination. November 9, 10-11 a.m., PST

2012-10-31 Thread Lisa Solomon
Webinar signup: 
Tree Ensembles and Classification Trees: A Winning Combination
November 9, 10-11 a.m., PST.

Webinar Registration: 
http://2.salford-systems.com/gradientboosting/ 

Understand major shortcomings of using only decision trees and how tree 
ensembles can help overcome these challenges and improve your model building. 
Combine all of the advantages of using classification and regression trees with 
the power-house interpretability of stochastic gradient boosting.
 __
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] choosing the correct number of clusters usinf NbClust

2012-08-22 Thread Lisa Baxter


I am attempting to use NbClust to examine different indices to determine
the number of clusters.  The code appears to be working and I am getting
results.  However, I have noticed that each time I run it I may get
different answers.  For example looking at the DB index one run
recommended 6 clusters while the next 5 - the code is exactly the same.
I assume there is some randomization that I don't see.  Is there a way
to get a consistent answer. Thanks.

-Lisa
[[alternative HTML version deleted]]

__
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] simple matching with R

2012-03-19 Thread Lisa Krchov
Hello,

I would like to use the simple matching coefficient in R to compare
genotypic data from two years (there are some inconsistencies in the
genotype notations in the 2 years and I want to find out the error).
Is there a R code I could use? How does my matrix needs to look like?

I have 50 genotypes  and each genotype is genotyped with 780 markers for
two different years. So I need to compare the markers for genotype 1 form
year 1 versus year 2, the markers from genotype 2 from year 1 to year 2 and
so on, so I can calculate the matching coefficients.

Is there a R code for that already?

Thank you very much in advance,
Lisa-Marie

[[alternative HTML version deleted]]

__
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] resistanceDistance representation

2012-02-23 Thread Lisa Santambrogio
Dear all,
i'm using gdistance to model animal movement across landscape.
I have imported 11 rasters with roads, freeways, slope, use-of-land, lakes
(...) after recoding them with GRASS with a HSI value ranging from 1 to 4.
I've assigned zero to the NAs and then transformed all the rasters in
TransitionLayers (function=mean,directions=4) and later summed all of them
into a new transition:


> MY_transitionclass   : TransitionLayer
dimensions  : 2181, 1648, 3594288  (nrow, ncol, ncell)
resolution  : 100.0049, 99.98945  (x, y)
extent  : 1460708, 1625516, 4947383, 5165460  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=150
+y_0=0 +ellps=intl +towgs84=-225,-65,9,0,0,0,0 +units=m +no_defs
values  : conductance
matrix class: dsCMatrix

I applied two different geocorrections to this same transition:

> MY_correction<-geoCorrection(MY_transition,"c",F,scl=T)

> MY_Rcorrection<-geoCorrection(MY_transition,"r",F,scl=T)

My coords are 44 points where samples were taken (some further genetic
analyses are programmed), but i've also tried with only two points:

> coords<-read.csv("coords_md.csv",header=F)
> mycoords<-as.matrix(coords)
> my_spatialpoints<-SpatialPoints(mycoords)

Finally I calculated three geographical distance matrices:

> geodist <- pointDistance(my_spatialpoints,longlat=FALSE)
> summary(geodist)   V1   V2   V3   V4  
>  V5
 Min.   : 0   Min.   : 0   Min.   : 0   Min.   : 0
Min.   : 0
 1st Qu.:133788   1st Qu.:133788   1st Qu.:133788   1st Qu.:133788
1st Qu.:133788
 Median :133788   Median :133788   Median :133788   Median :133788
Median :135168
 Mean   :114704   Mean   :117371   Mean   :120166   Mean   :123097
Mean   :126174
 3rd Qu.:137971   3rd Qu.:137971   3rd Qu.:137971   3rd Qu.:137971
3rd Qu.:137971
 Max.   :137971   Max.   :137971   Max.   :137971   Max.   :137971
Max.   :137971
  NA's   : 1   NA's   : 2   NA's   : 3
NA's   : 4
()

> costdist <- costDistance(MY_correction, my_spatialpoints)

> summary(costdist)   Min. 1st Qu.  MedianMean 3rd Qu.Max.
   0.000.00   21.92   68.53  210.90  244.70


> resdist <- resistanceDistance(MY_Rcorrection, my_spatialpoints)
> summary(resdist) Min. 1st Qu. Median Mean 3rd Qu. Max. 0 0 1022
1707 4286 4830

Now, I'd like to represent this measures but I couldn't find any examples
of how to do it; plotting or imaging them doesn't return a meaningful
graph, I guess I should transform them somehow but I don't know how.
ANY help would be really appreciated, along with comments about the rest of
the work done.

Thanks in advance,
Lisa

[[alternative HTML version deleted]]

__
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] Help with SEM package: Error message

2011-11-08 Thread Lisa Pham
Dear John,

Thank you for your reply.  My data is actually simulated under the model X
= Lambda*F + E.

Since my post, I've simplified the simulation of my data and I still get
the error.  This is what I've done since my last post.

I constructed Lambda apriori (so I know exactly which observed variables
load onto which factors), E follows a Gaussian with mean 0 and var-cov
matrix given by the Identity matrix.

For my particular model, I sample the factor scores F_i (for sample i) from
a multivariate normal

F_i ~ N(mu_i, Phi).

mu_i is fixed to Phi*z_i, where z_i is a 5x1 vector.

Thinking I could have an ill-conditioned var-cov matrix, I looked at the
condition number of Phi (the factor var-cov matrix).  I recently adjusted
Phi to ensure that the condition number was indeed small (it is now about
2).

I then sample Y_i ~ N(Lambda*F_i, Psi).

If the data I'm simulating is ill conditioned, I'm not even sure how to fix
it because the simulation itself is pretty straightforward.  Even with a
well conditioned factor var-cov matrix Phi that I used to sample my factor
scores, I still get that same problem.

In any case, I am so grateful for your help- I've been working on this all
day and I can't seem to figure out where I go wrong.  I made Lambda pretty
sparse and with 150 samples, I certainly don't have too many parameters...
besides identifiability, I'm not sure what to check for if its not a
problem with my coding.  Your post has already helped me to think about
this problem a little differently.

Sincerely,
Lisa


On Tue, Nov 8, 2011 at 9:32 PM, John Fox  wrote:

> Dear Lisa,
>
> There doesn't seem to be anything logically wrong with your model.
>
> I don't have much time today to look into it, but trying different
> optimizers in version 2.0-0 of sem, using the correlation matrix in place
> of the covariance matrix, and setting the par.size parameter, I was unable
> to obtain an admissible solution. I also was unable using factanal() to fit
> an exploratory factor analysis for five factors to your data. I expect that
> the problem is ill-conditioned.
>
> Best,
>  John
>
> 
> John Fox
> Sen. William McMaster Prof. of Social Statistics
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox/
> On Tue, 8 Nov 2011 08:18:28 -0800 (PST)
>  lisamp85  wrote:
> > Hello.
> >
> > I started using the sem package in R and after a lot of searching and
> trying
> > things I am still having difficulty.  I get the following error message
> when
> > I use the sem() function:
> >
> > Warning message:
> > In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names =
> > vars,  :
> >   Could not compute QR decomposition of Hessian.
> > Optimization probably did not converge.
> >
> > I started with a simple example using the specify.model() function, but
> it
> > is really straight forward.  I uploaded my specify.model script and my
> data
> > covariance matrix here too so I wouldn't clutter this email with the
> entire
> > model (20 observed variables, 5 factors).  Could this error message be
> from
> > the data itself and not from my path model?
> >
> > I have my observed variables X and my unobserved variables F.  I have
> ONLY
> > exogenous latent variables (i.e. they never appear on the right side of
> the
> > single head arrow ->).  I include all possible factor covariances FjFk,
> and
> > the only constraints I've made was to restrict the Factor variances to 1.
> > My model follows in this basic format (as you can see from my uploaded
> > file):
> >
> > # Factors (where I specify which observed variables load on to which
> > factors)
> > # I have only exogenous latent variables
> > F.i -> X.j, lamj.i, NA
> > .
> > .
> > .
> > # Observed variable variances
> > X.j <-> X.j, ej, NA
> > .
> > .
> > .
> > # Factor variances (I fixed all factor variances to 1)
> > F.i <-> F.i, NA, 1
> > .
> > .
> > .
> > # Factor covariances (I represent all factor covariances, i.e. the upper
> or
> > lower triangle of a covariance matrix)
> > F.i <-> F.k, FiFk, NA
> > .
> > .
> > .
> >
> > Did I do something wrong here?
> > Here are my uploaded files:
> > CFA script:  http://r.789695.n4.nabble.com/file/n4016569/CFA_script.txt
> > CFA_script.txt
> > Covariance matrix:
> > http://r.789695.n4.nabble.com/file/n4016569/covariance_matrix.RData
> > covariance_matrix.RData
> >
> >
> > Thank you s

[R] (no subject)

2011-10-21 Thread Lisa Henault
can i be taken off of this mailing list please?

is there another way that you can access this without having to get all the
emails??

[[alternative HTML version deleted]]

__
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] Text annotation of a graph

2011-08-05 Thread Lisa
Thank you. I will try this.

Lisa

--
View this message in context: 
http://r.789695.n4.nabble.com/Text-annotation-of-a-graph-tp3719775p3722163.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] Text annotation of a graph

2011-08-05 Thread Lisa
Thanks you for your reply.

I consider only the performance of “vars” (v1 to v10), so I just want to
indicate then on the y-axis at the point they should be located. 

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Text-annotation-of-a-graph-tp3719775p3721799.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] Text annotation of a graph

2011-08-04 Thread Lisa
Dear All, 

I am trying to add some text annotation to a graph using matplot() as
follows:

  vars <- c("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v8", "v10")
  id <- seq(5.000, 0.001, by = -0.001)
  sid <- c(4.997, 3.901, 2.339, 0.176, 0.151, 0.101, 0.076, 0.051, 0.026,
0.001)
  rn <- sample(seq(0, 0.6, by = 0.001), 5000, replace = T)
  matplot(rbind(rn, rep(0, length(rn))), rbind(id, id), xlim = c(0, 1),
  type = "l", lty = 1, lwd = 1, col = 1, xlab = "",
  ylab = "", axes = F)
  abline(v = 0, lty = 2)
  axis(1)
  mtext(side = 2, text = c(vars), at = sid, las = 2, line = 0.8)
  axis(3) 

But the text annotation can not be displayed correctly, i.e., some of them
stick together. 
Can anybody help me with this particular problem? Thanks in advance.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Text-annotation-of-a-graph-tp3719775p3719775.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 package: pbatR

2011-07-14 Thread Lisa
Thanks. I have installed PBAT on my computer.

--
View this message in context: 
http://r.789695.n4.nabble.com/R-package-pbatR-tp3667844p3667907.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: pbatR

2011-07-14 Thread Lisa
Dear All,

Does anybody have experience with R package pbatR
(http://cran.r-project.org/web/packages/pbatR/index.html)? I am trying to
use it to analyze the family-based case-control data, but the package
totally doesn’t work on my computer. I contacted the authors of the package,
but I haven’t heard anything from them. 

Following the package manual, I tried the simple example as below:

library(pbatR)
library(tcltk)
pbat.set("C:/pbat")

x <- data.frame(pid = c(1,1,1,2,2,2,2,3,3,3),  # three families
 id = c(1,2,3,1,2,3,4,1,2,3),
 idfath = c(0,0,1,0,0,1,1,0,0,1),
 idmoth = c(0,0,2,0,0,2,2,0,0,2),
sex = c(1,2,1,1,2,2,2,1,2,1),
AffectionStatus = c(0,0,1,0,0,1,0,0,0,1),  # 1 for case, 0 for control
   m1.1 = c(1,1,2,2,1,1,2,2,2,1),  # two SNPs with two columns
for each SNP
   m1.2 = c(1,2,1,2,1,2,1,1,2,2),
   m2.1 = c(1,1,2,2,2,1,1,1,2,1),
   m2.2 = c(2,1,2,1,2,2,2,1,1,1))
x1 <- as.ped(x)

y <- data.frame(pid = c(1,1,1,2,2,2,2,3,3,3),
 id = c(1,2,3,1,2,3,4,1,2,3),
age = c(55,50,22,38,37,15,11,42,41,17),
 weight = c(185,170,130,165,170,90,60,170,160,120))
y1 <- as.phe(y)


1. I first consider a model with the disease as a phenotype, and two SNPs as
predictors (on covariates) as bellow:

pbat.m(AffectionStatus ~ NONE, y1, x1, fbat="gee",
distribution='categorical', offset='none')

But some error messages were returned:
Error in writeCommandStrMatch("distribution", distribution, c("default",  : 
  'distribution' can only take on the following values: 'default', 'jiang',
'murphy', 'naive', 'observed'.  You passed the invalid value 'categorical'.

Then I removed last two arguments 
pbat.m(AffectionStatus ~ NONE, y1, x1, fbat="gee")

This time, a box appeared on the console:
R for Windows GUI front-end has encountered a problem and needs to close.

2. I consider a model with the disease as a phenotype, and two covariates
(age, weigth) and two SNPs as predictors as bellow:

pbat.m(AffectionStatus ~ age + weight, y1, x1, fbat="gee")

The function had been running for a very long time and no output was
returned until I had to stop it.

Any help would be greatly appreciated. 

Thanks.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/R-package-pbatR-tp3667844p3667844.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] Colors in R

2011-07-13 Thread Trevino, Lisa
HI everyone,
I'm trying to assign colors to multiple lines in a graph. Problem is I don't 
want to type in as many colors as there are linesis there a way around 
this? In brief, I'm plotting the logratio for up to 60 samples and want a 
different color for each sample.  Here is the code I'm using now..

Any help is greatly appreciated..

Best

LT

data <- read.table("data.csv", header=T, sep=",", stringsAsFactors= F)

data$Pt <-as.numeric(data$Pt)
npts <- unique(data$Pt)

xrange = c(min(data$Coordinate), max(data$Coordinate))
yrange = c(min(data$Log2Ratio), max(data$Log2Ratio))



 colors 
<-c("red","blue","green","darkmagenta","darkgreen","darkorange","darkred","gold","midnightblue","seagreen1","tomato","slateblue","violet","purple4","palegreen","darkviolet","forestgreen","firebrick"...up
 to 60 colors)

labels <- c('a','b', 'c', 'd', 'e', up to 60 labels)

#add lines
for (i in 1:length(npts)) {
 color=colors[i]
 pt = data[data$Pt==npts[i],]; plot(pt$Coordinate, pt$Log2Ratio, type="l", 
lty=3,col=color, xlim=xrange, ylim=yrange); par(new=T)}

[[alternative HTML version deleted]]

__
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] Multiple line graphs

2011-07-07 Thread Trevino, Lisa
Thank you!

LT


On 7/7/11 3:46 PM, "Joshua Wiley"  wrote:

Hi lt2,

I would use the ggplot2 or lattice package.  It strikes me as more
effort to do in traditional graphics.  Anyway, here are some examples.
 Lattice is a very nice package, but I am not quite as familiar with
it, so my examples for it are not representative of its full power.

Cheers,

Josh


# Your data
dat <- read.table(textConnection("
Pt  Coordinate  Log2Ratio
1   34046382-0.023639869
1   341414370.016456776
1   34232498-0.027852121
1   34261900-0.167065347
2   34364856-0.182864057
2   34461485-0.228341688
2   349526941.90875531
3   341747051.312169128
3   342478331.381729262
3   343202731.218914649
3   343905450.992551194"), header = TRUE)
closeAllConnections()

require(ggplot2)
require(lattice)

 Solution using the ggplot2 package 
## Using colours by patient
ggplot(dat, aes(x = Coordinate, y = Log2Ratio, colour = factor(Pt))) +
 geom_line()

## Mapping Pt to type of line
ggplot(dat, aes(x = Coordinate, y = Log2Ratio)) +
 geom_line(aes(linetype = factor(Pt)))

## Nothing, but creating separate plots
ggplot(dat, aes(x = Coordinate, y = Log2Ratio)) +
 geom_line() +
 facet_grid(Pt ~ .)

 Solution using the lattice package 
## Colouring lines
xyplot(Log2Ratio ~ Coordinate, data = dat, group = Pt,
  type = "l", auto.key = list(points = FALSE, lines = TRUE))

## Condition on lines
xyplot(Log2Ratio ~ Coordinate | factor(Pt), data = dat, type = "l")


On Thu, Jul 7, 2011 at 9:38 AM, lt2  wrote:
> HI everyone, I'm just starting to get into graphing with R and I need to
> generate one graph that illustrates the pattern of gene expression for
> various patients. My data is in .csv format and is as follows and i'm
> showing below a portion of the data.
>
> Pt  Coordinate  Log2Ratio
> 1   34046382-0.023639869
> 1   341414370.016456776
> 1   34232498-0.027852121
> 1   34261900-0.167065347
> 2   34364856-0.182864057
> 2   34461485-0.228341688
> 2   349526941.90875531
> 3   341747051.312169128
> 3   342478331.381729262
> 3   343202731.218914649
> 3   343905450.992551194
>
> I can generate the multiple line graphs but i can't get the different colors
> per patient, nor do i know how to change the pattern of the line.
>
> Any ideas and help is greatly appreciated.
>
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Multiple-line-graphs-tp3652015p3652015.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.
>



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
https://joshuawiley.com/


[[alternative HTML version deleted]]

__
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] Derivative of a function

2011-06-29 Thread Lisa
Yes. I need to do implicit differentiation. After rearrangement, I got 

(x2 – x1) * b = log(1 / y - 1)

Take derivative of both sides with respect to y, I have

(x2 – x1) * b’[y] = - 1/y(1-y)

Since both (x2 – x1) and b’[y] are vectors, I cannot move (x2 – x1) to
RHS. This is why I posted my question here to see if there is some R
functions or some idea that can help me solve this problem. Thanks.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Derivative-of-a-function-tp3631814p3633947.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] Derivative of a function

2011-06-29 Thread Lisa
This is not a homework. I just want to see if there are some R functions or
some ideas I can borrow to solve my problem. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Derivative-of-a-function-tp3631814p3633071.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] Derivative of a function

2011-06-28 Thread Lisa
Dear all,

I just want to get the derivative of a function that looks like:

y = exp(x1*b) / (exp(x1*b) + exp(x2*b))

where y is a scalar, x1, x2, and b are vectors. I am going to take the
derivative of b with respect to y, but I cannot derive an expression in
which b is function of y. I know there is another way to get the similar
result, i.e., first take the derivative of y with respect to each element of
b, and then take its reciprocal. But it is not what I want. Could someone
please tell me how to solve this problem? Thank you in advance. 

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Derivative-of-a-function-tp3631814p3631814.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] RES: Recode numbers

2011-06-01 Thread Lisa
Thank you very much, Bill. Your script works very well.

--
View this message in context: 
http://r.789695.n4.nabble.com/Recode-numbers-tp3566395p3566847.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] RES: Recode numbers

2011-06-01 Thread Lisa
Thank you so much, Filipe. Your R script is what I am looking for. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Recode-numbers-tp3566395p3566818.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] Recode numbers

2011-06-01 Thread Lisa
Thank you, Duncan,

Here “a” has the length of 24, and “b” has the length of 20 with numbers
from 1 to 20 uniquely. I just want encode “a” from 1 to 20 based on “a”
current order using “b”. So, a1[1] = b[1] = 1
a1[2] = b[2] = 5
a1[3] = a1[4] = b[3] = 8 (since third and fourth numbers are the same in
“a”)
a1[5] = a1[6] = b[4] = 9
a1[7] = b[5] = 14
a1[8] = b[6] = 20
a1[9] = b[7] = 3
a1[10] = a1[11] = b[8] = 10
...
a1[23] = b[19] = 15
a1[24] = b[20] = 19


--
View this message in context: 
http://r.789695.n4.nabble.com/Recode-numbers-tp3566395p3566681.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] Recode numbers

2011-06-01 Thread Lisa
Thank you for your help, Pete. I tried b[a], but it is not a1. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Recode-numbers-tp3566395p3566534.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] Recode numbers

2011-06-01 Thread Lisa
Dear all,

I have two sets of numbers that look like

a <- c(1, 2, 3, 3, 4, 4, 5, 6, 1, 2, 2, 3, 1, 2, 1, 2, 3, 3, 4, 5, 1, 2, 3,
4)

b <- c(1, 5, 8, 9, 14, 20, 3, 10, 12, 6, 16, 7, 11, 13, 17, 18, 2, 4, 15,
19)

I just want to use “b” to encode “a” so that “a” looks like

a1<- c(1, 5, 8, 8, 9, 9, 14, 20, 3, 10, 10, 12, 6, 16, 7, 11, 13, 13, 17,
18, 2, 4, 15, 19)

Does anyone have a suggestion how to deal with this? Thank you in advance.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Recode-numbers-tp3566395p3566395.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] Arrange a multi-level list to a one-level list

2011-05-27 Thread Lisa
Hi, Phil, 

Yes. That's what I am looking for. Thank you so much.

Lisa

--
View this message in context: 
http://r.789695.n4.nabble.com/Arrange-a-multi-level-list-to-a-one-level-list-tp3556500p3556601.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] Arrange a multi-level list to a one-level list

2011-05-27 Thread Lisa
Dear all,

I just want to arrange a multi-level list to a one-level list. For example:

x <- list(list(matrix(sample(c(0,1), 4, replace = T), 2),
matrix(sample(c(2,3), 4, replace = T), 2)),
list(matrix(sample(c(0,1), 6, replace = T), 2), matrix(sample(c(2,3), 6,
replace = T), 2)))

> x
[[1]]
[[1]][[1]]
 [,1] [,2]
[1,]11
[2,]00

[[1]][[2]]
 [,1] [,2]
[1,]32
[2,]33


[[2]]
[[2]][[1]]
 [,1] [,2] [,3]
[1,]100
[2,]010

[[2]][[2]]
 [,1] [,2] [,3]
[1,]233
[2,]333

If I do this work one time, I will arrange it like this:
 
c(x[[1]], x[[2]]) # Only consider the first level of the list.

[[1]]
 [,1] [,2]
[1,]11
[2,]00

[[2]]
 [,1] [,2]
[1,]32
[2,]33

[[3]]
 [,1] [,2] [,3]
[1,]100
[2,]010

[[4]]
 [,1] [,2] [,3]
[1,]233
[2,]333

But when I repeat this work many times and the levels will change each time
in a loop, how can I pass the arguments to c()? For example, in the first
iteration, the first level of a list is 3, in the second iteration, the
first level of a list is 5? ….

Any help would be greatly appreciated. 

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Arrange-a-multi-level-list-to-a-one-level-list-tp3556500p3556500.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] Suppress intermediate results on console

2011-05-26 Thread Lisa
Thanks for your comments and suggestion. I didn’t show all my own function
here because it has many lines. “x” is the results of another function. I am
calling summary because I want to extract some values from the results. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Suppress-intermediate-results-on-console-tp3553276p3553405.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] Suppress intermediate results on console

2011-05-26 Thread Lisa
Dear all,

I have a question about how to suppress intermediate results in a function
on console. For example, I will use summary() in my own function that looks
like:

myfunction <- function(…)
{
  …
  Summary(x)
  …
}

Then myfunction() will print “x” on console that is intermediate result and
doesn’t need showing. 

Does someone have any idea or any suggestion? Thank you in advance.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Suppress-intermediate-results-on-console-tp3553276p3553276.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] Order a matrix

2011-05-24 Thread Lisa
Hi, Bill,

Thank you for your help. Your R script works very well. 

Lisa

--
View this message in context: 
http://r.789695.n4.nabble.com/Order-a-matrix-tp3547923p3548017.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] Order a matrix

2011-05-24 Thread Lisa
Dear all,

I just want to order a matrix using several columns in a matrix. For
example:

x <- matrix(sample(c(1:5), 60, replace = T), 10, 6).

If I order the matrix by the first two columns, I will do it like this:
 
x[order(x[, 1], x[, 2]), ]. 

But when I repeat this work many times and the columns will change each time
in a simulation study, how can I assign the arguments of order()? For
example, in the first iteration, the columns needing to order is the first
two columns, in the second iteration, the columns needing to order is the
first, second, and fourth column? ….

I would appreciate any help on this question. Thanks a lot.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Order-a-matrix-tp3547923p3547923.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] Line feed for a long character string

2011-05-11 Thread Lisa
Hi, Duncan,

On your and  William Dunlap’s suggestion, I tried this:

cat(sep="\n", strwrap("my long character string")),
 
and it works very well. Thanks so much for your help.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Line-feed-for-a-long-character-string-tp3515824p3516426.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] Line feed for a long character string

2011-05-11 Thread Lisa
Dear all,

Does anyone know how to make a line feed automatically based on the width of
console window? For example, when you cat() a long character string just
like this:

cat("Seminar series is an opportunity for students to learn about ongoing
researches in the field of mathematics, computer science, physics,
chemistry, and some other related programs. Students must complete a seminar
attendance form and return to their mentors.\n")

In my computer, about half of the string is displayed with a symbol “$”at
the end that looks like this:

> cat("Seminar series is an opportunity for students to learn about ongoing
> researches in the field of mathematics, computer science, physics,
> chemistry, a$

Any help will be appreciated!

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Line-feed-for-a-long-character-string-tp3515824p3515824.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] Line numbers of scan(0

2011-04-28 Thread Lisa
I am trying to write a function to check unusual values in my datasets and
correct them. As some R users suggested, I try to use readline() and scan()
in my function. Suppose there are several unusual values in a dataset. I
want to change the line numbers in scan() to something like: unusual value
1, unusual value 2 and so on. I think this can make the correction much
easier. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Line-numbers-of-scan-0-tp3482314p3482802.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] Line numbers of scan(0

2011-04-28 Thread Lisa
Dear all,

Does everyone know how to change the line numbers of scan()? For example,

> scan(n = 3)
1: 4
2: 6
3: 9
Read 3 items
[1] 4 6 9

I just want to change the line numbers 1, 2, and 3 to, say a, b, and c that
look like this:

> scan(n = 3)
a: 4
b: 6
c: 9
Read 3 items
[1] 4 6 9

Any help will be appreciated. 

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Line-numbers-of-scan-0-tp3482314p3482314.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] Pause the execution of a function

2011-04-28 Thread Lisa
Hi, Rolf,

Thank you for your help. I am trying to use readline() and I have a question
about the maximum length of prompt string. The R help on readline() says: 

“The prompt string will be truncated to a maximum allowed length, normally
256 chars (but can be changed in the source code).”

I don’t know how to change the source code. Could you please help how to get
this done? Thanks.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Pause-the-execution-of-a-function-tp3478535p3482192.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] Pause the execution of a function

2011-04-27 Thread Lisa
Thanks. I will try them.

--
View this message in context: 
http://r.789695.n4.nabble.com/Pause-the-execution-of-a-function-tp3478535p3479240.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] Pause the execution of a function

2011-04-27 Thread Lisa
Dear all,

I am trying to write a script to pause the execution of a function and
provide some additional commands to the function and then continue execution
of the function. For example, when my function detects a wrong number in a
dataset, the function pauses automatically and returns information on the
screen:

“There is a wrong number in the dataset. Would you like to correct it? ”

If I input “yes” from the keyboard and hit the enter key, the function asks
again:

“What is the correct number?”

After inputting a correct number from the keyboard and hitting the enter
key, the function continues to execute.

Can anybody please help how to get this done? Thanks a lot in advance

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Pause-the-execution-of-a-function-tp3478535p3478535.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] Tell the difference between characters

2011-04-26 Thread Lisa
Yes. That is what I want. Thank you very much.

Lisa

--
View this message in context: 
http://r.789695.n4.nabble.com/Tell-the-difference-between-characters-tp3476130p3476288.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] Tell the difference between characters

2011-04-26 Thread Lisa
Thanks a lot.

Lisa

--
View this message in context: 
http://r.789695.n4.nabble.com/Tell-the-difference-between-characters-tp3476130p3476352.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] Tell the difference between characters

2011-04-26 Thread Lisa
Dear all,

I just want to determine if the characters in a character string are the
same or not. For example,

temp <- c("aa", "aA", "ab")

How do I determine the first one have the two same “a”, and the second and
third have the different characters? Thanks in advance.

Lisa
 


--
View this message in context: 
http://r.789695.n4.nabble.com/Tell-the-difference-between-characters-tp3476130p3476130.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] Factor function

2011-04-26 Thread Lisa
Thank you so much!

Lisa

--
View this message in context: 
http://r.789695.n4.nabble.com/Factor-function-tp3473984p3475549.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] Factor function

2011-04-25 Thread Lisa
Thank you for your help. Your R code works well.

Lisa

--
View this message in context: 
http://r.789695.n4.nabble.com/Factor-function-tp3473984p3474196.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] Factor function

2011-04-25 Thread Lisa
Thank you for your reply again. I really know that NA is not "NA". I just
want to figure out how to remove "NA" from the levels. Thanks again.

--
View this message in context: 
http://r.789695.n4.nabble.com/Factor-function-tp3473984p3474127.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] Factor function

2011-04-25 Thread Lisa
Did you see the data frame "d"? Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/Factor-function-tp3473984p3474065.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] Factor function

2011-04-25 Thread Lisa
Dear All,

I just want to remove “NA” from the levels of a factor.  For example:

d<-data.frame(matrix(c("ww","ww","xx","yy","ww","yy","xx","yy","NA"),
ncol=3, byrow=TRUE))

> factor(d[, 3], exclude=NA)
[1] xx yy NA
Levels: NA xx yy

But “NA” is still listed in the levels. How can I solve this problem? Thanks
in advance.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Factor-function-tp3473984p3473984.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] Select subset of data

2011-03-29 Thread Lisa
Thank you for your kind help. Your R code works very well.

--
View this message in context: 
http://r.789695.n4.nabble.com/Select-subset-of-data-tp3416012p3416307.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 subset of data

2011-03-29 Thread Lisa
Dear All,

I have a dataset that looks like this:

   group subject result v4 v5 
1  1   1  0  1  0 
2  1   2  1  0  0 
3  1   3  0  0  0 
4  1   4  1  0  0 
5  2   1  0  1  1 
6  2   2  0  0  1 
7  2   3  0  1  1 
8  3   1  0  1  0 
9  3   2  0  0  1 
10 3   3  1  0  0 
11 3   4  0  1  0 
12 4   1  1  0  0 
13 4   2  1  1  0 
14 4   3  0  0  1 
15 4   4  0  0  0 
16 4   5  1  0  1
……

I only show 4 groups here. There are several subjects within each group. I
want to select some groups in which for the firs two subjects, the results
are equal to 0, and for the other subjects, only one has the result being
equal to 1. So, for the data above, only the group 3 satisfies these
conditions. Therefore, the new dataset is:

   group subject result v4 v5 
8   3 1  01  0 
9   3 2  00  1 
10 3 3  10  0 
11 3 4  01  0 

Can anybody please help how to get this done? Your help would be greatly
appreciated. 

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Select-subset-of-data-tp3416012p3416012.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] Randomly generating data

2011-03-21 Thread Lisa
Hi, everybody,

I have a problem and need your help.
There are two columns that look like this:

 [1,] "t"  "f" 
 [2,] "f"  "t" 
 [3,] "t"  "f" 
 [4,] "t"  "t" 
 [5,] "f"  "f" 
 
I just want to generate the third column based on these two columns. First,
I randomly choose one of the two columns, say, the first column. So, the
first character of the third column is “t” that looks like this:

 [1,] "t"  "f"  "t"
 [2,] "f"  "t" 
 [3,] "t"  "f" 
 [4,] "t"  "t" 
 [5,] "f"  "f" 
 
Second, I determine the second character of the third column with an
additional Bernoulli trial with a probability, for example, rbinom(1, 1,
0.3). If the random generation in R is 0, we keep "f", the second character
in the first column because the first column has been chosen in the first
step, while if the random generation in R is 1, we choose "t" instead, the
second character in the second column.

Third, I determine the third character of the third column with a Bernoulli
trial but a different probability, for example, rbinom(1, 1, 0.7). 

Repeat these processes…

How can I do this efficiently if there are more than thousand records
(rows)?  Can anybody please help how to get this done? Thanks a lot in
advance

Lisa



--
View this message in context: 
http://r.789695.n4.nabble.com/Randomly-generating-data-tp3394250p3394250.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] Arguments of a function

2011-03-18 Thread Lisa
Thank you very much!

--
View this message in context: 
http://r.789695.n4.nabble.com/Arguments-of-a-function-tp3387643p3388615.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] Arguments of a function

2011-03-18 Thread Lisa
Hi, everybody,

I just want to pass arguments to a function as below:

range <- c(0.1, 0.5)

runif(1, range)

But it doesn’t work. 

Does anyone have any suggestions to offer? 

Thanks.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Arguments-of-a-function-tp3387643p3387643.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 columns of dataset

2010-12-04 Thread Lisa

Your R script works very well. Thank you very much.

Lisa
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Add-columns-of-dataset-tp3071722p3072513.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 columns of dataset

2010-12-03 Thread Lisa

Dear all,

I have a dataset that looks like 

id  var1  var2  var4  var7  var8 
10.0   0.10.30.90.0
20.4   0.60.00.00.2
30.0   0.00.00.80.7

Some columns are missed, for example, here the fourth (var3), sixth(var5)
and seventh (var6) columns. I want to first determine which columns are
missed in a huge dataset and then add the missed columns with the values of
zeros that looks like

id  var1  var2   var3  var4  var5  var6  var7  var8 
10.0   0.1 0.00.3   0.00.0   0.90.0
20.4   0.6 0.00.0   0.00.0   0.00.2
30.0   0.0 0.00.0   0.00.0   0.80.7

Can anybody please help how to get this done? Thanks a lot in advance

Lisa

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Add-columns-of-dataset-tp3071722p3071722.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 transformation

2010-01-25 Thread Lisa

Thank you so much.

Lisa
-- 
View this message in context: 
http://n4.nabble.com/Data-transformation-tp1289899p1289915.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 transformation

2010-01-25 Thread Lisa

Dear all,

I  have a dataset that looks like this:

x <- read.table(textConnection("col1 col2 
3 1 
2 2 
4 7 
8 6 
5 10"), header=TRUE) 

I want to rewrite it as below:

var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
1 0 1  0 0 0 0 0  0  0
0 2 0  0 0 0 0 0  0  0
0 0 0  1 0 0 1 0  0  0
0 0 0  0 0 1 0 1  0  0
0 0 0  0 1 0 0 0  0  1

Can anybody please help how to get this done? Your help would be greatly
appreciated. 

Lisa 

-- 
View this message in context: 
http://n4.nabble.com/Data-transformation-tp1289899p1289899.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 components of a list

2010-01-25 Thread Lisa

It works well. Thank you very much.

Lisa
-- 
View this message in context: 
http://n4.nabble.com/Delete-components-of-a-list-tp1289732p1289745.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] Delete components of a list

2010-01-25 Thread Lisa

Dear all,

I have a question about deleting components of a list. For example, I have a
list that looks like this:

[[1]]
var1 var2 var3
   134 
   221   

[[2]]
var1 var2 var3
   251 
   217   

[[3]]
var1 var2 var3
   167 
   384   

How to delete, say, the first columns of the list or the second rows? Thank
in advance.

Lisa

-- 
View this message in context: 
http://n4.nabble.com/Delete-components-of-a-list-tp1289732p1289732.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] Arguments of a function

2010-01-08 Thread Lisa

That's what I want. Thank you so much. 
Lisa


Henrique Dallazuanna wrote:
> 
> Try this:
> 
> my.f <- function(a, b) {
>   x1 <- 2 * 3
>   x2 <- 3 / 6
>   x3 <- 4 * 4 / 5 - sqrt(2)
>   y <- get(deparse(substitute(a))) + get(deparse(substitute(b)))
>   return(y)
> }
> 
> my.f(x1, x2)
> 
> On Fri, Jan 8, 2010 at 4:15 PM, Lisa  wrote:
>>
>> Dear all,
>>
>> I have a question about how to set arguments in my own function. For
>> example, I have a function that looks like this:
>>
>> my.f <- function(a = x1, b = x2)
>> {
>>   x1 = equation 1
>>   x2 = equation 2
>>   x3 = equation 3
>>   y = a + b
>> }
>>
>> x1, x2, and x3 are temporary variables (intermediate results) calculated
>> from other variables within the funciton. I want to use two of these
>> three
>> variables to calculate y, and write R script as below:
>>
>> my.f(a = x1, b = x2)
>>
>> or
>>
>> my.f(a = x2, b = x3)
>>
>> The error information shows that: “objects 'x1', 'x2', or 'x3' not
>> found”.
>>
>> Can anybody help me solve this problem? Thanks in advance.
>>
>> Lisa
>>
>> --
>> View this message in context:
>> http://n4.nabble.com/Arguments-of-a-function-tp1009883p1009883.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.
>>
> 
> 
> 
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Arguments-of-a-function-tp1009883p1009932.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] Arguments of a function

2010-01-08 Thread Lisa

Dear all,

I have a question about how to set arguments in my own function. For
example, I have a function that looks like this:

my.f <- function(a = x1, b = x2)
{
   x1 = equation 1
   x2 = equation 2
   x3 = equation 3
   y = a + b   
}

x1, x2, and x3 are temporary variables (intermediate results) calculated
from other variables within the funciton. I want to use two of these three
variables to calculate y, and write R script as below:

my.f(a = x1, b = x2)
 
or 

my.f(a = x2, b = x3)

The error information shows that: “objects 'x1', 'x2', or 'x3' not found”. 

Can anybody help me solve this problem? Thanks in advance.

Lisa

-- 
View this message in context: 
http://n4.nabble.com/Arguments-of-a-function-tp1009883p1009883.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 replacement

2010-01-05 Thread Lisa

Thank you for your kind help. Your R script works well.

Lisa



Dieter Menne wrote:
> 
> 
> 
> Lisa wrote:
>> 
>> I have a dataset that looks like this: 
>> 
>>> data
>>  idcode1code2 
>> 1 114 
>> 2 123 
>> 3 244 
>> ..
>> 
>> I want to change some numbers in the columns of “code1” and “code2” based
>> on “indx” as below
>> 
>>> indx
>> [[1]]
>> code 
>> 1  1 
>> 2  3 
>> 3  4 
>> For example,  for the first ten records (rows) of my dataset, I want to
>> change 2 to 3, 3 to 4, 4 to 6, and 5 to 8 in both “code1” and “code2”,
>> while for the last ten records, I want to change 3 to 4 and 4 to 6.
>> 
>> 
> 
> You might check for "recode", for example in package car, or for
> "transform". You could also do it the quick and dirty way, good to learn
> indexing. Be careful if you have NA in your data, or data out of the
> recode range.
> 
> Dieter
> 
> 
> data = data.frame(code1=sample(1:5,10,TRUE),code2=sample(1:5,10,TRUE))
> data =
> rbind(data,data.frame(code1=sample(1:4,10,TRUE),code2=sample(1:4,10,TRUE)))
> 
> # The recode table as  in your example
> #indx = list(data.frame(code=c(1,3,4,6,8)),data.frame(code=c(1,2,4,6)))
> 
> #easier to read
> recode1 = c(1,3,4,6,8)
> recode2 = c(1,2,4,6)
> 
> data$code1T[1:10] = recode1[data$code1[1:10]]
> data$code2T[1:10] = recode1[data$code2[1:10]]
> 
> data$code1T[11:20] = recode2[data$code1[11:20]]
> data$code2T[11:20] = recode2[data$code2[11:20]]
> 
> 
> 
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Data-replacement-tp999060p999342.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 replacement

2010-01-05 Thread Lisa

Dear all,

I have a question and need your help.

I have a dataset that looks like this: 

> data
 idcode1code2 
1 114 
2 123 
3 244 
4 315 
5 324 
6 411 
7 434 
8 643 
9 622 
10752 
11114 
12132 
13344 
14414 
15432 
16511 
17543 
18714 
19723 
20811 

I want to change some numbers in the columns of “code1” and “code2” based on
“indx” as below

> indx
[[1]]
code 
1  1 
2  3 
3  4 
4  6 
5  8 
[[2]]
code 
1  1 
2  2 
3  4 
4  6 

For example,  for the first ten records (rows) of my dataset, I want to
change 2 to 3, 3 to 4, 4 to 6, and 5 to 8 in both “code1” and “code2”, while
for the last ten records, I want to change 3 to 4 and 4 to 6.

Can anybody please help how to get this done? Thanks a lot in advance

Lisa

-- 
View this message in context: 
http://n4.nabble.com/Data-replacement-tp999060p999060.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 double quotation marks

2009-12-29 Thread Lisa

Your script works well. Thank you very mcuh.

Lisa



Nutter, Benjamin wrote:
> 
> It seems from your example that you're assuming all of the vectors have
> the same length.  If this is the case, then a data.frame might be your
> friend.
> 
>> df <- data.frame(
> v1 = c(0, 1, 0),
> v2 = c(1, 1, 0),
> v3 = c(2, 1, 2),
> v4 = c(2, 2, 1),
> v5 = c(0, 1, 1) )
> 
>> x <- 5
> 
>> get.var <- c("v1", "v2", paste("v", x, sep=""))
> 
>> df[, get.var]
> 
> Or, if you know your variables in the data.frame will be named
> sequentially
> 
>> df[, c(1, 2, x)]
> 
> 
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Lisa
> Sent: Tuesday, December 29, 2009 3:55 PM
> To: r-help@r-project.org
> Subject: Re: [R] Remove double quotation marks
> 
> 
> Thank you for your help. But here I just want to combine some vectors by
> column based on the numbers determined by other R script. 
> 
> For example, I have five vectors:
> 
> v1 <- c(0, 1, 0)
> v2 <- c(1, 1, 0)
> v3 <- c(2, 1, 2)
> v4 <- c(2, 2, 1)
> v5 <- c(0, 1, 1)
> 
> If I am going to combine the first two vectors, and one more other
> vector determined by my other R script, say, vector 5.  Then my R script
> is
> 
> x <- 5
> cbind(v1, v2, paste("v", x, sep = ""))
> 
> The output is
> 
>  v1  v2  
> [1,] "0" "1" "v5"
> [2,] "1" "1" "v5"
> [3,] "0" "0" "v5"
> 
> This is not what I want. I want to get this:
> 
>  v1  v2  v5 
> [1,]  0   1   0
> [2,]  1   1   1
> [3,]  0   0   1
> 
> Can you give me further suggestions or comments? Thanks a lot.
> 
> Lisa
> 
> 
> 
> Barry Rowlingson wrote:
>> 
>> On Tue, Dec 29, 2009 at 6:31 PM, Lisa  wrote:
>>>
>>> Thank you for your reply. But in the following case, "cat()" or
> "print()"
>>> doesn't work.
>>>
>>> data.frame(cbind(variable 1, variable 2, cat(paste("variable", x), 
>>> "\n"))), where x is a random number generated by other R script.
>>>
>>> Lisa
>> 
>>  Yes, because you are Doing It Wrong. If you have data that is indexed
> 
>> by an integer, don't store it in variables called variable1, variable2
> 
>> etc, because very soon you will be posting a message to R-help that is
> 
>> covered in the R FAQ...
>> 
>>  Store it in a list:
>> 
>>  v = list()
>>  v[[1]] = c(1,2,3,4,5)
>>  v[[2]] = c(4,5,6,7,8,9,9,9)
>> 
>> then you can do v[[i]] for integer values of i.
>> 
>> If you really really must get values of variable by name, perhaps 
>> because someone has given you a data file with variables called
>> variable1 to variable99, then use the paste() construction together 
>> with the 'get' function:
>> 
>> [ not tested, but should work ]
>> 
>>  > v1="99"
>>  > v2="102"
>>  > i=2
>>  > get(paste("v",i,sep=""))
>>  [1] 102
>> 
>> Barry
>> 
>> __
>> 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.
>> 
>> 
> 
> --
> View this message in context:
> http://n4.nabble.com/Remove-double-quotation-marks-tp990502p990586.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.
> 
> ===
> 
> P Please consider the environment before printing this e-mail
> 
> Cleveland Clinic is ranked one of the top hospitals
> in America by U.S.News & World Report (2009).  
> Visit us online at http://www.clevelandclinic.org for
> a complete listing of our services, staff and
> locations.
> 
> 
> Confidentiality Note:  This message is intended for use\...{{dropped:13}}
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Remove-double-quotation-marks-tp990502p990599.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 double quotation marks

2009-12-29 Thread Lisa

Thanks. I also need column name "v5".

Lisa



jholtman wrote:
> 
> ?get
> 
> something like:
> 
>> v1 <- c(0, 1, 0)
>> v2 <- c(1, 1, 0)
>> v3 <- c(2, 1, 2)
>> v4 <- c(2, 2, 1)
>> v5 <- c(0, 1, 1)
>> x <- 5
>> cbind(v1, v2, get(paste('v', x, sep='')))
>  v1 v2
> [1,]  0  1 0
> [2,]  1  1 1
> [3,]  0  0 1
>>
> 
> 
> On Tue, Dec 29, 2009 at 3:54 PM, Lisa  wrote:
> 
>>
>> Thank you for your help. But here I just want to combine some vectors by
>> column based on the numbers determined by other R script.
>>
>> For example, I have five vectors:
>>
>> v1 <- c(0, 1, 0)
>> v2 <- c(1, 1, 0)
>> v3 <- c(2, 1, 2)
>> v4 <- c(2, 2, 1)
>> v5 <- c(0, 1, 1)
>>
>> If I am going to combine the first two vectors, and one more other vector
>> determined by my other R script, say, vector 5.  Then my R script is
>>
>> x <- 5
>> cbind(v1, v2, paste("v", x, sep = ""))
>>
>> The output is
>>
>> v1  v2
>> [1,] "0" "1" "v5"
>> [2,] "1" "1" "v5"
>> [3,] "0" "0" "v5"
>>
>> This is not what I want. I want to get this:
>>
>> v1  v2  v5
>> [1,]  0   1   0
>> [2,]  1   1   1
>> [3,]  0   0   1
>>
>> Can you give me further suggestions or comments? Thanks a lot.
>>
>> Lisa
>>
>>
>>
>> Barry Rowlingson wrote:
>> >
>> > On Tue, Dec 29, 2009 at 6:31 PM, Lisa  wrote:
>> >>
>> >> Thank you for your reply. But in the following case, “cat()” or
>> “print()”
>> >> doesn’t work.
>> >>
>> >> data.frame(cbind(variable 1, variable 2, cat(paste("variable", x),
>> >> "\n"))),
>> >> where x is a random number generated by other R script.
>> >>
>> >> Lisa
>> >
>> >  Yes, because you are Doing It Wrong. If you have data that is indexed
>> > by an integer, don't store it in variables called variable1, variable2
>> > etc, because very soon you will be posting a message to R-help that is
>> > covered in the R FAQ...
>> >
>> >  Store it in a list:
>> >
>> >  v = list()
>> >  v[[1]] = c(1,2,3,4,5)
>> >  v[[2]] = c(4,5,6,7,8,9,9,9)
>> >
>> > then you can do v[[i]] for integer values of i.
>> >
>> > If you really really must get values of variable by name, perhaps
>> > because someone has given you a data file with variables called
>> > variable1 to variable99, then use the paste() construction together
>> > with the 'get' function:
>> >
>> > [ not tested, but should work ]
>> >
>> >  > v1="99"
>> >  > v2="102"
>> >  > i=2
>> >  > get(paste("v",i,sep=""))
>> >  [1] 102
>> >
>> > Barry
>> >
>> > __
>> > 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<http://www.r-project.org/posting-guide.html>
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://n4.nabble.com/Remove-double-quotation-marks-tp990502p990586.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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem that you are trying to solve?
> 
>   [[alternative HTML version deleted]]
> 
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Remove-double-quotation-marks-tp990502p990591.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 double quotation marks

2009-12-29 Thread Lisa

Thank you for your help. But here I just want to combine some vectors by
column based on the numbers determined by other R script. 

For example, I have five vectors:

v1 <- c(0, 1, 0)
v2 <- c(1, 1, 0)
v3 <- c(2, 1, 2)
v4 <- c(2, 2, 1)
v5 <- c(0, 1, 1)

If I am going to combine the first two vectors, and one more other vector
determined by my other R script, say, vector 5.  Then my R script is

x <- 5
cbind(v1, v2, paste("v", x, sep = ""))

The output is

 v1  v2  
[1,] "0" "1" "v5"
[2,] "1" "1" "v5"
[3,] "0" "0" "v5"

This is not what I want. I want to get this:

 v1  v2  v5 
[1,]  0   1   0
[2,]  1   1   1
[3,]  0   0   1

Can you give me further suggestions or comments? Thanks a lot.

Lisa



Barry Rowlingson wrote:
> 
> On Tue, Dec 29, 2009 at 6:31 PM, Lisa  wrote:
>>
>> Thank you for your reply. But in the following case, “cat()” or “print()”
>> doesn’t work.
>>
>> data.frame(cbind(variable 1, variable 2, cat(paste("variable", x),
>> "\n"))),
>> where x is a random number generated by other R script.
>>
>> Lisa
> 
>  Yes, because you are Doing It Wrong. If you have data that is indexed
> by an integer, don't store it in variables called variable1, variable2
> etc, because very soon you will be posting a message to R-help that is
> covered in the R FAQ...
> 
>  Store it in a list:
> 
>  v = list()
>  v[[1]] = c(1,2,3,4,5)
>  v[[2]] = c(4,5,6,7,8,9,9,9)
> 
> then you can do v[[i]] for integer values of i.
> 
> If you really really must get values of variable by name, perhaps
> because someone has given you a data file with variables called
> variable1 to variable99, then use the paste() construction together
> with the 'get' function:
> 
> [ not tested, but should work ]
> 
>  > v1="99"
>  > v2="102"
>  > i=2
>  > get(paste("v",i,sep=""))
>  [1] 102
> 
> Barry
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Remove-double-quotation-marks-tp990502p990586.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 double quotation marks

2009-12-29 Thread Lisa

Thank you for your reply. But in the following case, “cat()” or “print()”
doesn’t work.

data.frame(cbind(variable 1, variable 2, cat(paste("variable", x), "\n"))),
where x is a random number generated by other R script.

Lisa 



Duncan Murdoch wrote:
> 
> On 29/12/2009 1:16 PM, Lisa wrote:
>> Dear All,
>> 
>> I am not sure how to remove double quotation marks in a string, e.g.,
>> paste("variable", 1). Can anybody please help me solve it? Thank you in
>> advance.
> 
> I think you need to tell us what is wrong with what you get from that. 
> When I look at the result:
> 
>  > cat(paste("variable", 1), "\n")
> variable 1
> 
> I see no quotation marks.  (If you use print() you'll see some, but they 
> aren't part of the string, they are just used in the default display by 
> print().)
> 
> Duncan Murdoch
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Remove-double-quotation-marks-tp990502p990516.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 double quotation marks

2009-12-29 Thread Lisa

Dear All,

I am not sure how to remove double quotation marks in a string, e.g.,
paste("variable", 1). Can anybody please help me solve it? Thank you in
advance.

Lisa
-- 
View this message in context: 
http://n4.nabble.com/Remove-double-quotation-marks-tp990502p990502.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.


  1   2   >