Re: [R] Error with RMySQL

2021-10-28 Thread Ashim Kapoor
Dear Jim,

Can you please help me? I am a little confused here.

Best,
Ashim

On Thu, Oct 28, 2021 at 11:30 AM Ashim Kapoor  wrote:
>
> Dear Jim,
>
> > That error means that your user number or group is not allowed to
> > access it. Did you create the new one as a different user, maybe as
> > root?
>
> Here is what I did:
>
> I switched to root in the MySQL Server, created a new user called
> user2. I GRANTed user2 all permissions to access db2. I did NOT
> restart the mysql server as I think the GRANT  does not need a restart
> of the MySQL server.
>
> > Jim
> >
> > On Thu, Oct 28, 2021 at 4:42 PM Ashim Kapoor  wrote:
> > >
> > > Dear R - users,
> > >
> > > I have 2 databases on a MySQL server. I am able to access the old one
> > > but not the freshly created one.
> > >
> > > library(RMySQL)
> > > # This one is the old one, I am able to access it,
> > > > con1<- dbConnect(MySQL(),host= "myserver", db="db1", user= 
> > > > "user1",password ="mypass1")
> > >
> > > # This is the new one. I am getting an error.
> > > > con2 <- dbConnect(MySQL(),host= "myserver", db="db2", user= 
> > > > "user2",password="mypass2")
> > > Error in .local(drv, ...) :
> > >   Failed to connect to database: Error: Access denied for user
> > > 'user2'@'myserver' (using password: YES)
> > > >
> > >
> > > Can someone please point me in the right direction? The error is not
> > > clear. I do not think I have mistyped the credentials.
> > >
> > > Many thanks,
> > > Ashim
> > >
> > > __
> > > 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 with RMySQL

2021-10-28 Thread Jim Lemon
Hi Ashim,
I was out for a while. I would first try to restart MySQL, then if
that didn't fix it, try logging in as root and accessing the database.
While I can't debug this at a distance, I'm pretty sure that the
database thinks that you aren't authorized to access it. If the
restart works, your problem is solved. If you have to log in as root,
it's more difficult to know how this happened.

Jim

On Thu, Oct 28, 2021 at 6:13 PM Ashim Kapoor  wrote:
>
> Dear Jim,
>
> Can you please help me? I am a little confused here.
>
> Best,
> Ashim
>
> On Thu, Oct 28, 2021 at 11:30 AM Ashim Kapoor  wrote:
> >
> > Dear Jim,
> >
> > > That error means that your user number or group is not allowed to
> > > access it. Did you create the new one as a different user, maybe as
> > > root?
> >
> > Here is what I did:
> >
> > I switched to root in the MySQL Server, created a new user called
> > user2. I GRANTed user2 all permissions to access db2. I did NOT
> > restart the mysql server as I think the GRANT  does not need a restart
> > of the MySQL server.
> >
> > > Jim
> > >
> > > On Thu, Oct 28, 2021 at 4:42 PM Ashim Kapoor  
> > > wrote:
> > > >
> > > > Dear R - users,
> > > >
> > > > I have 2 databases on a MySQL server. I am able to access the old one
> > > > but not the freshly created one.
> > > >
> > > > library(RMySQL)
> > > > # This one is the old one, I am able to access it,
> > > > > con1<- dbConnect(MySQL(),host= "myserver", db="db1", user= 
> > > > > "user1",password ="mypass1")
> > > >
> > > > # This is the new one. I am getting an error.
> > > > > con2 <- dbConnect(MySQL(),host= "myserver", db="db2", user= 
> > > > > "user2",password="mypass2")
> > > > Error in .local(drv, ...) :
> > > >   Failed to connect to database: Error: Access denied for user
> > > > 'user2'@'myserver' (using password: YES)
> > > > >
> > > >
> > > > Can someone please point me in the right direction? The error is not
> > > > clear. I do not think I have mistyped the credentials.
> > > >
> > > > Many thanks,
> > > > Ashim
> > > >
> > > > __
> > > > 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 with RMySQL

2021-10-28 Thread Ashim Kapoor
Dear Jim,

Many thanks. I will try your suggestion and come back to you.

Many thanks,
Ashim

On Thu, Oct 28, 2021 at 1:25 PM Jim Lemon  wrote:
>
> Hi Ashim,
> I was out for a while. I would first try to restart MySQL, then if
> that didn't fix it, try logging in as root and accessing the database.
> While I can't debug this at a distance, I'm pretty sure that the
> database thinks that you aren't authorized to access it. If the
> restart works, your problem is solved. If you have to log in as root,
> it's more difficult to know how this happened.
>
> Jim
>
> On Thu, Oct 28, 2021 at 6:13 PM Ashim Kapoor  wrote:
> >
> > Dear Jim,
> >
> > Can you please help me? I am a little confused here.
> >
> > Best,
> > Ashim
> >
> > On Thu, Oct 28, 2021 at 11:30 AM Ashim Kapoor  wrote:
> > >
> > > Dear Jim,
> > >
> > > > That error means that your user number or group is not allowed to
> > > > access it. Did you create the new one as a different user, maybe as
> > > > root?
> > >
> > > Here is what I did:
> > >
> > > I switched to root in the MySQL Server, created a new user called
> > > user2. I GRANTed user2 all permissions to access db2. I did NOT
> > > restart the mysql server as I think the GRANT  does not need a restart
> > > of the MySQL server.
> > >
> > > > Jim
> > > >
> > > > On Thu, Oct 28, 2021 at 4:42 PM Ashim Kapoor  
> > > > wrote:
> > > > >
> > > > > Dear R - users,
> > > > >
> > > > > I have 2 databases on a MySQL server. I am able to access the old one
> > > > > but not the freshly created one.
> > > > >
> > > > > library(RMySQL)
> > > > > # This one is the old one, I am able to access it,
> > > > > > con1<- dbConnect(MySQL(),host= "myserver", db="db1", user= 
> > > > > > "user1",password ="mypass1")
> > > > >
> > > > > # This is the new one. I am getting an error.
> > > > > > con2 <- dbConnect(MySQL(),host= "myserver", db="db2", user= 
> > > > > > "user2",password="mypass2")
> > > > > Error in .local(drv, ...) :
> > > > >   Failed to connect to database: Error: Access denied for user
> > > > > 'user2'@'myserver' (using password: YES)
> > > > > >
> > > > >
> > > > > Can someone please point me in the right direction? The error is not
> > > > > clear. I do not think I have mistyped the credentials.
> > > > >
> > > > > Many thanks,
> > > > > Ashim
> > > > >
> > > > > __
> > > > > 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.


[R] Need help to print matrix with element and position

2021-10-28 Thread Anas Jamshed
I create a matrix of size 3x3 called mat_1 and then I want to iterate over
all the values one by one and print the element as well as the position in
the matrix:

My code is :

mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
3,byrow = TRUE)
mat_1
# Loop over my_matrix
for(row in 1:nrow(mat_1)) {
for(col in 1:ncol(mat_1)) {
print(mat_1[row, col])
}
}

But I don't know how to print elements and positions as well of this matrix?

[[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 with RMySQL

2021-10-28 Thread Ashim Kapoor
Dear Jim,

I restarted the mariadb.service but I am STILL not able to access the server.

I can access one database from one user but not from another user. The
credentials seem to be OK to me.

If I can figure this out I will post it here.

Many thanks,
Ashim

On Thu, Oct 28, 2021 at 1:38 PM Ashim Kapoor  wrote:
>
> Dear Jim,
>
> Many thanks. I will try your suggestion and come back to you.
>
> Many thanks,
> Ashim
>
> On Thu, Oct 28, 2021 at 1:25 PM Jim Lemon  wrote:
> >
> > Hi Ashim,
> > I was out for a while. I would first try to restart MySQL, then if
> > that didn't fix it, try logging in as root and accessing the database.
> > While I can't debug this at a distance, I'm pretty sure that the
> > database thinks that you aren't authorized to access it. If the
> > restart works, your problem is solved. If you have to log in as root,
> > it's more difficult to know how this happened.
> >
> > Jim
> >
> > On Thu, Oct 28, 2021 at 6:13 PM Ashim Kapoor  wrote:
> > >
> > > Dear Jim,
> > >
> > > Can you please help me? I am a little confused here.
> > >
> > > Best,
> > > Ashim
> > >
> > > On Thu, Oct 28, 2021 at 11:30 AM Ashim Kapoor  
> > > wrote:
> > > >
> > > > Dear Jim,
> > > >
> > > > > That error means that your user number or group is not allowed to
> > > > > access it. Did you create the new one as a different user, maybe as
> > > > > root?
> > > >
> > > > Here is what I did:
> > > >
> > > > I switched to root in the MySQL Server, created a new user called
> > > > user2. I GRANTed user2 all permissions to access db2. I did NOT
> > > > restart the mysql server as I think the GRANT  does not need a restart
> > > > of the MySQL server.
> > > >
> > > > > Jim
> > > > >
> > > > > On Thu, Oct 28, 2021 at 4:42 PM Ashim Kapoor  
> > > > > wrote:
> > > > > >
> > > > > > Dear R - users,
> > > > > >
> > > > > > I have 2 databases on a MySQL server. I am able to access the old 
> > > > > > one
> > > > > > but not the freshly created one.
> > > > > >
> > > > > > library(RMySQL)
> > > > > > # This one is the old one, I am able to access it,
> > > > > > > con1<- dbConnect(MySQL(),host= "myserver", db="db1", user= 
> > > > > > > "user1",password ="mypass1")
> > > > > >
> > > > > > # This is the new one. I am getting an error.
> > > > > > > con2 <- dbConnect(MySQL(),host= "myserver", db="db2", user= 
> > > > > > > "user2",password="mypass2")
> > > > > > Error in .local(drv, ...) :
> > > > > >   Failed to connect to database: Error: Access denied for user
> > > > > > 'user2'@'myserver' (using password: YES)
> > > > > > >
> > > > > >
> > > > > > Can someone please point me in the right direction? The error is not
> > > > > > clear. I do not think I have mistyped the credentials.
> > > > > >
> > > > > > Many thanks,
> > > > > > Ashim
> > > > > >
> > > > > > __
> > > > > > 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] Need help to print matrix with element and position

2021-10-28 Thread Jim Lemon
Hi Anas,
How about:

cat(row,col,mat_1[row,col],"\n")

Jim

On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed  wrote:
>
> I create a matrix of size 3x3 called mat_1 and then I want to iterate over
> all the values one by one and print the element as well as the position in
> the matrix:
>
> My code is :
>
> mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
> 3,byrow = TRUE)
> mat_1
> # Loop over my_matrix
> for(row in 1:nrow(mat_1)) {
> for(col in 1:ncol(mat_1)) {
> print(mat_1[row, col])
> }
> }
>
> But I don't know how to print elements and positions as well of this matrix?
>
> [[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] Need help to print matrix with element and position

2021-10-28 Thread Anas Jamshed
where should I place  cat(row,col,mat_1[row,col],"\n")?

On Thu, Oct 28, 2021 at 1:58 PM Jim Lemon  wrote:

> Hi Anas,
> How about:
>
> cat(row,col,mat_1[row,col],"\n")
>
> Jim
>
> On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed 
> wrote:
> >
> > I create a matrix of size 3x3 called mat_1 and then I want to iterate
> over
> > all the values one by one and print the element as well as the position
> in
> > the matrix:
> >
> > My code is :
> >
> > mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
> > 3,byrow = TRUE)
> > mat_1
> > # Loop over my_matrix
> > for(row in 1:nrow(mat_1)) {
> > for(col in 1:ncol(mat_1)) {
> > print(mat_1[row, col])
> > }
> > }
> >
> > But I don't know how to print elements and positions as well of this
> matrix?
> >
> > [[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.


Re: [R] Need help to print matrix with element and position

2021-10-28 Thread Jim Lemon
mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
3,byrow = TRUE)
mat_1
# Loop over my_matrix
for(row in 1:nrow(mat_1)) {
for(col in 1:ncol(mat_1)) {
cat(row,col,mat_1[row,col],"\n")
}
}

On Thu, Oct 28, 2021 at 8:01 PM Anas Jamshed  wrote:
>
> where should I place  cat(row,col,mat_1[row,col],"\n")?
>
> On Thu, Oct 28, 2021 at 1:58 PM Jim Lemon  wrote:
>>
>> Hi Anas,
>> How about:
>>
>> cat(row,col,mat_1[row,col],"\n")
>>
>> Jim
>>
>> On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed  
>> wrote:
>> >
>> > I create a matrix of size 3x3 called mat_1 and then I want to iterate over
>> > all the values one by one and print the element as well as the position in
>> > the matrix:
>> >
>> > My code is :
>> >
>> > mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
>> > 3,byrow = TRUE)
>> > mat_1
>> > # Loop over my_matrix
>> > for(row in 1:nrow(mat_1)) {
>> > for(col in 1:ncol(mat_1)) {
>> > print(mat_1[row, col])
>> > }
>> > }
>> >
>> > But I don't know how to print elements and positions as well of this 
>> > matrix?
>> >
>> > [[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] Need help to print matrix with element and position

2021-10-28 Thread Rui Barradas

Hello,

With no loops:


cbind(
  row = c(t(row(mat_1))),
  col = c(t(col(mat_1))),
  mat_1 = as.numeric(t(mat_1))
)


If the matrix entries are not numeric, use cbind.data.frame. This will 
keep the row and column numbers as numbers, the default cbind method 
would coerce them to the class of mat_1's elements.



cbind.data.frame(
  row = c(t(row(mat_1))),
  col = c(t(col(mat_1))),
  mat_1 = c(t(mat_1))
)


Hope this helps,

Rui Barradas


Às 09:19 de 28/10/21, Anas Jamshed escreveu:

I create a matrix of size 3x3 called mat_1 and then I want to iterate over
all the values one by one and print the element as well as the position in
the matrix:

My code is :

mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
3,byrow = TRUE)
mat_1
# Loop over my_matrix
for(row in 1:nrow(mat_1)) {
 for(col in 1:ncol(mat_1)) {
 print(mat_1[row, col])
 }
}

But I don't know how to print elements and positions as well of this matrix?

[[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] R code in RData

2021-10-28 Thread Martin Maechler
> Jeff Newmiller 
> on Wed, 27 Oct 2021 11:43:08 -0700 writes:

> Sounds right, though the OP appears to be assuming that the code used to 
generate the data objects in the file will also be there, and we need to be 
more definitive about that: it is not. Depending how the code was constructed, 
there may be useful information in the functions that were stored in the 
environment from which the save file was created, but this is not in any way 
guaranteed to be useful. In particular, there is no trace IN the RData file of 
which packages need to be loaded in order to access the objects stored in that 
RData file.
> This is one of the reasons depending on RData files for archiving work is 
not advisable... and why putting code in R scripts or Sweave/knitr-based 
literate programming files IS recommended.

Yes, very strongly recommended.

Citation:

  The source code is real.  Objects are realizations of the source code.
    

This has been the philosophy of using R-like systems
with ESS ("Emacs Speaks Statistics",  formerly 'S-mode') since the late 1980s,
also adopted by RStudio since 2011.


> On October 27, 2021 10:47:14 AM PDT, Bert Gunter  
wrote:
>> See ?load, but you may be confused. Strictly speaking, there is no code 
in
>> an .Rdata file, only a (typically binary, but possibly ascii)
>> representation of objects, usually as produced by ?save. Of course,
>> functions are also objects, so that if you load a file with functions, 
the
>> function code is available.
>> 
>> You can save and load command histories via ?savehistory, which, like 
?save
>> and ?load can usually be accessed through any GUI interface that you are
>> using.
>> 
>> Warning: I believe the above is correct, but I may be wrong in at least
>> some details, so give others a chance to reply and possibly correct.
>> 
>> Cheers,
>> Bert
>> 
>> 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 Wed, Oct 27, 2021 at 10:18 AM Bogdan Tanasa  wrote:
>> 
>>> Dear all, would you please advice :
>>> 
>>> I have an Rdata file, what is the way to print the R code that has been
>>> used inside the Rdata file ?
>>> 
>>> thank you,
>>> 
>>> Bogdan
>>> 
>>> [[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.

> -- 
> Sent from my phone. Please excuse my brevity.

> __
> 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] R code in RData

2021-10-28 Thread Martin Maechler
> Bert Gunter 
> on Wed, 27 Oct 2021 10:47:14 -0700 writes:

> See ?load, but you may be confused. Strictly speaking, there is no code in
> an .Rdata file, only a (typically binary, but possibly ascii)
> representation of objects, usually as produced by ?save. Of course,
> functions are also objects, so that if you load a file with functions, the
> function code is available.

> You can save and load command histories via ?savehistory, which, like 
?save
> and ?load can usually be accessed through any GUI interface that you are
> using.

> Warning: I believe the above is correct, but I may be wrong in at least
> some details, so give others a chance to reply and possibly correct.

> Cheers,
> Bert

> Bert Gunter

In spite of really not recommending to work with .RData but
rather with R *scripts*  (or R Sweave / R markdown documents),
an often forgotten considerably more flexible and in that sense better
alternative to load() in such situations is  attach()
which creates an environment in which the objects are loaded and
attaches that to the search() path.

Example (from my current R console):

> save.image() # creates .RData
> attach(".RData")
> ls.str(pos=2)
logi :  Named logi [1:3] FALSE NA TRUE
Mlibrary : function (pkg, lib = NULL, check64.32 = TRUE, ...)  
ncF :  int [1:5, 1:3] 5 6 2 1 15 5 6 2 1 15 ...
nchars : function (x, ...)  
ncT :  int [1:5, 1:3] 5 6 NA 1 15 5 6 NA 1 15 ...
x :  chr [1:5] "asfef" "qwerty" NA "b" "stuff.blah.yech"
> 

So, indeed,  ls.str()  comes handy as well..

Best,
Martin

__
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: the leading minor of order 6 is not positive definite

2021-10-28 Thread John Kane
I think we need the code you are running, any error messages you are
getting and some sample data. A handy way to supply sample data is to
use the dput() function. See ?dput.  If you have a very large data set
then something like head(dput(myfile), 100) will likely supply enough
data for us to work with.

On Mon, 25 Oct 2021 at 16:26, Sandhya Prakash
 wrote:
>
> Hi I'm too running a canonical correlation code but I'm getting my error like 
> this can you please help me
>
> Get Outlook for Android
>
> [[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.



-- 
John Kane
Kingston ON Canada

__
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 with RMySQL

2021-10-28 Thread Ken Peng
It seems like mysql server doesn't open the right authentication for your
access, such as user or host permissions.

Thanks.

On Thu, Oct 28, 2021 at 1:42 PM Ashim Kapoor  wrote:

> Dear R - users,
>
> I have 2 databases on a MySQL server. I am able to access the old one
> but not the freshly created one.
>
> library(RMySQL)
> # This one is the old one, I am able to access it,
> > con1<- dbConnect(MySQL(),host= "myserver", db="db1", user=
> "user1",password ="mypass1")
>
> # This is the new one. I am getting an error.
> > con2 <- dbConnect(MySQL(),host= "myserver", db="db2", user=
> "user2",password="mypass2")
> Error in .local(drv, ...) :
>   Failed to connect to database: Error: Access denied for user
> 'user2'@'myserver' (using password: YES)
> >
>
> Can someone please point me in the right direction? The error is not
> clear. I do not think I have mistyped the credentials.
>
> Many thanks,
> Ashim
>
> __
> 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] R vs Numpy

2021-10-28 Thread Catherine Walt
Hello members,

I am familiar with python's Numpy.
Now I am looking into R language.
What is the main difference between these two languages? including advantages 
or disadvantages.

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.


Re: [R] R vs Numpy

2021-10-28 Thread Sorkin, John
Catherine,

R is a program that is designed for the statistical analysis and visual display 
of data. Advantages and disadvantages depend on what you want to do with the 
language. 

John



From: R-help  on behalf of Catherine Walt 

Sent: Thursday, October 28, 2021 2:57 AM
To: r-help@r-project.org
Subject: [R] R vs Numpy

Hello members,

I am familiar with python's Numpy.
Now I am looking into R language.
What is the main difference between these two languages? including advantages 
or disadvantages.

Thanks.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=04%7C01%7CJSorkin%40som.umaryland.edu%7Cd7ce49543170430f10a208d99a3e8bc4%7C717009a620de461a88940312a395cac9%7C0%7C0%7C637710416263711233%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ada4s6jHFFpT09%2BnKV0hhXgA4dczZ88wNqqjMGED7Zg%3D&reserved=0
PLEASE do read the posting guide 
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=04%7C01%7CJSorkin%40som.umaryland.edu%7Cd7ce49543170430f10a208d99a3e8bc4%7C717009a620de461a88940312a395cac9%7C0%7C0%7C637710416263711233%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=qNxgDcGORjIZ4Q3BTkvdQ%2BRwODlFsFpFxwZCNyx06Vk%3D&reserved=0
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] R vs Numpy

2021-10-28 Thread J C Nash

https://www.ibm.com/cloud/blog/python-vs-r

On 2021-10-28 2:57 a.m., Catherine Walt wrote:

Hello members,

I am familiar with python's Numpy.
Now I am looking into R language.
What is the main difference between these two languages? including advantages 
or disadvantages.

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-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 vs Numpy

2021-10-28 Thread Jeff Newmiller
This is dangerously close to off topic, or at least it could be fuel for 
divisive argument rather than informed discussion (most readers here might be 
short on details of NumPy and long on details regarding R).

Have you used a search engine? Google found 
https://www.r-bloggers.com/2011/03/a-short-side-by-side-comparison-of-the-r-and-numpy-array-types/
 for me.

Under the hood, R and NumPy often use the same compiled code for numerical 
algorithms, so to some degree it is more a matter of taste in how you get at 
those algorithms.

On October 27, 2021 11:57:14 PM PDT, Catherine Walt  
wrote:
>Hello members,
>
>I am familiar with python's Numpy.
>Now I am looking into R language.
>What is the main difference between these two languages? including advantages 
>or disadvantages.
>
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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 vs Numpy

2021-10-28 Thread Avi Gross via R-help
I am not sure your overall question fits into this forum but a brief
internet search can find plenty of info.

But in brief, R is a language in which much of what numpy does was built in
from the start and many things are vectorized. Much of what the python
pandas language does is also part of native R. There are additional packages
(python called them modules) freely available that greatly extend those
capabilities and I doubt there is very much you can do in numpy that cannot
also often easily be done in R.

Realistically, there are several reasons the numpy module is so commonly
used in python. They left something like vectors out of the language. Yes,
they have dictionaries and lists and sets and all kinds of objects. So numpy
was made mostly in C to provide numeric processing of things that are more
like vectors efficiently. In R, everything is a vector as in a simple
variable is just a vector of length one!

I program in both and in other languages as many do. Reasons to choose one
or another vary. Python can do many things easily and with complexity and is
a rather full-blown and complex language with real object-oriented
capabilities and also functional programming. It is interpreted but also has
a way to save partially compiled code. R is pretty much all interpreted
albeit many things are written I C or C++ pr other compiled languages and
stuffed into libraries. 

One main reason to choose is programming style but there are TONS of
differences that can bite you such as R sometimes deferring evaluation of
code which can be an advantage or the opposite. But a huge reason I think
that people choose one or the other is the availability of packages that do
much of what they want. Some, for example, love a set of packages they call
the tidyverse and do much of their work largely within it rather than base
R. Many love the graphics package called ggplot.

But over time, I see more and more functionality available within the Python
community that rivals or perhaps exceeds such as the machine learning tools.

I have an interesting solution I sometimes use as you can run programs in R
using a package that allows the same data to be accessed back and forth
between an attached R interpreter and a Python interpreter. So if you want
to use python features like dictionaries and list comprehensions to massage
the data then have R do additional things and perhaps make graphs, you can
get some of both worlds.

As noted, a detailed answer is way beyond here. R has packages that probably
let you add things and it has too many object-oriented subsystems, most of
them not complete.

Good Luck,

Avi

-Original Message-
From: R-help  On Behalf Of Catherine Walt
Sent: Thursday, October 28, 2021 2:57 AM
To: r-help@r-project.org
Subject: [R] R vs Numpy

Hello members,

I am familiar with python's Numpy.
Now I am looking into R language.
What is the main difference between these two languages? including
advantages or disadvantages.

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-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 vs Numpy

2021-10-28 Thread Enrico Schumann
On Thu, 28 Oct 2021, Catherine Walt writes:

> Hello members,
>
> I am familiar with python's Numpy.
> Now I am looking into R language.
> What is the main difference between these two languages? including advantages 
> or disadvantages.
>
> Thanks.
>

Perhaps also of interest:
https://github.com/matloff/R-vs.-Python-for-Data-Science


-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
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] generate random numeric

2021-10-28 Thread Ken Peng
I saw runif(1) can generate a random num, is this the true random?

> runif(1)
[1] 0.8945383

What's the other better method?

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.


Re: [R] generate random numeric

2021-10-28 Thread Andrew Simmons
It might not be random, depending upon a seed being used (usually by
set.seed or RNGkind).

However, it's the best method for generating a random number within a
specified range without weights.

If you want weights, there are many other random number generation
functions, most notably rnorm. You can find a lot more in the stats
package.


On Fri, Oct 29, 2021, 02:39 Ken Peng  wrote:

> I saw runif(1) can generate a random num, is this the true random?
>
> > runif(1)
> [1] 0.8945383
>
> What's the other better method?
>
> 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.
>

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