r

Create bar plot with logarithmic scale in R

南楼画角 提交于 2021-02-11 13:13:01
问题 I am trying to create a bar plot with a logarithmic scale as my data varies from 3.92 to 65700. This is the code i have used so far: beach <- c(PlasticsBlue=3.92, PlasticsGrey=65700, FoamsOrange=17.9, FoamsWhite=51300, RopesGreen=9.71, RopesGreen=3140) beach par(mar = c(10, 5, 10, 5)) barplot(beach, names.arg=c("Plastics/Blue", "Plastics/Grey", "Foams/Orange", "Foams/White", "Ropes/Green", "Ropes/Green"), col=c("red2", "slateblue4", "red2", "slateblue4", "red2", "slateblue4", "red2"), legend

R: converting tidyverse to dplyr/reshape2 for plots

这一生的挚爱 提交于 2021-02-11 13:12:01
问题 In a previous post, a user showed me how to to plot longitudinal data in R. Here is the code: library(ggplot2) Data <- data.frame( "ID" = c("ABC111", "ABC111", "ABC111", "ABC111", "ABC112", "ABC112", "ABC112", "ABC113", "ABC113", "ABC114", "ABC115"), "color" = c("red", "red", "red", "red", "blue", "blue", "blue", "green", "green", "black", "yellow"), "start_date" = c("2005/01/01", "2006/01/01", "2007/01/01", "2008/01/01", "2009/01/01", "2010/01/01", "2011/01/01", "2012/01/01", "2013/01/01",

Using R, how to get the “diff” of two strings?

*爱你&永不变心* 提交于 2021-02-11 13:10:47
问题 The base R function diff computes a first difference, useful for lagged data comparisons. I am looking for the GNU diff function accessible in R: https://www.computerhope.com/unix/udiff.htm This function is useful for version control, but also useful in natural language processes to identify changes or edits between two similar text elements. This is also an underlying engine of git and so on. Ideally the function would be gnudiff(text1,text2) and if tied to quanteda or another library, that

Using R, how to get the “diff” of two strings?

痴心易碎 提交于 2021-02-11 13:10:38
问题 The base R function diff computes a first difference, useful for lagged data comparisons. I am looking for the GNU diff function accessible in R: https://www.computerhope.com/unix/udiff.htm This function is useful for version control, but also useful in natural language processes to identify changes or edits between two similar text elements. This is also an underlying engine of git and so on. Ideally the function would be gnudiff(text1,text2) and if tied to quanteda or another library, that

How to Convert CSV to Raster in R?

杀马特。学长 韩版系。学妹 提交于 2021-02-11 13:09:05
问题 I have a CSV (value, carbon, latitude, longitude) that I am trying to create a raster from. CSV file sample: Carbon Latitude Longitude coords.x1 coords.x2 1 385 36 74 36 74 2 463 36 74 36 74 3 35 36 74 36 74 4 38 36 74 36 74 5 34 36 74 36 74 6 11 36 74 36 74 7 46 36 74 36 74 8 18 36 74 36 74 9 213 36 74 36 74 10 619 36 74 36 74 11 140 36 74 36 74 12 40 36 74 36 74 13 42 36 74 36 74 14 18 36 74 36 74 15 277 36 74 36 74 16 641 36 74 36 74 17 416 36 74 36 74 18 459 36 74 36 74 19 1073 36 74 36

Error using Caret Package with “knn” method — Something is wrong; all the Accuracy metric values are missing

为君一笑 提交于 2021-02-11 13:07:48
问题 Hi I am using the caret package and training a model with a knn algorithm but I am running into an error. I am using the german credit data and this is the structure of the data frame 'data.frame': 1000 obs. of 21 variables: $ checking_balance : Factor w/ 4 levels "< 0 DM","> 200 DM",..: 1 3 4 1 1 $ months_loan_duration: int 6 48 12 42 24 36 24 36 12 30 ... $ credit_history : Factor w/ 5 levels "critical","delayed",..: 1 5 1 5 $ purpose : Factor w/ 10 levels "business","car (new)",..: 8 8 5 $

Reshaping a table in R while parsing information from column names and using it to collect information from specific columns

冷暖自知 提交于 2021-02-11 13:00:22
问题 I have this badly organized data table given to me, in which there are hundreds of columns (subset is given below) Names of columns are dot delimited where the first field holds information about a type of object (e.g. Item123, object_AB etc.) without any naming convention. There is no specific order for these columns as well. Other columns share the type of object field and also have the name of some property for that object (e.g. color, manufacturer etc.). Item123.type.value Item123.mass

Remove check all/none checkbox from Reactable table

喜你入骨 提交于 2021-02-11 12:59:39
问题 I want to remove the check all/none checkbox from a Reactable table. In this image, I do not want the orange circled checkbox to appear. Using Chrome Inspector, I examine the css of this checkbox and set display: none; This removes the entire column of checkboxes. How do I remove just this one? R Script library(reactable) reactable(iris, onClick = "select", selection = "multiple") 回答1: U can append some javascript code and make it run when the reactable is rendered: ie // Hide the select all

Error using Caret Package with “knn” method — Something is wrong; all the Accuracy metric values are missing

。_饼干妹妹 提交于 2021-02-11 12:59:17
问题 Hi I am using the caret package and training a model with a knn algorithm but I am running into an error. I am using the german credit data and this is the structure of the data frame 'data.frame': 1000 obs. of 21 variables: $ checking_balance : Factor w/ 4 levels "< 0 DM","> 200 DM",..: 1 3 4 1 1 $ months_loan_duration: int 6 48 12 42 24 36 24 36 12 30 ... $ credit_history : Factor w/ 5 levels "critical","delayed",..: 1 5 1 5 $ purpose : Factor w/ 10 levels "business","car (new)",..: 8 8 5 $

How to draw a barplot split by variable levels, while controlling for other variables via multiple regression?

家住魔仙堡 提交于 2021-02-11 12:58:24
问题 How can I draw a barplot for means, while controlling for other variables through regression -- in a split-bars-by-vars fashion? My general problem I conduct a research to figure out which fruit is more likable: mango, banana, or apple. To this end, I go ahead and sample 100 people at random. I ask them to rate, on a scale of 1-5, the degree of liking each of the fruits. I also collect some demographic information about them: gender, age, education level, and whether they are colorblind or