How to fix json code to split in a table using dplyr

I’m trying to split this json code into an easier way to parse my data, I have tried to use jsonlite with fromJSON() but doesn’t work. Data { "PROB": 0.066977381909206, "Y": -3.221016563928024, "x": 933 } library(jsonlite) jsonStr <- ‘{ "PROB": 0.066977381909206, "Y": -3.221016563928024, "x": 933 }’ t = fromJSON(jsonStr) > t $PROB [1] 0.06697738 $Y… Read More How to fix json code to split in a table using dplyr

How can I remove the values of a column of a data set that contain specific number of digits in R using dplyr?

I have a data set that looks like this : vec = c(989, 987, 145, 315, 8449, 9999999999000) char = c("a","b","c","d","e","f") df2 = tibble(vec,char);df2 # A tibble: 6 × 2 vec char <dbl> <chr> 1 989 a 2 987 b 3 145 c 4 315 d 5 8449 e 6 9999999999000 f I want to… Read More How can I remove the values of a column of a data set that contain specific number of digits in R using dplyr?

Concatenate dataframe with difrent dimension

I have data that are stored in three different data frames with different lengths. Below you can see my data : df<-data.frame( retail_seling_price=c(10), quantity_10=c(1000) ) df df1<-data.frame( retail_seling_price=c(100,200,300), quantity_18=c(1000,2000,3000) ) df1 df2<-data.frame( retail_seling_price=c(100,200,300,400), quantity_18=c(1000,2000,3000,0) ) df2 So now I want to merge all these data frames into one data frame, as in the pic shown… Read More Concatenate dataframe with difrent dimension

Calculate overall mean of multiple columns by group

I have several columns with reaction times (RT) per participant. This is a simplified version of the dataframe I have (in reality I have 20 RT columns): df <- data.frame(id=c(1,1,1,5,5,5), RT_0=c(0.467,NA,0.634,0.416,NA,0.35), RT_1=c(0.3,0.35,0.301,0.267,0.3,0.449), RT_2=c(1.251,NA, 0.334,0.34, 0.317,0.42), RT_3=c(0.284,0.316,0.283,0.367,0.55,0.35),pos=c(1,6,2,4,2,6)) id RT_0 RT_1 RT_2 RT_3 pos 1 0.467 0.3 1.251 0.284 1 1 NA 0.35 NA 0.316 6 1… Read More Calculate overall mean of multiple columns by group

Group by, combine and list into a new column in R

I have the following dataframe: df <- data.frame(name = c("michael", "michael", "michael", "jim", "jim", "pam", "dwight", "dwight", "dwight"), thing = c("mug", "bandana", "tiny tv", "pranks", "face", "reception", "bear", "beets", "battlestar galactica")) I would like to group "thing" by "name" and add it to a new column. This column must to be a list type which… Read More Group by, combine and list into a new column in R

Apply a ggplot2 function to a data frame to compute kernel density estimate

I’m able to use the group_modify function to apply the ggplot2:::compute_density function to a grouped dataframe however I’m unable to get it to work for an ungrouped data frame Here’s a simple example: mtcars %>% group_by(cyl) %>% group_modify(~ggplot2:::compute_density(.x$am, NULL)) How can this be modified to be computed on an un-grouped data frame? I’ve tried using… Read More Apply a ggplot2 function to a data frame to compute kernel density estimate