tl;dr you have to use na.exclude()
(or whatever) on the whole data frame at once, so that the remaining observations stay matched up across variables …
set.seed(101) tot_nochc=runif(10,1,15) cor_partner=factor(c(1,1,0,1,0,0,0,0,1,0)) age=runif(10,18,75) agecu=age^3 day=factor(c(1,2,2,3,3,NA,NA,4,4,4)) ## use data.frame() -- *DON'T* cbind() first dt=data.frame(tot_nochc,cor_partner,agecu,day) ## DON'T attach(dt) ...
Now try:
library(nlme) corpart.lme.1=lme(tot_nochc~cor_partner+agecu+cor_partner *agecu, random = ~cor_partner+agecu+cor_partner *agecu |day, data=dt, na.action=na.exclude)
We get convergence errors and warnings, but I think that’s now because we’re using a tiny made-up data set without enough information in it and not because of any inherent problem with the code.
Related Posts:
- Poker hand range chart visualization in R
- Error in plot.new() : figure margins too large, Scatter plot
- What does %>% function mean in R?
- R on MacOS Error: vector memory exhausted (limit reached?)
- Remove legend ggplot 2.2
- R: Using equation with natural logarithm in nls
- How to change legend title in ggplot
- kmeans complains “NA/NaN/Inf in foreign function call (arg 1)”, when there are none?
- Why use as.factor() instead of just factor()
- Update R using RStudio
- mean() warning: argument is not numeric or logical: returning NA
- What does “Error: object ‘
‘ not found” mean? - mean() warning: argument is not numeric or logical: returning NA
- How do I delete rows in a data frame?
- Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Polygon edge not found
- Drop data frame columns by name
- Having trouble setting working directory
- How to find the statistical mode?
- How can two strings be concatenated?
- SummarySE (Rmisc package) to produce a barplot with error bars (ggplot2)
- Remove a row from a data table in R
- R ggplot2 scale_y_continuous : Combining breaks & limits
- Add color to boxplot – “Continuous value supplied to discrete scale” error
- Error in plot.window(…) : need finite ‘xlim’ valuescc
- rmarkdown error “attempt to use zero-length variable name”
- Error: Incorrect number of dimensions in R
- cannot coerce type ‘closure’ to vector of type ‘character’
- Basic – T-Test -> Grouping Factor Must have Exactly 2 Levels
- R – longer object length is not a multiple of shorter object length
- How does one reorder columns in a data frame?
- R: Using equation with natural logarithm in nls
- remove legend title in ggplot
- scale_color_manual() not working
- Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) 0 non-na cases
- Clear R environment of all objetcs & packages
- Why I get this error writing data to a file
- R: need finite ‘ylim’ values in function
- How to save a data frame as CSV to a user selected location using tcltk
- Convert a list to a data frame
- Manually colouring plots with `scale_fill_manual` in ggplot2 not working
- Subscript out of bounds – general definition and solution?
- R: Error in eval(predvars, data, env) : numeric ‘envir’ arg not of length one in intrinsic.pars() in multgee package
- Convert a list to a data frame
- Remove grid, background color, and top and right borders from ggplot2
- R: “Unary operator error” from multiline ggplot2 command
- What does the double percentage sign (%%) mean?
- not a Stata version 5-12 .dta file
- How to subset a Data frame column wise using column names?
- Error : length of ‘dimnames’ [2] not equal to array extent
- Mean of a column in a data frame, given the column’s name
- How can I plot data with confidence intervals?
- No non-missing arguments warning when using min or max in reshape2
- Unimplemented type list when trying to write.table
- Having trouble setting working directory
- Custom legend for multiple layer ggplot
- Subscript out of bounds – general definition and solution?
- file.path function in R
- Reshaping data.frame from wide to long format
- How to set limits for axes in ggplot2 R plots?
- duplicate ‘row.names’ are not allowed error
- predict.lm() in a loop. warning: prediction from a rank-deficient fit may be misleading
- Convert categorical variables to numeric in R
- How to sum data.frame column values?
- Error: invalid subscript type ‘list’ in R
- “non-numeric argument to binary operator” error in R
- readOGR() cannot open file
- What does “The following object is masked from ‘package:xxx'” mean?
- grep using a character vector with multiple patterns
- How to avoid “Error in stripchart.default(x1, …) : invalid plotting method” error?
- R error in unique.default(x) unique() applies only to vectors
- Unused arguments in R
- How to convert a data frame column to numeric type?
- Boxplot dplyr: Error: non-numeric argument to binary operator
- How do I install an R package from source?
- Getting invalid model formula in ExtractVars when using rpart function in R
- Error: ggplot2 doesn’t know how to deal with data of class matrix?
- Aggregate multiple columns at once
- Error in match.fun(FUN)
- Error in file(filename, “r”, encoding = encoding) : cannot open the connection
- installing data.table results in “there is no package”
- What is integer overflow in R and how can it happen?
- R histogram range error: some ‘x’ not counted; maybe ‘breaks’ do not span range of ‘x
- Correct syntax for mutate_if
- Plotting data in R; error: default method not implemented for type ‘list’
- Error:attempt to apply non-function
- Error in contrib.url(repos, “source”) in R trying to use CRAN without setting a mirror Calls: install.packages -> contrib.url Execution halted
- Changing fonts in ggplot2
- Error in
: target of assignment expands to non-language object - How do I combine two data-frames based on two columns?
- How to eliminate “NA/NaN/Inf in foreign function call (arg 7)” running predict with randomForest
- Indicator function in R
- Batch convert columns to numeric type
- IF “OR” multiple conditions
- R4DS error comparison (1) is possible only for atomic and list types
- Error in x[[i]] : recursive indexing failed at level 2
- How to avoid “operations are possible only for numeric, logical or complex types” when computing top 3 elements in each group
- Warning: non-integer #successes in a binomial glm! (survey packages)
- Difference between as.POSIXct/as.POSIXlt and strptime for converting character vectors to POSIXct/POSIXlt
- invalid (do_set) left-hand side to assignment in R
- How to deal with “data of class uneval” error from ggplot2?