Re: [R] error message from read.csv in loop

2021-07-10 Thread Migdonio González
Thank you very much for the clarification. I will try to use a more precise
language next time.

Warm regards
Migdonio G.

On Sat, Jul 10, 2021 at 11:30 AM Bert Gunter  wrote:

> "It seems that your problem is that you are using single quotes inside of
> the double quotes."
>
> That is FALSE. From ?Quotes:
> "Single and double quotes delimit character constants. They can be
> used interchangeably but double quotes are preferred (and character
> constants are printed using double quotes), so single quotes are
> normally only used to delimit character constants containing double
> quotes."
>
> Of course, pairs of each type of quote must properly match, must not
> get confused with quotes in the delineated string, etc. , but they are
> otherwise interchangeable. The whole of ?Quotes, especially the
> examples, is informative and worth the read (imo).
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Sat, Jul 10, 2021 at 8:20 AM Migdonio González
>  wrote:
> >
> >  It seems that your problem is that you are using single quotes inside of
> > the double quotes. This is not necessary. Here is the corrected for-loop:
> >
> > for (j in 1:nrow(ora))
> > {
> > mycol  <- ora[j,"fname"]
> > mycsv  <- paste0(mycol,".csv")
> > rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/",
> mycsv))
> > rr <- read.csv(rdcsv)
> > }
> >
> > Also note that the rr variable will only store the last CSV, not all CSV.
> > You will need to initialize the rr variable as a list to store all CSVs
> if
> > that is what you require. Something like this:
> >
> > # Initialize the rr variable as a list.
> > rr <- as.list(rep(NA, nrow(ora)))
> >
> > # Run the for-loop to store all the CSVs in rr.
> > for (j in 1:nrow(ora))
> > {
> > mycol  <- ora[j,"fname"]
> > mycsv  <- paste0(mycol,".csv")
> > rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/",
> mycsv))
> > rr[[j]] <- read.csv(rdcsv)
> > }
> >
> > Regards
> > Migdonio G.
> >
> > On Fri, Jul 9, 2021 at 1:10 PM Kai Yang via R-help  >
> > wrote:
> >
> > > Hello List,
> > > I use for loop to read csv difference file into data frame rr.  The
> data
> > > frame rr will be deleted after a comparison and go to the next csv
> file.
> > > Below is my code:
> > > for (j in 1:nrow(ora))
> > > {
> > >   mycol  <- ora[j,"fname"]
> > >   mycsv  <- paste0(mycol,".csv'")
> > >   rdcsv  <- noquote(paste0("'w:/project/_Joe.B/Oracle/data/", mycsv))
> > >   rr <- read.csv(rdcsv)
> > > }
> > > but when I run this code, I got error message below:
> > > Error in file(file, "rt") : cannot open the connection
> > > In addition: Warning message:
> > > In file(file, "rt") :
> > >   cannot open file
> > > ''w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'': No such file
> or
> > > directory
> > >
> > > so, I checked the rdcsv and print it out, see below:
> > > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DISCRETE_VALUES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_QUESTIONS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_RUNS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/DATA_ENTRY_PAGES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/DISCRETE_VALUES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/ENTRY_GROUPS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_GROUPS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_VALUES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_LOT_DEFINITIONS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_SAMPLES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/MOLECULAR_WAREHOUSE.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_DEFINITIONS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_GROUPS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/RESPONSES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST_NAMES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_PLATE_ADDRESSES.csv'
> > > [1] 'w:/project/_Joe.B/Oracle/data/STORAGE_UNITS.csv'
> > > it seems correct. I copy and paste it into a code :
> > >  rr <- read.csv( 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv')
> > > and it works fine.
> > > Can someone help me debug where is the problem in my for loop code?
> > > Thanks,
> > > Kai
> > >
> > >
> > >
> > >
> > >
> > > [[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.
> > >
> >
> > [[alternati

Re: [R] error message from read.csv in loop

2021-07-10 Thread Duncan Murdoch

On 10/07/2021 12:30 p.m., Bert Gunter wrote:

"It seems that your problem is that you are using single quotes inside of
the double quotes."

That is FALSE. From ?Quotes:
"Single and double quotes delimit character constants. They can be
used interchangeably but double quotes are preferred (and character
constants are printed using double quotes), so single quotes are
normally only used to delimit character constants containing double
quotes."

Of course, pairs of each type of quote must properly match, must not
get confused with quotes in the delineated string, etc. , but they are
otherwise interchangeable. The whole of ?Quotes, especially the
examples, is informative and worth the read (imo).


I think Migdonio is right.  From the error message the problem is that 
the filename was being specified as 
"'w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'"


That is not a legal filename:  the single quotes probably tell Windows 
to interpret it as a single filename entry, not drive, path, filename. 
Or maybe the drive is being interpreted as "'w", which isn't a legal 
drive id.


In any case, if you set f to an existing full path, and file.exists(f) 
returns TRUE, you'll find that file.exists(paste0("'", f, "'")) returns 
FALSE.


Duncan Murdoch



Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, Jul 10, 2021 at 8:20 AM Migdonio González
 wrote:


  It seems that your problem is that you are using single quotes inside of
the double quotes. This is not necessary. Here is the corrected for-loop:

for (j in 1:nrow(ora))
{
 mycol  <- ora[j,"fname"]
 mycsv  <- paste0(mycol,".csv")
 rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
 rr <- read.csv(rdcsv)
}

Also note that the rr variable will only store the last CSV, not all CSV.
You will need to initialize the rr variable as a list to store all CSVs if
that is what you require. Something like this:

# Initialize the rr variable as a list.
rr <- as.list(rep(NA, nrow(ora)))

# Run the for-loop to store all the CSVs in rr.
for (j in 1:nrow(ora))
{
 mycol  <- ora[j,"fname"]
 mycsv  <- paste0(mycol,".csv")
 rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
 rr[[j]] <- read.csv(rdcsv)
}

Regards
Migdonio G.

On Fri, Jul 9, 2021 at 1:10 PM Kai Yang via R-help 
wrote:


Hello List,
I use for loop to read csv difference file into data frame rr.  The data
frame rr will be deleted after a comparison and go to the next csv file.
Below is my code:
for (j in 1:nrow(ora))
{
   mycol  <- ora[j,"fname"]
   mycsv  <- paste0(mycol,".csv'")
   rdcsv  <- noquote(paste0("'w:/project/_Joe.B/Oracle/data/", mycsv))
   rr <- read.csv(rdcsv)
}
but when I run this code, I got error message below:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
   cannot open file
''w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'': No such file or
directory

so, I checked the rdcsv and print it out, see below:
[1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DISCRETE_VALUES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/ASSAY_QUESTIONS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/ASSAY_RUNS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/DATA_ENTRY_PAGES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/DISCRETE_VALUES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/ENTRY_GROUPS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_GROUPS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_VALUES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/GEMD_LOT_DEFINITIONS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/GEMD_SAMPLES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/MOLECULAR_WAREHOUSE.csv'
[1] 'w:/project/_Joe.B/Oracle/data/QUESTION_DEFINITIONS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/QUESTION_GROUPS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv'
[1] 'w:/project/_Joe.B/Oracle/data/RESPONSES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST.csv'
[1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST_NAMES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_PLATE_ADDRESSES.csv'
[1] 'w:/project/_Joe.B/Oracle/data/STORAGE_UNITS.csv'
it seems correct. I copy and paste it into a code :
  rr <- read.csv( 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv')
and it works fine.
Can someone help me debug where is the problem in my for loop code?
Thanks,
Kai





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



 [[alternative HTML version deleted]]

__
R-help@r-pro

Re: [R] problem for strsplit function

2021-07-10 Thread Robert Knight
My method would be to use parse and deparse and substitute.  It would iterate 
over each file name and build a new list of file names with the last four 
characters removed to have only the left side, and only the last four remaining 
to have only the right side.  Then a new dataframe would be created of the 
partial file names.   

Deparse and substitute to get the file names into a string, then use character 
removal on the sides, put the file name into a new vector, and then create the 
relevant data frame if desired.

This allows one to Rely on their software development metaphor.  It might lack 
a certain finess, but the metaphor is either a loom or a boxing match against a 
CSV so it’s fun. :)

Sent from my iPhone

> On Jul 9, 2021, at 10:33 PM, Rolf Turner  wrote:
> 
> 
> This discussion has developed in such a way that it seems a better
> subject line would be "problem for the hairsplit function". :-)
> 
> cheers,
> 
> Rolf Turner
> 
> -- 
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> 
> __
> 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 message from read.csv in loop

2021-07-10 Thread Bert Gunter
"It seems that your problem is that you are using single quotes inside of
the double quotes."

That is FALSE. From ?Quotes:
"Single and double quotes delimit character constants. They can be
used interchangeably but double quotes are preferred (and character
constants are printed using double quotes), so single quotes are
normally only used to delimit character constants containing double
quotes."

Of course, pairs of each type of quote must properly match, must not
get confused with quotes in the delineated string, etc. , but they are
otherwise interchangeable. The whole of ?Quotes, especially the
examples, is informative and worth the read (imo).

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, Jul 10, 2021 at 8:20 AM Migdonio González
 wrote:
>
>  It seems that your problem is that you are using single quotes inside of
> the double quotes. This is not necessary. Here is the corrected for-loop:
>
> for (j in 1:nrow(ora))
> {
> mycol  <- ora[j,"fname"]
> mycsv  <- paste0(mycol,".csv")
> rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
> rr <- read.csv(rdcsv)
> }
>
> Also note that the rr variable will only store the last CSV, not all CSV.
> You will need to initialize the rr variable as a list to store all CSVs if
> that is what you require. Something like this:
>
> # Initialize the rr variable as a list.
> rr <- as.list(rep(NA, nrow(ora)))
>
> # Run the for-loop to store all the CSVs in rr.
> for (j in 1:nrow(ora))
> {
> mycol  <- ora[j,"fname"]
> mycsv  <- paste0(mycol,".csv")
> rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
> rr[[j]] <- read.csv(rdcsv)
> }
>
> Regards
> Migdonio G.
>
> On Fri, Jul 9, 2021 at 1:10 PM Kai Yang via R-help 
> wrote:
>
> > Hello List,
> > I use for loop to read csv difference file into data frame rr.  The data
> > frame rr will be deleted after a comparison and go to the next csv file.
> > Below is my code:
> > for (j in 1:nrow(ora))
> > {
> >   mycol  <- ora[j,"fname"]
> >   mycsv  <- paste0(mycol,".csv'")
> >   rdcsv  <- noquote(paste0("'w:/project/_Joe.B/Oracle/data/", mycsv))
> >   rr <- read.csv(rdcsv)
> > }
> > but when I run this code, I got error message below:
> > Error in file(file, "rt") : cannot open the connection
> > In addition: Warning message:
> > In file(file, "rt") :
> >   cannot open file
> > ''w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'': No such file or
> > directory
> >
> > so, I checked the rdcsv and print it out, see below:
> > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DISCRETE_VALUES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_QUESTIONS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_RUNS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/DATA_ENTRY_PAGES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/DISCRETE_VALUES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/ENTRY_GROUPS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_GROUPS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_VALUES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_LOT_DEFINITIONS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/GEMD_SAMPLES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/MOLECULAR_WAREHOUSE.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_DEFINITIONS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_GROUPS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/RESPONSES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST_NAMES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_PLATE_ADDRESSES.csv'
> > [1] 'w:/project/_Joe.B/Oracle/data/STORAGE_UNITS.csv'
> > it seems correct. I copy and paste it into a code :
> >  rr <- read.csv( 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv')
> > and it works fine.
> > Can someone help me debug where is the problem in my for loop code?
> > Thanks,
> > Kai
> >
> >
> >
> >
> >
> > [[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.
> >
>
> [[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 --

[R] syvcoxph and cox.zph for testing the PH assumption

2021-07-10 Thread Youyi Fong
Hello, is it kosher to call cox.zph on a syvcoxph model fit? I see that
someone proposed a modified version of cox.zph that uses resid(fit,
'schoenfeld', **weighted=TRUE**).

https://stats.stackexchange.com/questions/265307/assessing-proportional-hazards-assumption-of-a-cox-model-with-caseweights
Is that all it takes?
Thanks,
Youyi

[[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 message from read.csv in loop

2021-07-10 Thread Migdonio González
Hello Kai,

Just as you did to store the data inside of rr. Try class(rr[[1]]) or
class(rr[[2]]) and so on to explore a bit more. The variable rr is a list
that contains dataframes within it. To access the dataframes you must use
the syntax rr[[i]] where i is the index of the element of the list (or the
number of the dataframe in your case). For example:

df1 <- rr[[1]]
class(df1) # Check if this is class "data.frame".

df2 <- rr[[2]]
class(df2)

You can also try other ways to store the dataframes more efficiently. This
is just a quick-and-dirty solution to the code you provided. I recommend
reading more about lists in R to understand how they work and how they
differ from other data structures like vectors.

Hope this helps,
Warm regards.
Migdonio G.

On Fri, Jul 9, 2021 at 2:24 PM Kai Yang  wrote:

> Hi Migdonio,
>
> I did try your code:
>
> # Initialize the rr variable as a list.
>
> rr <- as.list(rep(NA, nrow(ora)))
>
>
>
> # Run the for-loop to store all the CSVs in rr.
>
> for (j in 1:nrow(ora))
>
> {
>
> mycol  <- ora[j,"fname"]
>
> mycsv  <- paste0(mycol,".csv")
>
> rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
>
> rr[[j]] <- read.csv(rdcsv)
>
> }
>
>
> this code is working, but rr is not a data frame, R said: Large list ( 20
> elements .). how can I use it as a data frame one by one?
>
> Thank you for your help
>
> Kai
>
> On Friday, July 9, 2021, 11:39:59 AM PDT, Migdonio González <
> migdonio.gonzale...@gmail.com> wrote:
>
>
> It seems that your problem is that you are using single quotes inside of
> the double quotes. This is not necessary. Here is the corrected for-loop:
>
> for (j in 1:nrow(ora))
> {
> mycol  <- ora[j,"fname"]
> mycsv  <- paste0(mycol,".csv")
> rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
> rr <- read.csv(rdcsv)
> }
>
> Also note that the rr variable will only store the last CSV, not all CSV.
> You will need to initialize the rr variable as a list to store all CSVs if
> that is what you require. Something like this:
>
> # Initialize the rr variable as a list.
> rr <- as.list(rep(NA, nrow(ora)))
>
> # Run the for-loop to store all the CSVs in rr.
> for (j in 1:nrow(ora))
> {
> mycol  <- ora[j,"fname"]
> mycsv  <- paste0(mycol,".csv")
> rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
> rr[[j]] <- read.csv(rdcsv)
> }
>
> Regards
> Migdonio G.
>
> On Fri, Jul 9, 2021 at 1:10 PM Kai Yang via R-help 
> wrote:
>
> Hello List,
> I use for loop to read csv difference file into data frame rr.  The data
> frame rr will be deleted after a comparison and go to the next csv file.
> Below is my code:
> for (j in 1:nrow(ora))
> {
>   mycol  <- ora[j,"fname"]
>   mycsv  <- paste0(mycol,".csv'")
>   rdcsv  <- noquote(paste0("'w:/project/_Joe.B/Oracle/data/", mycsv))
>   rr <- read.csv(rdcsv)
> }
> but when I run this code, I got error message below:
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>   cannot open file
> ''w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'': No such file or
> directory
>
> so, I checked the rdcsv and print it out, see below:
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DISCRETE_VALUES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_QUESTIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_RUNS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/DATA_ENTRY_PAGES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/DISCRETE_VALUES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ENTRY_GROUPS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_GROUPS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_VALUES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_LOT_DEFINITIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_SAMPLES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/MOLECULAR_WAREHOUSE.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_DEFINITIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_GROUPS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/RESPONSES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST_NAMES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_PLATE_ADDRESSES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/STORAGE_UNITS.csv'
> it seems correct. I copy and paste it into a code :
>  rr <- read.csv( 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv')
> and it works fine.
> Can someone help me debug where is the problem in my for loop code?
> Thanks,
> Kai
>
>
>
>
>
> [[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 comm

Re: [R] error message from read.csv in loop

2021-07-10 Thread Migdonio González
 It seems that your problem is that you are using single quotes inside of
the double quotes. This is not necessary. Here is the corrected for-loop:

for (j in 1:nrow(ora))
{
mycol  <- ora[j,"fname"]
mycsv  <- paste0(mycol,".csv")
rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
rr <- read.csv(rdcsv)
}

Also note that the rr variable will only store the last CSV, not all CSV.
You will need to initialize the rr variable as a list to store all CSVs if
that is what you require. Something like this:

# Initialize the rr variable as a list.
rr <- as.list(rep(NA, nrow(ora)))

# Run the for-loop to store all the CSVs in rr.
for (j in 1:nrow(ora))
{
mycol  <- ora[j,"fname"]
mycsv  <- paste0(mycol,".csv")
rdcsv  <- noquote(paste0("w:/project/_Joe.B/Oracle/data/", mycsv))
rr[[j]] <- read.csv(rdcsv)
}

Regards
Migdonio G.

On Fri, Jul 9, 2021 at 1:10 PM Kai Yang via R-help 
wrote:

> Hello List,
> I use for loop to read csv difference file into data frame rr.  The data
> frame rr will be deleted after a comparison and go to the next csv file.
> Below is my code:
> for (j in 1:nrow(ora))
> {
>   mycol  <- ora[j,"fname"]
>   mycsv  <- paste0(mycol,".csv'")
>   rdcsv  <- noquote(paste0("'w:/project/_Joe.B/Oracle/data/", mycsv))
>   rr <- read.csv(rdcsv)
> }
> but when I run this code, I got error message below:
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>   cannot open file
> ''w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'': No such file or
> directory
>
> so, I checked the rdcsv and print it out, see below:
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DEFINITIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_DISCRETE_VALUES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_QUESTIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ASSAY_RUNS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/DATA_ENTRY_PAGES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/DISCRETE_VALUES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/ENTRY_GROUPS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_GROUPS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_CODELIST_VALUES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_LOT_DEFINITIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/GEMD_SAMPLES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/MOLECULAR_WAREHOUSE.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_DEFINITIONS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/QUESTION_GROUPS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/RESPONSES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_LIST_NAMES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/SAMPLE_PLATE_ADDRESSES.csv'
> [1] 'w:/project/_Joe.B/Oracle/data/STORAGE_UNITS.csv'
> it seems correct. I copy and paste it into a code :
>  rr <- read.csv( 'w:/project/_Joe.B/Oracle/data/RESPONDENTS.csv')
> and it works fine.
> Can someone help me debug where is the problem in my for loop code?
> Thanks,
> Kai
>
>
>
>
>
> [[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.
>

[[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] [Rd] R 4.1.1 scheduled for August 10

2021-07-10 Thread Peter Dalgaard via R-help
Full schedule is available on developer.r-project.org.

(This comes somewhat late this year, partly because we needed to squeeze in 
4.0.5 before 4.1.0 could be released.)

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] How to estimate the parameter for many variable?

2021-07-10 Thread SITI AISYAH ZAKARIA
Dear Rui and Jim,

Thank you very much for your feedback.

Yes, now I get the output. And after this I will use this output as the
marginal distribution to continue the analysis on spatial extremes.


Thanks again. See you later.

On Fri, 9 Jul 2021 at 17:18, Rui Barradas  wrote:

> Hello,
>
> With the condition for the location it can be estimated like the following.
>
>
> fit_list2 <- gev_fit_list <- lapply(Ozone_weekly2, gev.fit, ydat = ti,
> mul = c(2, 3), show = FALSE)
> mle_params2 <- t(sapply(fit_list2, '[[', 'mle'))
> # assign column names
> colnames(mle_params2) <- c("location", "scale", "shape", "mul2", "mul3")
> head(mle_params2)
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 09:53 de 09/07/21, SITI AISYAH ZAKARIA escreveu:
> > Dear Rui ang Jim,
> >
> > Thank you very much.
> >
> > Thank you Rui Barradas, I already tried using your coding and I'm
> > grateful I got the answer.
> >
> > ok now, I have some condition on the location parameter which is cyclic
> > condition.
> >
> > So, I will add another 2 variables for the column.
> >
> > and the condition for location is this one.
> >
> >   ti[,1] = seq(1, 888, 1)
> >ti[,2]=sin(2*pi*(ti[,1])/52)
> >ti[,3]=cos(2*pi*(ti[,1])/52)
> >fit0<-gev.fit(x[,i], ydat = ti, mul=c(2, 3))
> >
> > Thank you again.
> >
> > On Fri, 9 Jul 2021 at 14:38, Rui Barradas  > > wrote:
> >
> > Hello,
> >
> > The following lapply one-liner fits a GEV to each column vector,
> there
> > is no need for the double for loop. There's also no need to create a
> > data set x.
> >
> >
> > library(ismev)
> > library(mgcv)
> > library(EnvStats)
> >
> > Ozone_weekly2 <- read.table("~/tmp/Ozone_weekly2.txt", header = TRUE)
> >
> > # fit a GEV to each column
> > gev_fit_list <- lapply(Ozone_weekly2, gev.fit, show = FALSE)
> >
> > # extract the parameters MLE estimates
> > mle_params <- t(sapply(gev_fit_list, '[[', 'mle'))
> >
> > # assign column names
> > colnames(mle_params) <- c("location", "scale", "shape")
> >
> > # see first few rows
> > head(mle_params)
> >
> >
> >
> > The OP doesn't ask for plots but, here they go.
> >
> >
> > y_vals <- function(x, params){
> > loc <- params[1]
> > scale <- params[2]
> > shape <- params[3]
> > EnvStats::dgevd(x, loc, scale, shape)
> > }
> > plot_fit <- function(data, vec, verbose = FALSE){
> > fit <- gev.fit(data[[vec]], show = verbose)
> > x <- sort(data[[vec]])
> > hist(x, freq = FALSE)
> > lines(x, y_vals(x, params = fit$mle))
> > }
> >
> > # seems a good fit
> > plot_fit(Ozone_weekly2, 1)   # column number
> > plot_fit(Ozone_weekly2, "CA01")  # col name, equivalent
> >
> > # the data seems gaussian, not a good fit
> > plot_fit(Ozone_weekly2, 4)   # column number
> > plot_fit(Ozone_weekly2, "CA08")  # col name, equivalent
> >
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> >
> > Às 00:59 de 09/07/21, SITI AISYAH ZAKARIA escreveu:
> >  > Dear all,
> >  >
> >  > Thank you very much for the feedback.
> >  >
> >  > Sorry for the lack of information about this problem.
> >  >
> >  > Here, I explain again.
> >  >
> >  > I use this package to run my coding.
> >  >
> >  > library(ismev)
> >  > library(mgcv)
> >  > library(nlme)
> >  >
> >  > The purpose of this is I want to get the value of parameter
> > estimation
> >  > using MLE by applying the GEV distribution.
> >  >
> >  > x <- data.matrix(Ozone_weekly2)  x refers to
> > my data
> >  > that consists of 19 variables. I will attach the data together.
> >  > x
> >  > head(gev.fit)[1:4]
> >  > ti = matrix(ncol = 3, nrow = 888)
> >  > ti[,1] = seq(1, 888, 1)
> >  > ti[,2]=sin(2*pi*(ti[,1])/52)
> >  > ti[,3]=cos(2*pi*(ti[,1])/52)
> >  >
> >  > /for(i in 1:nrow(x))
> >  >+ { for(j in 1:ncol(x))the problem
> in
> >  > here, i don't no to create the coding. i target my output will
> > come out
> >  > in matrix that
> >  >  + {x[i,j] = 1}}   show
> the
> >  > parameter estimation for 19 variable which have 19 row and 3
> column/
> >  > /
> > row --
> >  > refer to variable (station)  ; column -- refer to parameter
> > estimation
> >  > for GEV distribution
> >  >
> >  > /thank you.
> >  >
> >  > On Thu, 8 Jul 2021 at 18:40, Rui Barradas  > 
> >  > >>
> wrote:
> >  >
> >  > Hello,
> >  >
> >  > Also, in the code
> >  >
> >  > x <- data.matrix(Ozone_weekly)
> >  >
> >  > [...omited...]
> >  >
> >  > for(i in 1:nrow(x))
> >  > + { for(j in 1:ncol(