Questions tagged [levels]
491 questions
2
votes
0 answers
Can 2 levels in a factor go missing in a generalised mixed effect model?
I ran this Generalised mixed effect model
glm1bd <- glmer(Abundance ~ Reason + Region + months.since.spill + bareground.cover +
litter.cover + Distance.to.nearest.bush + buildings + roads + (1|Site/Session/Point), warrispill,
…

Inieric
- 21
- 1
2
votes
2 answers
How to recode factor levels from a vector in tidyverse?
Consider the data set below, there is a factor No with 34 levels, I want to recode these levels according to newLvl
MWE
structure(list(No = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,…

doctorate
- 1,381
- 1
- 19
- 43
2
votes
1 answer
Making explicit implicit missing values in nested levels
I am trying to complete my dataframe with missing levels.
Current output
id foo bar val
1 a x 7
2 a y 9
3 a z 6
4 b x 10
5 b y 4
6 b z 5
7 c y 2
Data
structure(list(id = c("1", "2", "3", "4", "5", "6",…

tom
- 725
- 4
- 17
2
votes
2 answers
How can I sort a dataframe by a predetermined order of factor levels in R?
I have a data frame in which one column consists of unique factors. I want to sort this data frame by a predefined order of factor levels, independend of the original order.
For example my data looks like this:
label <- c('tree','lake','house',…

Katsuyo
- 63
- 1
- 5
2
votes
2 answers
in R, how to set and retain custom levels in factor with different labels?
in R, how to set and retain custom levels in factor with different labels ?
That is, I want to set custom numbers in the levels of a factor, and these numerical values - integers to be retained and not converted to "1, 2, 3 etc.".
I know that one…

Estatistics
- 874
- 9
- 24
2
votes
2 answers
How can I use a sub function in R to change a factor level that has a plus (+ ) symbol?
I ran into a hiccup using the sub() and gsub() functions in R to rename/change a factor level in R. But I'm not sure why it is not working.
Scenario:
I have some survey data that several factors with levels that truncate the high value. For…

Shawn Janzen
- 369
- 3
- 15
2
votes
1 answer
Filtering pandas df with level values
I have the following pandas df:
df
price max maxperhour
Site Commodity Type
Mid Biomass Stock 6.0 1.500000e+15 1.500000e+15
CO2 Env 0.0 1.500000e+15 …

oakca
- 1,408
- 1
- 18
- 40
2
votes
1 answer
Error comes up, when my test set has data which my train data doesn't have?
I have a dataset and have split it into train (80%) and test (20%) set.
First step is setting up decision tree and then I predict using my test set.
tree <- rpart(train$number ~ ., train, method = "class")
pred <- predict(tree,test, type…

pineapple
- 169
- 9
2
votes
1 answer
How this R syntax works?
For example, if we have a data frame called x in R with a column which have some levels and we want to obtain that levels as strings, this should work:
levels(x$column)[x$column]
Anyone can explain me how this R syntax works?
Thanks for your help

Héctor Olivera
- 25
- 4
2
votes
1 answer
Opacity Levels in Android Studio
I’ve searched and I haven’t found a way to get a certain level of transparency in a colored button while the text of the button is 100% visible.
There has been options to get certain levels of transparency in a button, but the text also becomes…

camjames
- 19
- 3
2
votes
2 answers
How do I load random levels?
I'm using Unity 3 to build my game. I have a basic GUI button that when clicked, I would like the user to be taken to a random level. There are 10 levels in my game. Below is a copy of the code I'm trying to implement.
function OnGUI()
{
//…

Digital D
- 51
- 2
- 5
2
votes
1 answer
Move same factor levels in different columns into same column in R
I have a dataframe with different variables that can share some factor levels:
id tag_1 tag_2 tag_3
1: 3 human NA artist
2: 5 human NA NA
3: 7 song artist human
4: 8 …

Tau
- 173
- 1
- 8
2
votes
2 answers
Python - Pandas - Fill missing data based on existing Levels
I use pandas and get my data from a SQL database
I have two tickers. One is a U.S stock, the other an European stock. Dates are not necessarily the same for both stocks (holidays, etc).
All my data is stored in a multi-index DataFrame.
Looking to…

ruh
- 139
- 3
- 9
2
votes
2 answers
How to convert the values in a dataframe to a dummy values by levels() function?
The given data is
SNP1 <- c("AA","GG","AG")
SNP2 <- c("AA","CC","AC")
SNP3 <- c("GG","AA","AG")
df<- data.frame(SNP1, SNP2, SNP3)
colnames(df)<- c('rs10000438', 'rs10000500','rs1000055')
I define a data function which is dominant_dummy. When I run…

user5802211
- 197
- 1
- 9
2
votes
1 answer
Reduce number of levels for each factor dplyr approach
I am trying to reduce the number of levels in each factor variable in my data. I want to reduce the number of levels doing 2 operations:
If the number of levels is larger than a cut-off then replace the less frequent levels to a new level until the…

Tobias Dekker
- 980
- 8
- 19