• Register
1 vote
1.2k views

Problem :

Currently I am learning the r programming. I am unable to find the answer to below error but I am unable to do so. Currently I have one dataframe it has a column of strings. My task is to count the exact number of characters present in each entry of a column and then replace a string column with a counts.

Please find below the error for your reference:

data[,29]=apply(data[,29],nchar())
Out[2]: Error in match.fun(FUN): argument "FUN" is missing, with no default   
Error in match.fun(FUN): argument "FUN" is missing, with no default

Can someone guide me in fixing above error?

8 5 2
3,230 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution :

I went through your issue and I came to know that you are beginner so I am trying to help you.

I guess there are many problems with your code so you are facing above error.

So you need to first apply operators on your matrix or on your data.frame. I guess you wanted to use the sapply instead.

The next problem is with nchar() calls the nchar without any argument in it. So you must use nchar as the function name and you should avoid calling it  as the calling will happen inside sapply as shown below:

data[, 29] = sapply(data[,29], nchar)
8 4
5,680 points

Related questions

0 votes
1 answer 7 views
7 views
Problem: error in sort(y) : argument "y" is missing, with no default.
asked Feb 16 charles mathews 3.8k points
0 votes
1 answer 57 views
0 votes
1 answer 392 views
1 vote
2 answers 778 views
778 views
Problem : I am very new to R. I am facing a issue while entering CurrentDay. I had previously created it as below : Transaction <- function(PnL, Day)   results <- list(a = PnL, b = Day)  return(results) The above PnL and Day are both numeric values. Day ... /MA  return(MAValue) } Please guide me why am I receiving below error? Error in fun(left, right) : non-numeric argument to binary operator.
asked Apr 14, 2020 morrisBson 3.2k points
0 votes
1 answer 2.1K views
2.1K views
Problem : I have been facing below error message and traceback: Error in FUN(X[[i]], ...) : only defined on the data frame with all numeric variables 5 stop("only defined on the data frame with all numeric variables") 4 FUN(X[[i]], ...) 3 lapply(args, ... .numeric(data[good,]) But now I get the different error message back as below : "Error: (list) object cannot be coerced to type 'double'"
asked Dec 16, 2019 alecxe 7.5k points
0 votes
1 answer 575 views
575 views
Problem: I have only the fundamental knowledge related to R. I want to simulate the very basic moving average process in R which is as shown below for your reference: x_t = Z_(t-1)-0.4Z_(t-2)+Z_t. Please find below my code in R: z = rnorm(500, 0, 1) x ... was unable to find the exact solution for my above error. I am looking for some help from R expert if possible to fix my above R related error.
asked Aug 12, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 794 views
794 views
Problem : I want to use the neural net for predictions. I am trying to create some X as follows : x <- cbind(seq(1, 50, 1), seq(51, 100, 1)) I am trying to create some Y as follows : y <- x[,1]*x[,2] Give them the names as follows colnames(x) ... =0.01) error in terms.formula(formula) : '.' in formula and no 'data' argument Does anybody have any idea regarding the error I am facing? Any solution?
asked Dec 11, 2019 alecxe 7.5k points
0 votes
1 answer 188 views
188 views
Problem : My R code is giving me following error promise already under evaluation: recursive default argument reference or earlier problems?
asked Nov 18, 2019 peterlaw 6.9k points
0 votes
1 answer 1.2K views
1.2K views
Problem : I have about 25 dataframes which are essentially the frequency counts of my elements stored in the column called Elements. They all have some of the different and some of the the same elements in my Elements columns so they just look like below : dataframe called ... on them but facing below error: Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match .
asked Dec 24, 2019 alecxe 7.5k points
1 vote
1 answer 144 views
144 views
Problem : I am very new to R. Currently I need to embed RInside to the required application on the windows 7 64-bit Operating system but if I try to initialize the RInside as shown below: Rin = new RInside(argc, argv); I often face the message as shown below for ... done lot of research to fix above R error but unable to fix it. So looking for R expert who can help in quick fixing above error.
asked May 5, 2020 stewart 4k points