r

R ggplot2 using ..count.. when using facet_grid

自闭症网瘾萝莉.ら 提交于 2021-02-09 08:29:15
问题 I am using R studio in Ubuntu, with standard updated R and ggplot2 I try to create a histogram in ggplot, and to separate the data by groups. I need the plot's y axis to say the frequency of each bin in the subgroup that was split by the facet grid. for example if i have two entries in the data a group 1 1 2 2 I need to use facet_grid to split by group, and then to show that a has one bar for 1 that is 100% percent of the examples in group 1 and vice versa. I found out that the way to do it,

Is there a build-in ordinal sequence vector in R?

五迷三道 提交于 2021-02-09 08:28:51
问题 I need a long ordinal sequence vector in R. As a simple example of what I want: OS <- c("First","Second","Third") Is there a build-in vector like that? 回答1: from library(english) ordinal(1:5) # [1] first second third fourth fifth 回答2: I googled "R cardinal numbers" and got to the vignette for the toOrdinal package, but unfortunately it doesn't actually get you words. library(toOrdinal) sapply(1:5,toOrdinal) ## [1] "1st" "2nd" "3rd" "4th" "5th" The docs say convert_to: OPTIONAL. Output type

Is there a build-in ordinal sequence vector in R?

旧时模样 提交于 2021-02-09 08:27:30
问题 I need a long ordinal sequence vector in R. As a simple example of what I want: OS <- c("First","Second","Third") Is there a build-in vector like that? 回答1: from library(english) ordinal(1:5) # [1] first second third fourth fifth 回答2: I googled "R cardinal numbers" and got to the vignette for the toOrdinal package, but unfortunately it doesn't actually get you words. library(toOrdinal) sapply(1:5,toOrdinal) ## [1] "1st" "2nd" "3rd" "4th" "5th" The docs say convert_to: OPTIONAL. Output type

R supress console output of a system or shell command

二次信任 提交于 2021-02-09 08:16:19
问题 I have this windows-batchfile which I'm calling from R using the shell() command. This batchfile does some calculations and writes them on the disk but also on the screen. I'm interested in the disk-output, only. I cannot change the batchfile. The batchfile might be something silly like: @echo off echo 1 + 2 @echo 1 + 2 > C:\TEMP\batchoutput.txt exit I tried shell("batchfile.bat", invisible = TRUE) 1 + 2 shell("batchfile.bat", show.output.on.console = FALSE) Error in system(cmd, intern =

R S3 method not exported from namespace

自闭症网瘾萝莉.ら 提交于 2021-02-09 07:29:29
问题 Why do I have this error message : > vegan::reorder.hclust Error: 'reorder.hclust' is not an exported object from 'namespace:vegan' While this S3 method is well available. For example if I type help(reorder.hclust, package = "vegan") I obtain the intended help page and vegan:::reorder.hclust displays the source code of the function on the console... Also the NAMESPACE file of my vegan installation contains S3method(reorder, hclust) . I would like to use this function in another package were I

R S3 method not exported from namespace

☆樱花仙子☆ 提交于 2021-02-09 07:24:47
问题 Why do I have this error message : > vegan::reorder.hclust Error: 'reorder.hclust' is not an exported object from 'namespace:vegan' While this S3 method is well available. For example if I type help(reorder.hclust, package = "vegan") I obtain the intended help page and vegan:::reorder.hclust displays the source code of the function on the console... Also the NAMESPACE file of my vegan installation contains S3method(reorder, hclust) . I would like to use this function in another package were I

Adding column to Rcpp::DataFrame is falling back to list

故事扮演 提交于 2021-02-09 06:48:29
问题 When I add a column to a dataframe using Rcpp it ceases to be rendered as a dataframe once returned. I'm trying to stay as close to the original examples of adding a column as possible, but I get a list regardless of how I mutate it. As you can see below, I'm losing the class and some important attributes on the object when I add a column either via assigning to a new key or using push_back() . Runnable reprex here, or output copied below fun <- Rcpp::cppFunction(' List DataFrameExample() {

Replacing NAs between two rows with identical values in a specific column

独自空忆成欢 提交于 2021-02-09 02:49:11
问题 I have a dataframe with multiple columns and I want to replace NAs in one column if they are between two rows with an identical number. Here is my data: v1 v2 1 2 NA 3 NA 2 1 1 NA 7 NA 2 3 1 I basically want to start from the beginning of the data frame and replcae NAs in column v1 with previous Non NA if the next Non NA matches the previous one. That been said, I want the result to be like this: v1 v2 1 2 1 3 1 2 1 1 NA 7 NA 2 3 1 As you may see, rows 2 and 3 are replaced with number "1"

Replacing NAs between two rows with identical values in a specific column

烈酒焚心 提交于 2021-02-09 02:47:36
问题 I have a dataframe with multiple columns and I want to replace NAs in one column if they are between two rows with an identical number. Here is my data: v1 v2 1 2 NA 3 NA 2 1 1 NA 7 NA 2 3 1 I basically want to start from the beginning of the data frame and replcae NAs in column v1 with previous Non NA if the next Non NA matches the previous one. That been said, I want the result to be like this: v1 v2 1 2 1 3 1 2 1 1 NA 7 NA 2 3 1 As you may see, rows 2 and 3 are replaced with number "1"

How to convert SOAP request curl to RCurl

蹲街弑〆低调 提交于 2021-02-09 00:26:34
问题 How should I convert this one liner: curl -d @request.xml -o response.xml http://www.sample.com/soap It is accessing request xml which looks like this: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://sample.com/"> <soap:Body> <req:getEvents> <start>2014-12-12T00:00:00+0100</start> <end>2014-12-13T00:00:00+0100</end> <type>TYPE</type> </req:getEvents> </soap:Body> </soap:Envelope> The response is written into