Is there a way to create a “dictionary” in R, such that it has pairs? Something to the effect of:
x=dictionary(c("Hi","Why","water") , c(1,5,4)) x["Why"]=5
I’m asking this because I am actually looking for a two categorial variables function.
So that if x=dictionary(c(“a”,”b”),c(5,2))
x val 1 a 5 2 b 2
I want to compute x1^2+x2 on all combinations of x keys
x1 x2 val1 val2 x1^2+x2 1 a a 5 5 30 2 b a 2 5 9 3 a b 5 2 27 4 b b 2 2 6
And then I want to be able to retrieve the result using x1 and x2. Something to the effect of: get_result[“b”,”a”] = 9
what is the best, efficient way to do this?
Related Posts:
- R Hex to RGB converter
- How do I select the first row in an R data frame that meets certain criteria?
- Error in file(file, “rt”) : cannot open the connection [duplicate]
- Error in
: object of type ‘closure’ is not subsettable - How to join (merge) data frames (inner, outer, left, right)
- Interpreting “condition has length > 1” warning from `if` function
- rbind error: “names do not match previous names”
- rbind error: “names do not match previous names”
- How to coerce a list object to type ‘double’
- $ operator is invalid for atomic vectors for dataframe R
- Plotting with ggplot2: “Error: Discrete value supplied to continuous scale” on categorical y-axis
- ggplot2 error : Discrete value supplied to continuous scale
- ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”
- R programming: How do I get Euler’s number?
- adding x and y axis labels in ggplot2
- Set NA to 0 in R
- ‘x’ and ‘y’ lengths differ ERROR when plotting
- What are the “standard unambiguous date” formats for string-to-date conversion in R?
- ‘x’ and ‘y’ lengths differ ERROR when plotting
- What are the “standard unambiguous date” formats for string-to-date conversion in R?
- Difference between paste() and paste0()
- Remove duplicated rows
- Error in colMeans(x, na.rm = TRUE) : ‘x’ must be numeric in KNN classification
- Error in ggplot.data.frame : Mapping should be created with aes or aes_string
- Error in plot.window(…) : need finite ‘xlim’ values
- Editing legend (text) labels in ggplot
- case_when in mutate pipe
- Logistic Regression on factor: Error in eval(family$initialize) : y values must be 0 <= y <= 1
- dim(X) must have a positive length when applying function in data frame
- Extract year from date
- Error: attempt to use zero-length variable name
- incorrect number of dimensions and incorrect number of subscripts in array
- How to debug “contrasts can be applied only to factors with 2 or more levels” error?
- R error: cannot coerce type ‘closure’ to vector of type ‘double’
- Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) : NA/NaN/Inf in ‘y’, tried every possible way
- R t-test Grouping factor must have exactly 2 levels error
- What does c do in R?
- Understanding the order() function
- Error in lis[[i]] : attempt to select less than one element
- Plot a line graph, error in xy.coords(x, y, xlabel, ylabel, log) : ‘x’ and ‘y’ lengths differ
- How to compute weighted mean in R?
- Calculate correlation for more than two variables?
- How to count the number of observations in R like Stata command count
- Remove all of x axis labels in ggplot
- Sum rows in data.frame or matrix
- Create an empty data.frame
- Can’t draw Histogram, ‘x’ must be numeric
- MLE error in R: initial value in ‘vmmin’ is not finite
- Rename multiple columns by names
- What is the difference between rm() and rm(list=ls())?
- Remove rows with all or some NAs (missing values) in data.frame
- Convert date-time string to class Date
- How do you create vectors with specific intervals in R?
- Linear model function lm() error: NA/NaN/Inf in foreign function call (arg 1)
- Remove rows with all or some NAs (missing values) in data.frame
- Converting data frame column from character to numeric
- Singularity in backsolve at level 0, block 1 in LME model
- Nested ifelse statement
- How do I get RSS from a linear model output
- Warning message: In `…` : invalid factor level, NA generated
- Plot two graphs in same plot in R
- How to overcome error:”attempt to set ‘colnames’ on an object with less than two dimension” in xts object
- ggplot2 manually specifying colour with geom_line
- remove all variables except functions
- How to update a package in R?
- Error: Invalid input: date_trans works with objects of class Date only
- Run R script from command line
- Matrix expression causes error “requires numeric/complex matrix/vector arguments”?
- NAs are not allowed in subscripted assignments
- What’s the difference between facet_wrap() and facet_grid() in ggplot2?
- ggplot2, facet_grid, free scales?
- How do I install an R package from source?
- How can I convert Json to data frame in R
- lmer error: grouping factor must be < number of observations
- R Error (from NA’s to 0): duplicate subscripts for column in Data Frame
- Error in rbind(deparse.level, …) : numbers of columns of arguments do not match R
- Creating box plot on exercise
- What is the meaning of the dollar sign “$” in R function()?
- How to sort a data frame by alphabetic order of a character variable in R?
- Error in na.fail.default(as.ts(x)) : missing values in object in time series forecasting
- Argument “No” is missing, with no default
- R apply function with multiple parameters
- Geometric Mean: is there a built-in?
- Error in eval(predvars, data, env) : invalid ‘envir’ argument of type ‘character’
- Error in na.fail.default: missing values in object – but no missing values
- Error: Invalid number of ‘breaks’ in R
- Efficiently sum across multiple columns in R
- Convert the values in a column into row names in an existing data frame
- Deleting rows that are duplicated in one column based on the conditions of another column
- Replace all 0 values to NA
- The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframe
- Merge error : negative length vectors are not allowed
- non-numeric argument to binary operator
- Error Error in storage.mode(x) <- "double" : 'list' object cannot be coerced to type 'double'
- Column standard deviation R [duplicate]
- Meaning of objects being masked by the global environment
- Subset and ggplot2
- Create a matrix of scatterplots (pairs() equivalent) in ggplot2
- How do I print a hexadecimal number with leading 0 to have width 2 using sprintf?
- In R, dealing with Error: ggplot2 doesn’t know how to deal with data of class numeric