Re: [R] Odd behavior of a function within apply

2022-08-09 Thread Erin Hodgess
My “count1a” function was only looking for types of integers and characters. There were a few logical types, which were the source of the error. Thanks, Erin On Tue, Aug 9, 2022 at 11:33 AM David Carlson wrote: > Could you have columns that are not character or integer so that y is > never def

Re: [R] Odd behavior of a function within apply

2022-08-09 Thread David Carlson via R-help
Could you have columns that are not character or integer so that y is never defined in the function? count1a(1:5/3) Error in count1a(1:5/3) : object 'y' not found David Carlson On Mon, Aug 8, 2022 at 1:35 PM Erin Hodgess wrote: > OK.⁠​ I'm back again.⁠​ So my test1.⁠​df is 236x390 If I put in

Re: [R] Odd behavior of a function within apply

2022-08-08 Thread John Fox
Dear Erin, The problem is that the data frame gets coerced to a character matrix, and the only column with "" entries is the 9th (the second one you supplied): as.matrix(test1.df) X1_1_HZP1 X1_1_HBM1_mon X1_1_HBM1_yr 1 "48160" "December""2014" 2 "48198" "June""2018" 3 "8

[R] Odd behavior of a function within apply

2022-08-08 Thread Erin Hodgess
Hello! I have the following data.frame dput(test1.df[1:10,8:10]) structure(list(X1_1_HZP1 = c(48160L, 48198L, 80027L, 48161L, NA, 48911L, NA, 48197L, 48021L, 11355L), X1_1_HBM1_mon = c("December", "June", "August", "", "", "August", "April", "February", "", "December"), X1_1_HBM1_yr = c(2014L, 20