how to edit data in R? - r

> edit(data.frame())
Error in dataentry(datalist, modes) : invalid device
In addition: Warning message:
In edit.data.frame(data.frame()) : unable to open X Input Method
my system is: debian6.04+R-2.15.1
what is the matter?

If you are on a MAC and just installed XQuartz, you must restart your computer to get the X11 capabilities.

I experienced exactly the same problem on linux and I noticed that it was a problem of input and locale settings. I solved by clearing the following variables in the environment
$ export XMODIFIERS=
$ export GTK_IM_MODULE=
Then it worked fine.

Related

R 64-bit shiny ERROR: invalid 'nchars' argument

I am currently moving a (localhost) shiny App from a windows 32-bit to windows 64-bit . Google didn't managed to answer my problem :( so I'm asking the community !
This App worked fine on 32 bits, I had to re-install R, all Packages, Java on the 64-bit machine (each in the 64-bit mode). My app has the following file architecture :
a gloabl.R file where I load libraries
a server.R
List item
a ui.R
another file which format data to be sent d3/nvd3
a JS file to display a linechart.
the error I have is the following :
Warning in file(con, "rb") : file("") only supports open = "w+" and
open = "w+b": using the former Warning: Error in readChar: invalid
'nchars' argument Stack trace (innermost first):
1: runApp Error : invalid 'nchars' argument
When I'm running code without shiny, all works fine, all is precessed and results are good.
Does anyone has ever been facing to this ?
If you need anything just ask I will be more specific. I am not giving you the code, he is a little tricky and is in multiple files... And I think it is specific to my new environement.
Reinstalling solely the shiny-package fixed the problem for me. I am using R-studio, and did the operation through the Packages window (deleted and reinstalled).

R installed.packages() randomly stopped working on windows 7

installed.packages() command in R lists your installed packages. Mine was working for almost a year and then this command randomly started throwing an error. As this is a built-in command, I am not even sure how to "reinstall" it or address this. Any ideas how to fix the error and get the command working again?
> installed.packages()
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file `'C:\Users\Mitch\AppData\Local\Temp\Rtmp6Dawpa/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'`
One suggestion on here involved this in combination:
.libPaths()
installed.packages(lib.loc = 'my path')
The results of this produced yet another error as shown here. Looks like an issue with the installed file still but how to address is the question:
> installed.packages(lib.loc = 'C:/ProgramFilesCoders/R/R-3.3.2/library')
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file 'C:\Users\Mitch\AppData\Local\Temp\Rtmp6Dawpa/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'
>
That is odd.
What version of R are you running, standard R or Microsoft R? And did you recently update?
If you did recently update, perhaps your packages did not get copied over, hence the 'No such file or directory' statement.
If you haven't updated, I would install a newer version and see if it fixes the issue.
If your uncertain, you can always use the updateR function to check if you have the latest version and choose to install it or not.
library(installr)
updateR()
Good luck,
I think the issue lies in terms of the where the function is looking for the package information. installed.packages() needs an argument lib.loc.
From official documentation
lib.loc character vector describing the location of R library trees to search through
Looks like the function for some reason is looking in AppData\Local\Temp which is the download location and not the installed location.
Without looking at your R_Home and .libPaths() is difficult to nail down where the problem is, however running .libPaths() should give you one or more paths as shown in the below example. None of these should be temp locations.
>.libPaths()
[1] "C:/Users/UserName/Documents/R/win-library/3.4"
[2] "C:/Program Files/R/R-3.4.0/library"
If not, you can set the path within the .libPaths("your path") or pass the path of the library as part of installed.packages(lib.loc = 'your path') and try again.
Sometimes the most simple obvious solution is what works:
I closed my RStudio environment saving it to .RData
I re-opened RStudio and tried the command again
it worked
For the future, some good ideas got posted on here before I thought to try the above. Here are the suggestions that others included in case the above does not work if this problem is encountered by anyone in the future:
Use .libPaths() to find out proper path where this is installed, and then re-run the command with the path included in it like so: installed.packages(lib.loc = 'your path')
Try debugging it with: debug(installed.packages); Expectation is that we will likely find something wrong with .readPkgDesc(lib, fields) while stepping through debug. This was not tried yet so you may encounter things not written up here when you do try it.
Try Updating R in case it is out of date with these commands: library(installr) and updateR().

Error while using h2o.init in R

This is the error message:
> h2o.init()
Error in dirname(path) : path too long
In addition: There were 12 warnings (use warnings() to see them)
This is one of the warning messages (the others are similar):
> warnings()
Warning messages:
1: In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="\\FILE-EM1-06/USERDATA2$/john134/My Documents/./../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../..": The filename or extension is too long
Any idea how to work around this error?
Thanks
It seems that Windows path string is limited to (maybe) 256 length. Usually, setting a the path setwd(shorterExistingWorkDir) works and should address your issue.
I struggled with this issue quite a bit, including upgrading.
Most folks are assuming that you've literally just set an incredibly long path. I don't think this is the case (it wasn't for me, at least). It's that the PATH may be set on a network drive or other device where the underlying mapped paths are more complicated.
A related thread is here on the H2O forum:
Main issue is the user had a Windows drive that did not conform to the norm, i.e., "C://", etc. Instead, the user had a network drive
(DTCHYB-AZPX015/). This caused issues in the search for a config
file as there was no "root" (In this case, "root" is reaching your Win
drive). Since there was no "root", the path to search kept expanding
until it caused R to error out with the above exception.
The fix is to NOT search for a config when h2o.init() is called. Rather, only search for a config if a user asks to do so. My proposal
is to add a new field to h2o.init()called ignore_config. This
field will be set to TRUE by default.
When calling h2o.init() the R environment signal the launching of h2o application (actually a web server) in the backend which was installed when you install H2O package into R. The local runtime environment uses the full path of the location where H2O jar file is located. Because the packages is installed deep inside the nested folders in your file system it cross the valid limit of OS path 256 character length and fails to launch the backend H2O server and you see this error. In your case you are using external path so adds up more characters in the path to make the problem worse..
For example the h2o.jar is located in my OSX machine as below:
/Library/Frameworks/R.framework/Resources/library/h2o <-- H2O package Path
/Library/Frameworks/R.framework/Resources/library/h2o/java/h2o.jar <-- Jar Path
As you are using Windows, what you need is to find ways to reduce this path to OS limit and it will work.
The other solution is to run h2o.jar separately and then just use R to connect to H2O cluster. The steps are as below:
Download H2O 3.10.4.2 and unzip to a folder close to root so you do not hit 265 char limit again. Also install 3.10.4.2 R Package. (Try to keep the same version)
Run H2O > java -jar h2o.jar
From RStudio console try > h2o.init()
So if there is already H2O cluster running the h2o.init() will connect to a running H2O cluster instead to start one and you will by pass above problem.
If you hit any problem write here and we will help you.

Why is RSelenium always giving an error when I want to define a Firefox profile

I am using RSelenium and want to set a Firefox profile. So I tried to reproduce the example of the answer to this question. However, no matter what I change I always get the following error. What am I doing wrong?
I already read in the RSelenium manual that for windows systems RTools should be installed when one wants to make a Firefox profile. I did but nothing changed.
The error is the following:
Error in file(tmpfile, "rb") : cannot open the connection
In addition: Warning messages:
1: running command '"zip" -r9Xjq "C:\Users\mariu\AppData\Local\Temp\RtmpQfl3bl\file15c41fc2411d.zip" "C:\Users\mariu\AppData\Local\Temp\RtmpQfl3bl/firefoxprofile/prefs.js" ' had status 127
2: In file(tmpfile, "rb") :
cannot open file 'C:\Users\mariu\AppData\Local\Temp\RtmpQfl3bl\file15c41fc2411d.zip': No such file or directory
the problem is that Rselenium cannot create a zip file of your Firefox Profile (error status 127), therefore cannot read it in the next command line.
I resolved following this answer:
Create zip file: error running command " " had status 127 .
Do as the link says , shut down R, restart your pc and it should work.
Thanks,
Rob
Sometimes, for some reasons, it is not enough to add Rtools file location to Environmental Variables as was mentioned here. To solve the problem you need to add path within R using folowing code:
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
Then PC needs to be reseted. After that you can check whether path was setted correctly.
Sys.which("make")
## "C:\\rtools40\\usr\\bin\\make.exe
If output of sys.which is "" then something went wrong. By the way the entire procedure has been described here: https://cran.r-project.org/bin/windows/Rtools/.

RStudio Server error when restarting the R session

This recently began to appear whenever I restart my RStudio Server session:
Error in tools:::httpdPort > 0 :
comparison (6) is possible only for atomic and list types
It does not seem to relate to running any code (all I do to reproduce it is to go to the Session menu and then click "Restart R"). It appears that we are running version 0.97.551.
What is this error and how can we resolve it?
This has been fixed. Try updating everything to the latest version.
https://support.rstudio.com/hc/en-us/community/posts/202656007-Cryptic-error-on-starting-RStudio-daily-with-R-devel
What does "Error in tools:::httpdPort <= 0L : ...." in Rstudio means?

Resources