My code was working and then RStudio crashed. When I opened it back up, a line of my code is not working now...
CodeTable<-count(unique(Data$Code))
Previously, this created a simple database of 3 columns: 1) Numeric order, 2)the unique Code, and 3) the count of each Code (which was always 1, since they were counted as unique). Now, I am receiving an error message:
Error in UseMethod("summarise_") :
no applicable method for 'summarise_' applied to an object of class "character"
I don't believe anything was changed from R crashing and I don't know how to now create my little 'count' table I had before.
count from dplyr requires input as a data.frame
library(dplyr)
Data %>%
count(Code)
In base R, we can do
table(Data$Code)
Related
My code was working and then RStudio crashed. When I opened it back up, a line of my code is not working now...
CodeTable<-count(unique(Data$Code))
Previously, this created a simple database of 3 columns: 1) Numeric order, 2)the unique Code, and 3) the count of each Code (which was always 1, since they were counted as unique). Now, I am receiving an error message:
Error in UseMethod("summarise_") :
no applicable method for 'summarise_' applied to an object of class "character"
I don't believe anything was changed from R crashing and I don't know how to now create my little 'count' table I had before.
count from dplyr requires input as a data.frame
library(dplyr)
Data %>%
count(Code)
In base R, we can do
table(Data$Code)
UPDATE: i uninstalled and reinstalled dplyr and now its working fine. Not sure why this happens
Often times when I'm using dplyr functions I get this error, "Evaluation error: argument "n" is missing, with no default."
It happens for random operations I use inside dplyr but I'll show a simple one I'm getting with the mutate function. Analyzing the years baseball players played in a df called hof, I have a "From" column which is their first year, and a "To" column which is their last year (neither column has any missing values and both are numeric). I'm using mutate to find their middle year
*Note: I'm sure there are other ways to do this without dplyr but I want to solve this issue since it happens to me often with filter as well
I've made sure commas, parenthesis, and all words are used correctly. I've also tried calling the function directly like dplyr::mutate
hof <- hof %>%
dplyr::mutate(MidCareer = (From + To) / 2)
And the error message
Error in mutate_impl(.data, dots) :
Evaluation error: argument "n" is missing, with no default.
I am new to SparkR, so please forgive if my question is very basic.
I work on databricks and try to get all unique dates of a column of a SparkDataFrame.
When I run:
uniquedays <- SparkR::distinct(df$datadate)
I get the error message:
unable to find an inherited method for function ‘distinct’ for signature ‘"Column"’
On Stack Overflow, I found out that this usually means
(If I run isS4(df), it returns TRUE):
That is the type of message you will get when attempting to apply an S4 generic function to an object of a class for which no defined S4 method exists
I also tried to run
uniquedays <- SparkR::unique(df$datadate)
where I get the error message:
unique() applies only to vectors
It feels like, I am missing something basic here.
Thank you for your help!
Try this:
library(magrittr)
uniquedays <- SparkR::select(df, df$datadate) %>% SparkR::distinct()
I have tried multiple variations of the rename function in dplyr.
I have a data frame called from a database called alldata, and a column within the data frame named WindDirection:N. I am trying to rename it as Wind Direction. I understand creating variable names containing spaces is not a good practice, but I want it to be named as such to improve readability for a selectInput list in shiny, and even if I settle for renaming it WindDirection I am getting all of the same error messages.
I have tried:
rename(alldata, Wind Direction = WindDirection:N)
which gives the error message:
Error: unexpected symbol in "rename(alldata, Wind Direction"
rename(alldata, `Wind Direction` = `WindDirection:N`)
which does not give an error message, but also does not rename the variable
rename(alldata, "Wind Direction" = "WindDirection:N")
which gives the error message:
Error: Arguments to rename must be unquoted variable names. Arguments Wind Direction are not.
I then tried the same 3 combinations of the reverse order (because I know that is how plyr works even though I do not call it to be used using the library command earlier in my code) putting the old variable first and the new variable 2nd with similar error messages.
I then tried to specify the package as I have 1 example below and tried all 6 combinations again.
dplyr::rename(alldata, `Wind Direction` = `WindDirection:N`)
to similar error messages as the first time.
I have used the following thread as an attempt to do this myself.
Replacement for "rename" in dplyr
as agenis pointed out, my mistake was not redefining the dataframe after renaming the variable.
So where I had
dplyr::rename(alldata,Wind Direction=WindDirection:N)
I should have
alldata <- dplyr::rename(alldata,Wind Direction=WindDirection:N)
I am doing following in Cooccur library in R.
> fb<-read.table("Fb6_peaks.bed")
> f1<-read.table("F16_peaks.bed")
everything is ok with the first two commands and I can also display the data:
> fb
> f1
But when I give the next command as given below
> explore_pairs(c("fb", "f1"))
I get an error message:
Error in sum(sapply(tf1_s, score_sample, tf2_hits = tf2_s, hit_list = hit_l)) :
invalid 'type' (list) of argument
Could anyone suggest something?
Despite promising to release a version to the Bioconductor depository in the article the authors published over a year ago, they have still not delivered. The gz file that is attached to the article is not of a form that my installation recognizes. Your really should be corresponding with the authors for this question.
The nature of the error message suggests that the function is expecting a different data class. You should be looking at the specification for the arguments in the help(explore_pairs) file. If it is expecting 2 matrices, then wrapping data.matrix around the arguments may solve the problem, but if it is expecting a class created by one of that packages functions then you need to take the necessary step to construct the right objects.
The help file for explore_pairs does exist (at least in the MAN directory) and says the first argument should be a character vector with further provisos:
\arguments{
\item{factornames}{an vector of character strings, each naming a GFF-like
data frame containing the binding profile of a DNA-binding factor.
There is also a load utility, load_GFF, which I assume is designed for creation of such files.
Try rename your data frame:
names(fb)=c("seq","start","end")
Check the example datasets. The column names are as above. I set the names and it worked.