This question already has answers here:
Replace given value in vector
(8 answers)
How do I change a single value in a data.frame?
(4 answers)
How to change a single value in a data frame in R
(4 answers)
How to change a cell value in data.frame
(2 answers)
Closed 4 months ago.
I have the following data frame:
df <- data.frame(
item=c("a","","a","d","e"),
price_today=c(1,2,"THREE%%",4,"SIX/SIX"))
If I would like to select "THREE%%" and "SIX/SIX" in column price_today and convert them to "3?3" and "6?6", respectively, how should I go about it?
Related
This question already has answers here:
Group by multiple columns and sum other multiple columns
(7 answers)
How to sum a variable by group
(18 answers)
Closed 2 years ago.
I have this table:
I want to combine the rows, so that the values off the variables are in one row from the same month.
This question already has answers here:
How to drop columns by name pattern in R?
(6 answers)
Remove columns that contain a specific word
(5 answers)
Closed 3 years ago.
My data set has about 100 columns and some of them (about 25) are called similar but not them same. I'd like to delete all columns that start with "reads_per_million" because write this is so impractical:
data_tumor <- data_tumor[,-c(3,5,7,13,15,22,33,54,65,34,**etc,etc**)]
Thank you so much
This question already has answers here:
How do I make a matrix from a list of vectors in R?
(6 answers)
Combine a list of data frames into one data frame by row
(10 answers)
Closed 5 years ago.
I have a dat frame called crimeLARaw_tbl_final.
One of the columns called location_1.coordinates, is a ‘list’ data type column which contains a list of values:
location_1.coordinates
c(-118.3157, 34.0454)
c(-118.2717, 34.001)
c(-118.2671, 34.0294)
c(-118.4517, 33.967)
How could I bring each value in the list to its own column?
long lat
-118.3157 34.0454
-118.2717 34.001
-118.2671 34.0294
-118.4517 33.967
I have tried with dplyr and stringr but not getting anywhere.
Thank you
This question already has answers here:
How to count the number of unique values by group? [duplicate]
(1 answer)
Unique values in each of the columns of a data frame
(9 answers)
Closed 5 years ago.
Is there better way to compute this instead of:
length(unique(vector))
let's assume that we donno what class is the vector.
You can use
library(data.table)
vector <- c(1,2,2,2,3)
uniqueN(vector)
This question already has answers here:
How do you remove columns from a data.frame?
(12 answers)
Remove an entire column from a data.frame in R
(8 answers)
Closed 6 years ago.
dataframename <- data.frame(
col1=1:10,
col2=10:1,
col3=1:50,
col4=11:20
)
Consider the above dataframe and I want to remove column 1 and column 4.
1. Without using any package.
2. The answer should be in dataframe format only and not vector results.
###Use subset command:###
dataframename <- subset(dataframename, select = -c(col1,col4) )
###One more approach is you can use list(NULL) to the dataframe:###
dataframename[,c("col1","col4")] <- list(NULL)