Re: [R] Confirmatory Factor Analysis

2021-11-26 Thread Pat Malone via R-help
In this particular case, lavaan  has a dedicated forum with lots of helpful
folks at https://groups.google.com/g/lavaan

On Fri, Nov 19, 2021 at 8:28 PM Bert Gunter  wrote:

> Please read the posting guide linked below, which says:
>
> "Questions about statistics: The R mailing lists are primarily
> intended for questions and discussion about the R software. However,
> questions about statistical methodology are sometimes posted. If the
> question is well-asked and of interest to someone on the list, it may
> elicit an informative up-to-date answer."
>
> Also note:
>
> "For questions about functions in standard packages distributed with R
> (see the FAQ Add-on packages in R), ask questions on R-help.
> If the question relates to a contributed package , e.g., one
> downloaded from CRAN, try contacting the package maintainer first. You
> can also use find("functionname") and
> packageDescription("packagename") to find this information. Only send
> such questions to R-help or R-devel if you get no reply or need
> further assistance. This applies to both requests for help and to bug
> reports."
>
> So do not be surprised if you do not get a response here. Cross Validated,
> i.e.
> stats.stackexchange.com
> *might* be a better alternative.
>
> Cheers,
> Bert Gunter
>
>
> On Fri, Nov 19, 2021 at 4:40 PM AbouEl-Makarim Aboueissa
>  wrote:
> >
> >  Dear All:
> >
> >
> >
> > I am conducting a Confirmatory Factor Analysis (CFA) for the attached
> data.
> > Here is what I did. please see below
> >
> > I do need your help with the structure of the model. I believe that what
> I
> > used is the correlated CFA model. If I am wrong, please fix me. I need
> your
> > help with the structure of the CFA uncorrelated model.
> >
> >
> >
> > Thank you very much for your help in advance
> >
> >
> >
> > Abou
> >
> >
> >
> >
> >
> > datacfa<-read.table("G:/data_for_R.txt", header=TRUE)
> >
> > head(datacfa)
> >
> >
> >
> > install.packages("lavaan")
> >
> > library(lavaan)
> >
> >
> >
> > install.packages("semPlot")
> >
> > library(semPlot)
> >
> >
> >
> > install.packages("parameters")
> >
> > library(parameters)
> >
> >
> >
> >  model structure
> >
> >
> >
> > CAF.Factors <- 'Factor1 =~ X11 + X13 + X14 + X15 + X17
> >
> > Factor2 =~ X6 + X7 + X12 + X16 + X19
> >
> >  Factor3 =~ X9 + X18 + X21
> >
> >  Factor4 =~ X19 + X20 + X22'
> >
> >
> >
> > fourfactors.model.a <- cfa(CAF.Factors, data=datacfa,std.lv=TRUE)
> >
> >
> >
> > summary(fourfactors.model.a, fit.measures=TRUE,standardized=TRUE)
> >
> >
> >
> > semPaths(fourfactors.model.a, ncharNodes = 0, style = "lisrel", rotation
> =
> > 2)
> >
> >
> >
> > #  model_parameters(fourfactors.model.a)
> >
> >
> >
> > model_parameters(fourfactors.model.a, standardize = TRUE)
> >
> >
> > __
> >
> >
> > *AbouEl-Makarim Aboueissa, PhD*
> >
> > *Professor, Statistics and Data Science*
> > *Graduate Coordinator*
> >
> > *Department of Mathematics and Statistics*
> > *University of Southern Maine*
> > __
> > 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.
>


-- 

*Patrick S. Malone, PhD*
Sr Research Statistician, FAR HARBΦR
+1 803.553.4181  |  pat@   |  farharbor.com
*This message may contain confidential information; if you are not the
intended recipient please notify the sender and delete the message.*

[[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 cases on predictive maintenance

2016-04-04 Thread Norman Pat
Hi Team,
  Can you please suggest me some good cases where we can use
R programming to tackle predictive maintenance problems

Many thanks

[[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] R how to find outliers and zero mean columns?

2016-03-30 Thread Norman Pat
Hi Jim,
Thanks for your reply. I know these basic stuffs in R.

But I want to know let say you have a data frame X with 300 features.
>From that 300 features I need to pullout the names of each feature
that has zero values for all the observations in that sample.

Here I am looking for a package or a function to do that.

And how do I know whether there are abnormal values for each feature. Let
say
I have 300 features and 10 observations. It is hard to look everything
in the excel file. Instead of that I am looking for a package that does the
work.

I hope you understood.

Thanks a lot

Cheers


On Thu, Mar 31, 2016 at 1:13 PM, Jim Lemon  wrote:

> Hi Norman,
> To check whether all values of an object (say "x") fulfill a certain
> condition (==0):
>
> all(x==0)
>
> If your object (X) is indeed a data frame, you can only do this by
> column, so if you want to get the results:
>
> X<-data.frame(A=c(0,1:10),B=c(0,2:10,9),
>  C=c(0,-1,3:11),D=rep(0,11))
> all_zeros<-function(x) return(all(x==0))
> which_cols<-unlist(lapply(X,all_zeros))
>
> If your data frame (or a subset) contains all numeric values, you can
> finesse the problem like this:
>
> which_rows<-apply(as.matrix(X),1,all_zeros)
>
> What you get is a list of logical (TRUE/FALSE) values from lapply, so
> it has to be unlisted to get a vector of logical values like you get
> with "apply".
>
> You can then use that vector to index (subset) the original data frame
> by logically inverting it with ! (NOT):
>
> X[,!which_cols]
> X[!which_rows,]
>
> Your "outliers" look suspiciously like missing values from certain
> statistical packages. If you know the values you are looking for, you
> can do something like:
>
> NA9<-X==9
>
> and then "remove" them by replacing those values with NA:
>
> X[NA9]<-NA
>
> Be aware that all these hackles (diminutive of hacks) are pretty
> specific to this example. Also remember that if this is homework, your
> karma has just gone down the cosmic sinkhole.
>
> Jim
>
>
> On Thu, Mar 31, 2016 at 9:56 AM, Norman Pat  wrote:
> > Hi team
> >
> > I am new to R so please help me to do this task.
> >
> > Please find the  attached data sample. But in the original data frame I
> > have 350 features and 40 observations.
> >
> > I need to carryout these tasks.
> >
> > 1. How to Identify features (names) that have all zeros?
> >
> > 2. How to remove features that have all zeros from the dataset?
> >
> > 3. How to identify features (names) that have outliers such as 9,-1
> in
> > the data frame.
> >
> > 4. How to remove outliers?
> >
> >
> > Many thanks
> > __
> > 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.


Re: [R] R how to find outliers and zero mean columns?

2016-03-30 Thread Norman Pat
Hi David,

> Please find the  attached data sample.

No. Nothing attached. Please read the Rhelp Info page and the Posting Guide.
*I attached it. Anyway I have attached it again (sample train.xlsx).*

Who is assigning you this task? Homework? (Read the Posting Guide.)
*This is my new job role so I have to do that. I know some basic R *

> 1. How to Identify features (names) that have all zeros?

That's generally pretty simple if "names" refers to columns in a data frame.
*You mean such as something like names(data.nrow(means==0))*

> 2. How to remove features that have all zeros from the dataset?

But maybe you mean to process by rows?
*in a column(feature) *

> 3. How to identify features (names) that have outliers such as 9,-1 in
> the data frame.
*Please refer to the attached excel file*

> 4. How to remove outliers?

You could start by defining "outliers" in something other than vague
examples. If this is data from a real-life data gathering effort, then
defining outliers would start with an explanation of the context.
*By looking at data I need to find the outliers*

*Thanks *


On Thu, Mar 31, 2016 at 12:20 PM, David Winsemius 
wrote:

>
> > On Mar 30, 2016, at 3:56 PM, Norman Pat  wrote:
> >
> > Hi team
> >
> > I am new to R so please help me to do this task.
> >
> > Please find the  attached data sample.
>
> No. Nothing attached. Please read the Rhelp Info page and the Posting
> Guide.
>
> > But in the original data frame I
> > have 350 features and 40 observations.
> >
> > I need to carryout these tasks.
>
> Who is assigning you this task? Homework? (Read the Posting Guide.)
>
> > 1. How to Identify features (names) that have all zeros?
>
> That's generally pretty simple if "names" refers to columns in a dataframe.
>
> >
> > 2. How to remove features that have all zeros from the dataset?
>
> But maybe you mean to process by rows?
>
>
> > 3. How to identify features (names) that have outliers such as 9,-1
> in
> > the data frame.
> >
> > 4. How to remove outliers?
>
> You could start by defining "outliers" in something other than vague
> examples. If this is data from a real-life data gathering effort, then
> defining outliers would start with an explanation of the context.
>
>
> >
> >
> > Many thanks
>
> Please at least do the following "homework".
>
> > __
> > 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.
>
> David Winsemius
> Alameda, CA, USA
>
>
__
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 how to find outliers and zero mean columns?

2016-03-30 Thread Norman Pat
Hi team

I am new to R so please help me to do this task.

Please find the  attached data sample. But in the original data frame I
have 350 features and 40 observations.

I need to carryout these tasks.

1. How to Identify features (names) that have all zeros?

2. How to remove features that have all zeros from the dataset?

3. How to identify features (names) that have outliers such as 9,-1 in
the data frame.

4. How to remove outliers?


Many thanks
__
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] Data frame with unequal lines per case

2014-07-03 Thread Pat Jackson
Dear R Help list, 
 I have data in a comma delimited format with an unequal number of lines 
per case,  ranging from 1 to 5. Each line contains that individual's rating of 
a televised conference they observed. I'm  interested in the influence of group 
size on ratings. 
  My questions: how can I create a data frame that will a) treat the group 
as the unit of analysis and b) permit me to calculate group results,  e.g., 
average ratings per group among those with data (which will vary)? 
   The data are formatted like those below (but with commas), which 
contains 3 groups (my unit of analysis). The header is the first row.  
Groupname is alpha (which I'll convert later) and the rest are numeric.  Number 
is the number of the individual rater in the group, ranging from 1-5.  Rate1 
and Rate2 range from 0-7 but my example has a more limited range. Male,  
female,  white and nonwhite are 1 yes or 0 no. 

So I have a maximum of 5 raters in 3 groups.  
   
Is it necessary to create a rectangular data frame with empty lines for groups 
with fewer than 5 raters? How should I do that? Or is there a better way? ( I 
have a lot more cases than provided below. )

Thank you for a referral to apps or a suggested strategy to deal with this. 

Pat J. 

Header:
Groupname number rate1 rate2 males females white nonwhite

Data:
Blue 1 3 1 1 0 0 1
Blue 2 2 3 1 0 1 0
Orange 1 4 4 0 1 1 0
Yellow 1 3 2 1 0 1 0
Yellow 2 5 2 0 1 0 1
Yellow 3 4 3 1 0 0 1
Yellow 4 4 2 1 0 1 0
Yellow 5 2 2 0 1 0 1 
[[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] Average value in a particular range of a matrix

2014-06-12 Thread Pat-74100

Hi

@Rolf Turner: So you're wrong, I can guaranty you this is not homework ... but 
just for a graph I'm trying do plot.

@Arun: Yes I've done a mistake, it is 1-100 , 101-200 etc .. or even 
1-50,51-100 etc. The range is not important.

Thanks


> Date: Thu, 12 Jun 2014 02:04:26 -0700
> From: smartpink...@yahoo.com
> Subject: Re: [R] Average value in a particular range of a matrix
> To: leonardsqual...@hotmail.com
> 
> Hi Pat,
> Is it 1-100, 101-200, 201-300,.. or just the way you described?
> A.K.
> 
> 
> 
> 
> On Wednesday, June 11, 2014 11:45 PM, Pat-74100  
> wrote:
> Hi
> 
> I have a matrix with values of size 1*500  i have to find the avg 
> value of first 1 to 100 ,avg value of 100 - 200 and so on up to 400-500.
> is there any function to find the average of 1 -100 and 100 - 200, 200 -
> 300,300 - 400,400 - 500 ??
> 
> Thanks
>   
> [[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] Average value in a particular range of a matrix

2014-06-11 Thread Pat-74100
Hi

I have a matrix with values of size 1*500  i have to find the avg 
value of first 1 to 100 ,avg value of 100 - 200 and so on up to 400-500.
 is there any function to find the average of 1 -100 and 100 - 200, 200 -
 300,300 - 400,400 - 500 ??

Thanks
  
[[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] lmPerm p-values and multiple testing

2012-11-03 Thread Pat
Even you used perm="Exact", the maximum observations allowed is only 10.  If
data exceeds this, perm="Prob" is used instead of "Exact". So, the p-values
are always changed.  The Porb method will approximate the permutation
distribution by randomly exchanging pairs of Y elements.



--
View this message in context: 
http://r.789695.n4.nabble.com/lmPerm-p-values-and-multiple-testing-tp4643219p4648350.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] Overall model significance for poisson GLM

2012-04-09 Thread Pat Wilkins
Greetings,

I am running glm models for species counts using a poisson link function.
Normal summary functions for this provide summary statistics in the form of
the deviance, AIC, and p-values for individual predictors.  I would like to
obtain the p-value for the overall model.  So far, I have been using an
analysis of deviance table to check a model against the null model with the
intercept as the only predictor.

Any advice on other methods to obtain the proper p-value would be
appreciated.

Thanks,

Pat

[[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] how to transform a data file

2011-11-28 Thread pat j
Hello R people,

I have a data file with 101 numeric variables: one variable called IDN (the
individual's unique id number, which I need to retain, and which ranges
from 1000 to 1320; some numbers are obviously skipped), and V1 to V100
(each has a value of 0 or 1; these 100 variables represent sequentially
ordered days and whether a characteristic was present or absent--e.g., v1
is day 1 and a "1" means the characteristic is present; v10 is day 10 and
"0" means the characteristic is absent).

This may be child's play for many on this list, but how do I transform this
data file to two columns, one called "id"  and another column named "c"
with 100 rows? I think it will end up being a 1000 row file. I've read some
and think that I'm trying to "melt" my existing data. I can transpose the
v1 to v100 with t(v1 to v100) but then I'm unclear on how to automatically
generate 100 identical IDN's for each case and variable and then put them
together.

 This may be redundant, but for the sake of clarity, what I'm trying to do
is get from this:

IDN  V1 V2 V3 … V100

1   0   1   0  . . .   1

2   1  1   1   . . .   0

40  1   0   . . .  1

.

.

100   0  1   0   . . .   1

To this:

id   c

10

11

10

.  .

.[continue 96 more times for c4 - c100]

1 1

2 1

2 1

2 1

.   .

. [continue 96 more times for c4 - c100]

2 0

.

.

.

 [then repeat this for the next 98 cases]

1000  1   0  1


Thank you very much.

PJ

[[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] Ruby Koans an amazing platform for teaching programming. Would this work with R?

2011-05-05 Thread Pat Schmitz
For those not familiar Ruby Koans is a fantastic platform for teaching many
of the basics of programming in the Ruby language.  It uses unit tests
written for methods each of which describe a component of the Ruby
programming language.

http://rubykoans.com/

The koans platform has become popular enough that it has been translated to
a few other popular languages.

Clojure - https://github.com/functional-koans/clojure-koans
Python - https://github.com/gregmalcolm/python_koans
Javascript - https://github.com/mrdavidlaing/javascript-koans

I have been programming with R for around two years now, having come to R as
a non-programmer, hoping to use it as a pragmatic solution to handeling and
plotting lots of data.  My skills have increased but are still certainly
limited, and much of the advanced functionality remains a bit of a mystery
to me.

As I have learned more of other languages, particularly Ruby and Javascript,
I am amazed with what can be done and with some concepts I so clearly have
not learned while programming R.

Take a look at Ruby Koans.  Would this work for R?

-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Trouble variable scoping a function writing with get()

2011-01-26 Thread Pat Schmitz
I am having trouble with variable scoping inside/outside functions.  I
want to use get() to grab a named and quoted variable as an input to a
function, however the function can't find the variable when it is entered
into the function call, only when it is named in the main environment.

I obviously am not so clear on variable scoping, and ?get really doesn't
clear up my confusion.

I am sure that there are better, more appropriate ways to write a
function...

Please enlighten me,
Pat

# Example code

dat <- expand.grid(a = factor(c("a", "b")), b=1:10)

# Function that requires get()
ex <- function(data, response){
 library(plyr)
 output <- ddply(data,
.(a),
summarize,
 res = sum(get(response))
)
return(output)
}


out <- ex(data = dat, response = "b")
# Error in get(response) : object 'response' not found

# However if I name reponse outside of the function, it is found by the
function
response = "b"
out <- ex(data = dat, response = "b")
out
#> out
#  a res
#1 a  55
#2 b  55


-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Question about a perceived irregularity in R syntax

2010-07-22 Thread Pat Schmitz
Both vector query's can select the values from the data.frame as written,
however in the first form assigning a value to said selected numbers fails.
 Can you explain the reason this fails?

dat <- data.frame(index = 1:10, Value = c(1:4, NA, 6, NA, 8:10))

dat$Value[dat$Value == "NA"] <- 1 #Why does this  fails to work,
dat$Value[dat$Value %in% NA] <- 1 #While this does work?


#Particularly when str() results in an equivalent class
dat <- data.frame(index = 1:10, Value = c(1:4, NA, 6, NA, 8:10))
str(dat$Value[dat$Value %in% NA])
str(dat$Value[dat$Value == "NA"])

Thanks
Pat


-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] strip.custom with strip on left for three conditioning variables

2010-03-31 Thread Pat Schmitz
I want to use a strip.custom as with useOuterStrips for three conditioning
variables.
useOuterStrips restricts this to only two conditioning variables, and I
cannot figure out
how to write strip.custom properly to do this.

library(lattice)

mtcars$HP <- equal.count(mtcars$hp)

#with two factors
x2<-xyplot(mpg ~ disp | HP + factor(cyl), mtcars)
useOuterStrips(x2)


#with three factors
x3<-xyplot(mpg ~ disp | HP + factor(cyl) + factor(carb), mtcars)

update(x3,strip=strip.custom(which.given= 1),
 strip2=strip.custom(which.given= 2),
 strip.left=strip.custom(which.given=3)
)

--
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] xyplot, overlay two variables on one plot with group factors

2010-02-14 Thread Pat Schmitz
Ok...I realized that if I don't wish to compare the groupings directly

i can plot the groups as separate panels, which is a much more simple
solution, but doesn't necessarily give the same effect.

xyplot(y+y2 ~ x | grp, dat)


On Sun, Feb 14, 2010 at 3:19 PM, Dennis Murphy  wrote:

> Hi:
>
> Here's one approach: the idea is to essentially stack the responses in both
> data sets, create a factor that identifies the stacked variables, merges
> the data
> together and then combines 'variable' and 'grp' from the merged data frame
> into a single factor for use as the groups = element in xyplot. (Got all
> that?)
>
> library(lattice)
> library(reshape)
> # use the melt function of reshape to stack the responses and create an
> # identifier (variable) for them. The responses themselves are put into a
> # variable named 'value'. id.vars are kept separate, the others are stacked
> # into a variable identifier called 'variable' and the vector of values
> called
> # 'values'...
> Dat <- melt(dat, id.vars = c('x', 'grp'))
> Dat2 <- melt(dat2, id.vars = c('x', 'grp'))
> Dat3 <- rbind(Dat, Dat2) # concatenate the two data frames
> Dat3$gv <- with(Dat3, paste(variable, grp, sep = ""))  # combine factors
>
> xyplot(value ~ x, data = Dat3, groups = gv, type = "l")
>
> There are more elegant ways to create the grouping factor, which you may
> need if you intend to create a 'nice' legend, but at this level it works.
>
> HTH,
> Dennis
>
> On Sun, Feb 14, 2010 at 12:44 PM, Pat Schmitz wrote:
>
>> All
>>
>> I want to overlay two variables on the same plot following their
>> appropriate
>> grouping.  I have attempted to use subscripting in panel with
>> panel.xyplot,
>> but I can't get the grouping to follow into the panel...here is an
>> example...
>>
>>
>> dat<-data.frame(
>> y= log(1:10),
>> y2=10:19,
>>  x=1:10,
>> grp = as.factor(1)
>> )
>>
>> dat2<-data.frame(
>>  y= log(10:19),
>> y2= 20:29,
>> x=1:10,
>>  grp = as.factor(c(2))
>> )
>>
>> dat<-rbind(dat, dat2)
>>
>> # Here I plot both response variables on y axis by the same x
>> xyplot(y2 ~ x, dat, groups=grp, type="l")
>> xyplot(y ~ x, dat, groups=grp, type="l")
>>
>> # I want to overlay both in the same plot to compare
>> xyplot(y~ x, dat,
>>  groups = grp,
>> ylim = c(0,40),
>> panel=function(x,y,subscripts, groups,...){
>>  panel.xyplot(x, y, type="l")
>> panel.xyplot(dat$x[subscripts], dat$y2[subscripts],type="l")
>>  }
>> )
>>
>>
>> Thanks
>>
>> --
>> Patrick Schmitz
>> Graduate Student
>> Plant Biology
>> 1206 West Gregory Drive
>> RM 1500
>>
>>[[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.
>>
>
>


-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] xyplot, overlay two variables on one plot with group factors

2010-02-14 Thread Pat Schmitz
All

I want to overlay two variables on the same plot following their appropriate
grouping.  I have attempted to use subscripting in panel with panel.xyplot,
but I can't get the grouping to follow into the panel...here is an
example...


dat<-data.frame(
y= log(1:10),
y2=10:19,
 x=1:10,
grp = as.factor(1)
)

dat2<-data.frame(
 y= log(10:19),
y2= 20:29,
x=1:10,
 grp = as.factor(c(2))
)

dat<-rbind(dat, dat2)

# Here I plot both response variables on y axis by the same x
xyplot(y2 ~ x, dat, groups=grp, type="l")
xyplot(y ~ x, dat, groups=grp, type="l")

# I want to overlay both in the same plot to compare
xyplot(y~ x, dat,
 groups = grp,
ylim = c(0,40),
panel=function(x,y,subscripts, groups,...){
 panel.xyplot(x, y, type="l")
panel.xyplot(dat$x[subscripts], dat$y2[subscripts],type="l")
 }
)


Thanks

-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Label individual points in lattice by and ID

2009-12-07 Thread Pat Schmitz
Thanks

This works, but I lose the ability to say plot a line by group connecting
the numbered points,
how do I recover this, or say color the groups by ID..

xyplot(y~x | f1 + f2, data= dat,
groups=ID,
type="l",
panel= function(x, y,groups, subscripts, ...){
panel.text(x, y, groups[subscripts])
    })

Pat

On Mon, Dec 7, 2009 at 3:18 AM, Felix Andrews  wrote:

> If you want to plot each point as the text of its ID, use a panel function:
> panel = function(x, y, groups, subscripts, ...) panel.text(x, y,
> groups[subscripts])
>
> If you want to add labels interactively to selected points:
> xyplot(y~x | f1 + f2, groups=ID,dat)
> ## repeat for each panel:
> trellis.focus(); panel.identify(); trellis.unfocus()
>
>
> 2009/12/7 Pat Schmitz :
> > Sorry.  My previous code didn't quite display my problem correctly.  To
> make
> > my point more clear, I want to use my "groups" as the label for the
> point,
> > or rather the point itself.  The key becomes illegible with many groups.
> >
> > x<-as.factor(1:5)
> > y<-rnorm(1:10)
> > f1<-c("a","b")
> > f2<-c("x","y")
> >
> > dat<-expand.grid(x=x, y=y, f1=f1, f2=f2)
> > dat$ID <- 1:dim(dat)[1]
> >
> > xyplot(y~x | f1 + f2, groups=ID,dat)
> >
> > xyplot(y~x | f1 + f2, groups=ID,auto.key=TRUE,dat)  # more accurate rep
> of
> > problem with key
> >
> >
> > Thanks
> > Pat
> >
> >
> > On Sun, Dec 6, 2009 at 9:58 PM, Pat Schmitz 
> wrote:
> >
> >> I am using a plot to inspect data points, and I would like to identify
> each
> >> point with respect to an ID. At issue is that I am producing a faceted
> plot
> >> with many IDs (96) and the key is far to large to accurately identify
> points
> >> by color.
> >>
> >> 1) Can you direct me on labeling or printing data points by an ID
> instead
> >> of a point, as in "ID" in this toy example
> >> 2) alternately is there method for printing a key for each panel which
> >> shows only those IDs which appear in the panel at hand?
> >>
> >> x<-as.factor(1:5)
> >> y<-rnorm(1:10)
> >> ID<-1:5
> >> f1<-c("a","b")
> >> f2<-c("x","y")
> >>
> >> dat<-expand.grid(x=x, y=y, id=ID, f1=f1, f2=f2)
> >>
> >> xyplot(y~x | f1 + f2, dat)
> >>
> >>
> >>
> >> Thanks
> >> Pat
> >>
> >> --
> >> Patrick Schmitz
> >> Graduate Student
> >> Plant Biology
> >> 1206 West Gregory Drive
> >> RM 1500
> >>
> >
> >
> >
> > --
> > Patrick Schmitz
> > Graduate Student
> > Plant Biology
> > 1206 West Gregory Drive
> > RM 1500
> >
> >[[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.
> >
>
>
>
> --
> Felix Andrews / 安福立
> Postdoctoral Fellow
> Integrated Catchment Assessment and Management (iCAM) Centre
> Fenner School of Environment and Society [Bldg 48a]
> The Australian National University
> Canberra ACT 0200 Australia
> M: +61 410 400 963
> T: + 61 2 6125 4670
> E: felix.andr...@anu.edu.au
> CRICOS Provider No. 00120C
> --
> http://www.neurofractal.org/felix/
>



-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Label individual points in lattice by and ID

2009-12-06 Thread Pat Schmitz
Sorry.  My previous code didn't quite display my problem correctly.  To make
my point more clear, I want to use my "groups" as the label for the point,
or rather the point itself.  The key becomes illegible with many groups.

x<-as.factor(1:5)
y<-rnorm(1:10)
f1<-c("a","b")
f2<-c("x","y")

dat<-expand.grid(x=x, y=y, f1=f1, f2=f2)
dat$ID <- 1:dim(dat)[1]

xyplot(y~x | f1 + f2, groups=ID,dat)

xyplot(y~x | f1 + f2, groups=ID,auto.key=TRUE,dat)  # more accurate rep of
problem with key


Thanks
Pat


On Sun, Dec 6, 2009 at 9:58 PM, Pat Schmitz  wrote:

> I am using a plot to inspect data points, and I would like to identify each
> point with respect to an ID. At issue is that I am producing a faceted plot
> with many IDs (96) and the key is far to large to accurately identify points
> by color.
>
> 1) Can you direct me on labeling or printing data points by an ID instead
> of a point, as in "ID" in this toy example
> 2) alternately is there method for printing a key for each panel which
> shows only those IDs which appear in the panel at hand?
>
> x<-as.factor(1:5)
> y<-rnorm(1:10)
> ID<-1:5
> f1<-c("a","b")
> f2<-c("x","y")
>
> dat<-expand.grid(x=x, y=y, id=ID, f1=f1, f2=f2)
>
> xyplot(y~x | f1 + f2, dat)
>
>
>
> Thanks
> Pat
>
> --
> Patrick Schmitz
> Graduate Student
> Plant Biology
> 1206 West Gregory Drive
> RM 1500
>



-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Label individual points in lattice by and ID

2009-12-06 Thread Pat Schmitz
I am using a plot to inspect data points, and I would like to identify each
point with respect to an ID. At issue is that I am producing a faceted plot
with many IDs (96) and the key is far to large to accurately identify points
by color.

1) Can you direct me on labeling or printing data points by an ID instead of
a point, as in "ID" in this toy example
2) alternately is there method for printing a key for each panel which shows
only those IDs which appear in the panel at hand?

x<-as.factor(1:5)
y<-rnorm(1:10)
ID<-1:5
f1<-c("a","b")
f2<-c("x","y")

dat<-expand.grid(x=x, y=y, id=ID, f1=f1, f2=f2)

xyplot(y~x | f1 + f2, dat)



Thanks
Pat

-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Can You Recommend Books for Linear Mixed Models in R

2009-10-01 Thread Pat Schmitz
All

I have been looking into the books on performing statistics in R, in
particular I am interested in General Linear Mixed Models, for Randomized
Complete Block Design Experiments

The list I have come away with so far is:

Mixed Effects Models in S and S-plus by Pinheiro (2002)
http://www.amazon.com/Mixed-Effects-Models-S-S-Plus/dp/0387989579/ref=wl_itt_dp_o?ie=UTF8&coliid=I1WXOBRXMHD30V&colid=38N475HUK5VPJ

Linear Models with R by Faraway (2004)
http://www.amazon.com/Linear-Models-Texts-Statistical-Science/dp/1584884258/ref=sr_1_1?ie=UTF8&s=books&qid=1254412763&sr=1-1

Extending the Linear Model with R by Faraway (2005)
http://www.amazon.com/Extending-Linear-Model-Generalized-Nonparametric/dp/158488424X/ref=pd_sim_b_7

Which of these would you as statisticians, researchers, scientists most
recommend?
Are there others in this realm of statistics that I have not discovered,
that might be more effective?

Thanks
Pat



-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Applying Logical statement to DateTime string as factor

2009-08-18 Thread Pat Schmitz
Fantastic, that works fantastically.  Is there a optimal way to search R
News topics, so that I can catch references like this? For all my searching
of list serves, and documentation, I found very little which could help me.

I have however, had excellent help with R-help, Gabor, I appreciate your
response very much.

Pat

On Tue, Aug 18, 2009 at 5:18 AM, Gabor Grothendieck  wrote:

> Try this:
>
>
> Lines <- '"1","30 Jun 2009 18:14:59"
> "2","02 Jul 2009 07:33:37"
> "3","06 Jul 2009 08:22:35"
> "4","06 Jul 2009 19:25:50"
> "5","08 Jul 2009 08:41:48"
> "6","10 Jul 2009 07:31:39"
> "7","10 Jul 2009 19:59:25"
> "8","13 Jul 2009 07:49:18"
> "9","13 Jul 2009 18:52:52"
> "10","15 Jul 2009 08:06:56"
> "11","15 Jul 2009 19:03:01"
> "12","17 Jul 2009 08:02:02"'
>
> library(chron)
> DF <- read.csv(textConnection(Lines), header = FALSE, as.is = TRUE)
> dd <- as.chron(DF$V2, "%d %b %Y %H:%M:%S")
>
> dd - dates(dd) > times("12:00:00")  # c(TRUE, FALSE, ...)
>
>
> See R News 4/1 and its references for more.
>
>
> On Tue, Aug 18, 2009 at 3:42 AM, Pat Schmitz wrote:
> > R-Help
> >
> > I have a data set which uses a DateTime string as follows : "2009-06-30
> > 18:14:59"
> > While I have been able to convert to DateTime properly
> >
> > time <- strptime(as.character(dat$Time),format='%d %b %Y %T') #Convert to
> > dateTime string
> >
> > I would like to use the time of day "hour" as a *factor* level.  I have
> > found that I can convert the date time to a factor
> >
> > time <- as.ordered(cut(time,  "hour"))
> >
> > But this produces a factor level for every single day.  The issue I have
> is
> > in figuring out how to apply a logical statement to the datetime string
> or
> > to the factor.  I would like to say that every datetime with an hour <12
> is
> > the morning factor, and every datetime with an hour >12 is at night.
> Without
> > LOTS of superfluous code.  below I am going as far as splitting the
> string
> > to columns, pulling the time and then setting the factor with a for
> > statement...yeesh.  I have example CSV dates at the end.
> >
> > new.dates <- matrix(unlist(lapply(as.character(dat$Time), function(x)
> > strsplit(x," "))),ncol=4, byrow=TRUE)  #Break Time String into columns
> > colnames(new.dates) <- c("day","month","year", "time") # Set column names
> > dat <- cbind(as.data.frame(new.dates),  as.data.frame(dat)) #bind to data
> > frame
> >
> > tfact<-matrix()
> >
> > for (i in which(as.character(dat$time) <= "12:00:00")){
> >tfact[i] <- "Morning"
> >}
> >
> > for (i in which(as.character(dat$time) >= "12:00:00")){
> >tfact[i] <- "Night"
> >}
> >
> > tfact<-factor(tfact,
> >levels=c("Morning",  "Night"),
> >)
> >
> > Example CSV Data
> > "1","30 Jun 2009 18:14:59"
> > "2","02 Jul 2009 07:33:37"
> > "3","06 Jul 2009 08:22:35"
> > "4","06 Jul 2009 19:25:50"
> > "5","08 Jul 2009 08:41:48"
> > "6","10 Jul 2009 07:31:39"
> > "7","10 Jul 2009 19:59:25"
> > "8","13 Jul 2009 07:49:18"
> > "9","13 Jul 2009 18:52:52"
> > "10","15 Jul 2009 08:06:56"
> > "11","15 Jul 2009 19:03:01"
> > "12","17 Jul 2009 08:02:02"
> >
> >
> > Thanks
> > Pat
> >
> > --
> > Patrick Schmitz
> > Graduate Student
> > Plant Biology
> > 1206 West Gregory Drive
> > RM 1500
> >
> >[[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.
> >
>



-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] Applying Logical statement to DateTime string as factor

2009-08-18 Thread Pat Schmitz
R-Help

I have a data set which uses a DateTime string as follows : "2009-06-30
18:14:59"
While I have been able to convert to DateTime properly

time <- strptime(as.character(dat$Time),format='%d %b %Y %T') #Convert to
dateTime string

I would like to use the time of day "hour" as a *factor* level.  I have
found that I can convert the date time to a factor

time <- as.ordered(cut(time,  "hour"))

But this produces a factor level for every single day.  The issue I have is
in figuring out how to apply a logical statement to the datetime string or
to the factor.  I would like to say that every datetime with an hour <12 is
the morning factor, and every datetime with an hour >12 is at night. Without
LOTS of superfluous code.  below I am going as far as splitting the string
to columns, pulling the time and then setting the factor with a for
statement...yeesh.  I have example CSV dates at the end.

new.dates <- matrix(unlist(lapply(as.character(dat$Time), function(x)
strsplit(x," "))),ncol=4, byrow=TRUE)  #Break Time String into columns
colnames(new.dates) <- c("day","month","year", "time") # Set column names
dat <- cbind(as.data.frame(new.dates),  as.data.frame(dat)) #bind to data
frame

tfact<-matrix()

for (i in which(as.character(dat$time) <= "12:00:00")){
tfact[i] <- "Morning"
}

for (i in which(as.character(dat$time) >= "12:00:00")){
tfact[i] <- "Night"
}

tfact<-factor(tfact,
levels=c("Morning",  "Night"),
)

Example CSV Data
"1","30 Jun 2009 18:14:59"
"2","02 Jul 2009 07:33:37"
"3","06 Jul 2009 08:22:35"
"4","06 Jul 2009 19:25:50"
"5","08 Jul 2009 08:41:48"
"6","10 Jul 2009 07:31:39"
"7","10 Jul 2009 19:59:25"
"8","13 Jul 2009 07:49:18"
"9","13 Jul 2009 18:52:52"
"10","15 Jul 2009 08:06:56"
"11","15 Jul 2009 19:03:01"
"12","17 Jul 2009 08:02:02"


Thanks
Pat

-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] What is the best method to produce means by categorical factors?

2009-07-30 Thread Pat Schmitz
I am attempting to replicate some of my experience from SAS in R and assume
there are best methods for using a combination of summary(), subset, and
which() to produce a subset of mean values by categorical or ordinal
factors.

within sas I would write

proc means mean data=dataset;
class factor1 factor2
var variable1 variable2;
RUN;

producing an output with means for each variable by factor groupings as
below:

*factor1factor2  obs   variablemean*
Level AtreatmentA3variable110
  variable222

   treatmentB3variable112
  variable230

Level BtreatmentA3variable110
  variable222

   treatmentB3variable112
  variable230

What is the best way to go about this in R?






-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] problem with caretNWS on linux

2008-05-09 Thread Pat Shields
On closer inspection of your specs, you might want to try upgrading your 
Twisted install.  I just checked and am pretty sure that the twistd 
version is sync'd with the Twisted version.  NWS requires Twisted >= 2.1.


Pat

Peter Tait wrote:

Hi Pat,
thank you for the response.
Yes I am running R on the same machine as the NWS server. I was doing 
this on my Windows 2003 server with out any problem.

My Linux server has 4 cores and I would like R to take advantage of them.
Thank you for your help.
Cheers
Peter

Original Message Follows
From: Patrick Shields <[EMAIL PROTECTED]>
To: Peter Tait <[EMAIL PROTECTED]>
CC: r-help@r-project.org
Subject: Re: [R] problem with caretNWS on linux
Date: Thu, 08 May 2008 16:42:31 -0400

Peter,
Are you running the NWS server on the same machine as the R session 
(ie the machine running 'twistd -y /etc/nws.tac')?


Pat

Peter Tait wrote:

Hi,
I am using caretNWS on a RHEL x86_64 system and I am getting an error 
message that is nearly identical to the one occuring in
http://www.r-project.org/nosvn/R.check/r-release-macosx-ix86/caretNWS-00check.txt 




Error in socketConnection(serverHost, port = port, open = "a+b", 
blocking = TRUE) :

 unable to open connection
Calls: system.time ... .local -> tryCatch -> tryCatchList -> 
socketConnection

In addition: Warning message:
In socketConnection(serverHost, port = port, open = "a+b", blocking = 
TRUE) :

 penguin:8765 cannot be opened

The software versions I am using are the following:
Python 2.3.4
twistd (the Twisted daemon) 1.3.0rc1
nwsserver-1.5.2
R version 2.6.2 (2008-02-08)
nws 1.6.3

Thank you for the help.
Peter

__
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.


--
Pat Shields
REvolution Computing
(203) 777-7442 x250
[EMAIL PROTECTED]




--
Pat Shields
REvolution Computing
(203) 777-7442 x250
[EMAIL PROTECTED]

__
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] Odd time conversion glitch

2007-12-27 Thread Pat Carroll
Hello, all.

I ran across an odd problem while working in R 2.6.0. The command line text 
follows. Basically, I attempted to convert a character vector of length 13 (in 
a data frame with 13 rows) from a character representation of dates to a POSIX 
representation using strptime. strptime returned a vector of length 9, which 
appears to contain 13 values (!) in the appropriate format.

I can't find any way to convince the strptime output that it has 13 values . . 
. even though (for example) posixvector[1:13] returns 13 values, 
anothervectorof length13<-posixvector[1:13] produces a length mismatch error.

Can anyone help diagnose this, or work around it?

Many thanks,
~Pat Carroll.


> Dataset$DateFilled
 [1] "10/20/2005" "11/4/2005"  "11/18/2005" "12/2/2005"  "4/3/2006"   
"6/5/2006"   "7/14/2006"  "4/27/2007"  "5/7/2007"   "7/17/2007"  "2/14/2005" 
[12] "2/14/2005"  "2/21/2005" 
> datefilledpos<-strptime(Dataset$DateFilled,format="%m/%d/%Y")
> datefilledpos
 [1] "2005-10-20" "2005-11-04" "2005-11-18" "2005-12-02" "2006-04-03" 
"2006-06-05" "2006-07-14" "2007-04-27" "2007-05-07" "2007-07-17" "2005-02-14"
[12] "2005-02-14" "2005-02-21"
> length(datefilledpos)
[1] 9
> length(Dataset$DateFilled)
[1] 13
> datefilledpos[1:13]
 [1] "2005-10-20" "2005-11-04" "2005-11-18" "2005-12-02" "2006-04-03" 
"2006-06-05" "2006-07-14" "2007-04-27" "2007-05-07" "2007-07-17" "2005-02-14"
[12] "2005-02-14" "2005-02-21"
> Dataset$DateFilled<-datefilledpos
Error in `$<-.data.frame`(`*tmp*`, "DateFilled", value = list(sec = c(0,  : 
  replacement has 9 rows, data has 13
> Dataset$DateFilled<-datefilledpos[1:13]
Error in `$<-.data.frame`(`*tmp*`, "DateFilled", value = list(sec = c(0,  : 
  replacement has 9 rows, data has 13
> 

 
Pat Carroll. 
what matters most is how well you walk through the fire. 
bukowski.





  

Be a better friend, newshound, and

__
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] RODBC problem: sqlSave not working after an update

2007-10-22 Thread Pat Carroll
Good day, all.

I just upgraded to R 2.6.0. I re-installed my most-used packages including 
RODBC to be sure I'm up-to-date. I have been working with a large insurance 
claims dataset stored in a MS-Access database on a Windows machine. I have been 
regularly exporting tables from R into it using sqlSave. It's worked like a 
charm until today, when this happened:

> CDUchannel<-odbcDriverConnect()
> sqlSave(CDUchannel,CDUAdmits,tablename="RCDUAdmits5")
Error in sqlSave(CDUchannel, CDUAdmits, tablename = "RCDUAdmits5") : 
  [RODBC] Failed exec in Update
22018 39 [Microsoft][ODBC Microsoft Access Driver]Invalid character value for 
cast specification (null)
> 

When I open the database in Access, I find that a table with the correct name 
has been created, it contains the right number of columns and all are 
appropriately named, but it is empty. There is a long pause between entering 
the command and the error message printing, so some processing is happening. I 
couldn't find anything using "sqlSave","RODBC",and "Access" recently in the 
archives search.

Anybody understand this error message, or why I'm suddenly getting it now?

All help appreciated, as always.

Thanks,
~Pat.
 
Pat Carroll. 
what matters most is how well you walk through the fire. 
bukowski.




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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.